New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.pmc not loaded if @INC has a trailing slash #13694
Comments
From @schwernCreated by @schwernIf the @INC directory where a .pm and .pmc are located has a trailing $ pwd $ perl -I ~/tmp -wle 'use Foo; print Foo::test()' $ perl -I ~/tmp/ -wle 'use Foo; print Foo::test()' $ cat Foo.pm sub test { "pm" } =pod =head1 NAME Foo - this is the pm =cut 1; $ cat Foo.pmc sub test { "pmc" } =pod =head1 NAME Foo - this is the pmc =cut 1; This bug appears in... This bug does not appear in... Perl Info
|
From @iabynOn Wed, Mar 26, 2014 at 03:23:06PM -0700, Michael G Schwern wrote:
A bisect comes up with this: commit 6b0bdd7 RT-116192 - If a directory in @INC already has a trailing '/', don't add another. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @wolfsageOn Sat, Mar 29, 2014 at 3:28 PM, Dave Mitchell <davem@iabyn.com> wrote:
My apologies! Patch attached. The original code always assumed a '/' would be appended, so it set With my earlier patch, this wasn't the case if the SV already ended in New tests included. -- Matthew Horsfall (alh) |
From @wolfsage0001-RT-121512-Allow-I-dir-with-trailing-slash-to-find-.p.patchFrom 4f86a010d75c228240961c2e480bae9a51653237 Mon Sep 17 00:00:00 2001
From: "Matthew Horsfall (alh)" <wolfsage@gmail.com>
Date: Mon, 31 Mar 2014 08:25:33 -0400
Subject: [PATCH] RT-121512 - Allow -I/dir/ with trailing slash to find .pmc
files.
6b0bdd7f2041803dc3ec72b53d28052705861967 updated -I to not add a
trailing '/' if one was already present, but failed to update the
length of the resulting SV to account for the lack of another character.
This caused later checks based off of that length to fail (in this case,
seeing if the last 3 characters of the string are .pm).
---
MANIFEST | 2 ++
pp_ctl.c | 5 ++++-
t/run/flib/t2.pm | 5 +++++
t/run/flib/t2.pmc | 5 +++++
t/run/switchM.t | 10 +++++++++-
5 files changed, 25 insertions(+), 2 deletions(-)
create mode 100644 t/run/flib/t2.pm
create mode 100644 t/run/flib/t2.pmc
diff --git a/MANIFEST b/MANIFEST
index 70565d5..0794152 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5444,6 +5444,8 @@ t/run/dtrace.pl For dtrace.t
t/run/dtrace.t Test for DTrace probes
t/run/exit.t Test perl's exit status.
t/run/flib/broken.pm Bad .pm file for switchM.t
+t/run/flib/t2.pm Test for .pmcs with -I/dir/
+t/run/flib/t2.pmc Test for .pmcs with -I/dir/
t/run/fresh_perl.t Tests that require a fresh perl.
t/run/locale.t Tests related to locale handling
t/run/mad.t Test vs MAD environment
diff --git a/pp_ctl.c b/pp_ctl.c
index 3c643d7..1352d38 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3954,6 +3954,7 @@ PP(pp_require)
if (path_searchable) {
const char *dir;
STRLEN dirlen;
+ U8 ext_len = 1;
if (SvOK(dirsv)) {
dir = SvPV_nomg_const(dirsv, dirlen);
@@ -3999,13 +4000,15 @@ PP(pp_require)
/* Avoid '<dir>//<file>' */
if (!dirlen || *(tmp-1) != '/') {
*tmp++ = '/';
+ } else {
+ ext_len = 0;
}
/* name came from an SV, so it will have a '\0' at the
end that we can copy as part of this memcpy(). */
memcpy(tmp, name, len + 1);
- SvCUR_set(namesv, dirlen + len + 1);
+ SvCUR_set(namesv, dirlen + len + ext_len);
SvPOK_on(namesv);
}
# endif
diff --git a/t/run/flib/t2.pm b/t/run/flib/t2.pm
new file mode 100644
index 0000000..172a14e
--- /dev/null
+++ b/t/run/flib/t2.pm
@@ -0,0 +1,5 @@
+package t2;
+
+sub id { "t2pm" }
+
+1;
diff --git a/t/run/flib/t2.pmc b/t/run/flib/t2.pmc
new file mode 100644
index 0000000..e3894bc
--- /dev/null
+++ b/t/run/flib/t2.pmc
@@ -0,0 +1,5 @@
+package t2;
+
+sub id { "t2pmc" }
+
+1;
diff --git a/t/run/switchM.t b/t/run/switchM.t
index 72e8908..6a75100 100644
--- a/t/run/switchM.t
+++ b/t/run/switchM.t
@@ -8,7 +8,7 @@ use strict;
require './test.pl';
-plan(2);
+plan(4);
like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
@@ -17,3 +17,11 @@ like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
like(runperl(switches => ['-Irun/flib/', '-Mbroken'], stderr => 1),
qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
"Ensure -Irun/flib/ produces correct filename in warnings");
+
+like(runperl(switches => ['-Irun/flib', '-Mt2', '-e "print t2::id()"'], stderr => 1),
+ qr/^t2pmc$/,
+ "Ensure -Irun/flib loads pmc");
+
+like(runperl(switches => ['-Irun/flib/', '-Mt2', '-e "print t2::id()"'], stderr => 1),
+ qr/^t2pmc$/,
+ "Ensure -Irun/flib/ loads pmc");
--
1.7.9.5
|
From @tonycozOn Mon Mar 31 05:32:55 2014, alh wrote:
I think this patch or something like it should be applied to blead and backported. The only issue I have with the patch itself is it could be simpler, instead of adding extra variable, the if could simply ++dirlen when it bumps tmp. Nothing else within the scope depends on dirlen being the length of the original @INC entry. Tony |
From @wolfsageOn Mon, Mar 31, 2014 at 7:28 PM, Tony Cook via RT
Thanks for the review Tony. Attached a version with your suggested changes. Side question (related to both of these patches) - is it bad that in Thanks, -- Matthew Horsfall (alh) |
From @wolfsage0001-RT-121512-Allow-I-dir-with-trailing-slash-to-find-.p.patchFrom 3277d1b90c2bf865b14f5bf27134f6c28b9d607f Mon Sep 17 00:00:00 2001
From: "Matthew Horsfall (alh)" <wolfsage@gmail.com>
Date: Mon, 31 Mar 2014 08:25:33 -0400
Subject: [PATCH] RT-121512 - Allow -I/dir/ with trailing slash to find .pmc
files.
6b0bdd7f2041803dc3ec72b53d28052705861967 updated -I to not add a
trailing '/' if one was already present, but failed to update the
length of the resulting SV to account for the lack of another character.
This caused later checks based off of that length to fail (in this case,
seeing if the last 3 characters of the string are .pm).
---
MANIFEST | 2 ++
pp_ctl.c | 3 +++
t/run/flib/t2.pm | 5 +++++
t/run/flib/t2.pmc | 5 +++++
t/run/switchM.t | 10 +++++++++-
5 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 t/run/flib/t2.pm
create mode 100644 t/run/flib/t2.pmc
diff --git a/MANIFEST b/MANIFEST
index 70565d5..0794152 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5444,6 +5444,8 @@ t/run/dtrace.pl For dtrace.t
t/run/dtrace.t Test for DTrace probes
t/run/exit.t Test perl's exit status.
t/run/flib/broken.pm Bad .pm file for switchM.t
+t/run/flib/t2.pm Test for .pmcs with -I/dir/
+t/run/flib/t2.pmc Test for .pmcs with -I/dir/
t/run/fresh_perl.t Tests that require a fresh perl.
t/run/locale.t Tests related to locale handling
t/run/mad.t Test vs MAD environment
diff --git a/pp_ctl.c b/pp_ctl.c
index 3c643d7..e13e450 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3999,6 +3999,9 @@ PP(pp_require)
/* Avoid '<dir>//<file>' */
if (!dirlen || *(tmp-1) != '/') {
*tmp++ = '/';
+ } else {
+ /* So SvCUR_set reports the correct length below */
+ dirlen--;
}
/* name came from an SV, so it will have a '\0' at the
diff --git a/t/run/flib/t2.pm b/t/run/flib/t2.pm
new file mode 100644
index 0000000..172a14e
--- /dev/null
+++ b/t/run/flib/t2.pm
@@ -0,0 +1,5 @@
+package t2;
+
+sub id { "t2pm" }
+
+1;
diff --git a/t/run/flib/t2.pmc b/t/run/flib/t2.pmc
new file mode 100644
index 0000000..e3894bc
--- /dev/null
+++ b/t/run/flib/t2.pmc
@@ -0,0 +1,5 @@
+package t2;
+
+sub id { "t2pmc" }
+
+1;
diff --git a/t/run/switchM.t b/t/run/switchM.t
index 72e8908..6a75100 100644
--- a/t/run/switchM.t
+++ b/t/run/switchM.t
@@ -8,7 +8,7 @@ use strict;
require './test.pl';
-plan(2);
+plan(4);
like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
@@ -17,3 +17,11 @@ like(runperl(switches => ['-Irun/flib', '-Mbroken'], stderr => 1),
like(runperl(switches => ['-Irun/flib/', '-Mbroken'], stderr => 1),
qr/^Global symbol "\$x" requires explicit package name at run\/flib\/broken.pm line 6\./,
"Ensure -Irun/flib/ produces correct filename in warnings");
+
+like(runperl(switches => ['-Irun/flib', '-Mt2', '-e "print t2::id()"'], stderr => 1),
+ qr/^t2pmc$/,
+ "Ensure -Irun/flib loads pmc");
+
+like(runperl(switches => ['-Irun/flib/', '-Mt2', '-e "print t2::id()"'], stderr => 1),
+ qr/^t2pmc$/,
+ "Ensure -Irun/flib/ loads pmc");
--
1.7.9.5
|
From @tonycozOn Tue Apr 01 09:42:26 2014, alh wrote:
That isn't a problem, SvGROW() will often allocate a bit more space anyway. pp_sysread() provides one example where we grow to a length where perhaps not all that space is used. Tony |
From @wolfsageOn Tue Apr 01 21:12:13 2014, tonyc wrote:
Alright, thanks. I've pushed this to blead. Closing. -- Matthew Horsfall (alh) -- |
@wolfsage - Status changed from 'open' to 'resolved' |
From [Unknown Contact. See original ticket]Relevant commit: 9fdd5a7 -- Matthew Horsfall (alh) |
Migrated from rt.perl.org#121512 (status was 'resolved')
Searchable as RT121512$
The text was updated successfully, but these errors were encountered: