Skip Menu |
Report information
Id: 121512
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: schwern <schwern [at] pobox.com>
Cc:
AdminCc:

Operating System: darwin
PatchStatus: (no value)
Severity: medium
Type: core
Perl Version: 5.18.2
Fixed In: (no value)



To: perlbug [...] perl.org
Date: Wed, 26 Mar 2014 15:22:48 -0700
Subject: .pmc not loaded if @INC has a trailing slash
CC: Michael Schwern <schwern [...] pobox.com>
From: Michael G Schwern <schwern [...] pobox.com>
This is a bug report for perl from schwern@pobox.com, generated with the help of perlbug 1.39 running under perl 5.18.2. ----------------------------------------------------------------- [Please describe your issue here] If the @INC directory where a .pm and .pmc are located has a trailing slash, require will fail to load the .pmc. I suspect this bug was added in eb70bb4a400e88a66c7e10414a2d52b5da4cfd1f $ pwd /Users/schwern/tmp $ perl -I ~/tmp -wle 'use Foo; print Foo::test()' pmc $ perl -I ~/tmp/ -wle 'use Foo; print Foo::test()' pm $ cat Foo.pm package Foo; sub test { "pm" } =pod =head1 NAME Foo - this is the pm =cut 1; $ cat Foo.pmc package Foo; sub test { "pmc" } =pod =head1 NAME Foo - this is the pmc =cut 1; This bug appears in... 5.18.1 5.18.2 5.19.10 This bug does not appear in... 5.10.1 5.12.5 5.14.4 5.16.3 [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl 5.18.2: Configured by schwern at Thu Mar 6 14:40:23 PST 2014. Summary of my perl5 (revision 5 version 18 subversion 2) configuration: Platform: osname=darwin, osvers=13.1.0, archname=darwin-2level uname='darwin windhund.local 13.1.0 darwin kernel version 13.1.0: thu jan 16 19:40:37 pst 2014; root:xnu-2422.90.20~2release_x86_64 x86_64 i386 macbookpro8,1 darwin ' config_args='-de -Dprefix=/Users/schwern/perl5/perlbrew/perls/perl-5.18.2 -Aeval:scriptdir=/Users/schwern/perl5/perlbrew/perls/perl-5.18.2/bin' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include', optimize='-O3', cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/opt/local/include' ccversion='', gccversion='4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/opt/local/lib' libpth=/opt/local/lib /usr/lib libs=-lgdbm -ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/opt/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.18.2: /Users/schwern/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/darwin-2level /Users/schwern/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2 /Users/schwern/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2/darwin-2level /Users/schwern/perl5/perlbrew/perls/perl-5.18.2/lib/5.18.2 . --- Environment for perl 5.18.2: DYLD_LIBRARY_PATH (unset) HOME=/Users/schwern LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/Users/schwern/perl5/perlbrew/bin:/Users/schwern/perl5/perlbrew/perls/perl-5.18.2/bin:/Users/schwern/bin:/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/MacGPG2/bin PERLBREW_BASHRC_VERSION=0.67 PERLBREW_HOME=/Users/schwern/.perlbrew PERLBREW_MANPATH=/Users/schwern/perl5/perlbrew/perls/perl-5.18.2/man PERLBREW_PATH=/Users/schwern/perl5/perlbrew/bin:/Users/schwern/perl5/perlbrew/perls/perl-5.18.2/bin PERLBREW_PERL=perl-5.18.2 PERLBREW_ROOT=/Users/schwern/perl5/perlbrew PERLBREW_VERSION=0.67 PERL_BADLANG (unset) SHELL=/bin/bash
To: perl5-porters [...] perl.org
Date: Sat, 29 Mar 2014 19:28:59 +0000
Subject: Re: [perl #121512] .pmc not loaded if @INC has a trailing slash
From: Dave Mitchell <davem [...] iabyn.com>
CC: wolfsage [...] gmail.com
Download (untitled) / with headers
text/plain 657b
On Wed, Mar 26, 2014 at 03:23:06PM -0700, Michael G Schwern wrote: Show quoted text
> If the @INC directory where a .pm and .pmc are located has a trailing > slash, require will fail to load the .pmc. I suspect this bug was > added in eb70bb4a400e88a66c7e10414a2d52b5da4cfd1f
A bisect comes up with this: commit 6b0bdd7f2041803dc3ec72b53d28052705861967 Author: Matthew Horsfall (alh) <wolfsage@gmail.com> AuthorDate: Thu Dec 27 10:38:08 2012 -0500 Commit: Father Chrysostomos <sprout@cpan.org> CommitDate: Sun Feb 10 12:19:15 2013 -0800 RT-116192 - If a directory in @INC already has a trailing '/', don't add another. -- Nothing ventured, nothing lost.
From: "Matthew Horsfall (alh)" <wolfsage [...] gmail.com>
Subject: Re: [perl #121512] .pmc not loaded if @INC has a trailing slash
Date: Mon, 31 Mar 2014 08:32:27 -0400
To: Perl5 Porters <perl5-porters [...] perl.org>
On Sat, Mar 29, 2014 at 3:28 PM, Dave Mitchell <davem@iabyn.com> wrote: Show quoted text
> On Wed, Mar 26, 2014 at 03:23:06PM -0700, Michael G Schwern wrote:
>> If the @INC directory where a .pm and .pmc are located has a trailing >> slash, require will fail to load the .pmc. I suspect this bug was >> added in eb70bb4a400e88a66c7e10414a2d52b5da4cfd1f
> > A bisect comes up with this: > > commit 6b0bdd7f2041803dc3ec72b53d28052705861967 > Author: Matthew Horsfall (alh) <wolfsage@gmail.com> > AuthorDate: Thu Dec 27 10:38:08 2012 -0500 > Commit: Father Chrysostomos <sprout@cpan.org> > CommitDate: Sun Feb 10 12:19:15 2013 -0800 > > RT-116192 - If a directory in @INC already has a trailing '/', don't add another.
My apologies! Patch attached. The original code always assumed a '/' would be appended, so it set the length of the resulting SV to be +1. With my earlier patch, this wasn't the case if the SV already ended in a '/', so later checks on the SV that were based off the length of the SV would be wrong. New tests included. -- Matthew Horsfall (alh)

Message body is not shown because sender requested not to inline it.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 810b
On Mon Mar 31 05:32:55 2014, alh wrote: Show quoted text
> > RT-116192 - If a directory in @INC already has a trailing '/', don't > > add another.
> > My apologies! Patch attached. > > The original code always assumed a '/' would be appended, so it set > the length of the resulting SV to be +1. > > With my earlier patch, this wasn't the case if the SV already ended in > a '/', so later checks on the SV that were based off the length of the > SV would be wrong. > > New tests included.
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
Date: Tue, 1 Apr 2014 12:41:58 -0400
To: perlbug-followup [...] perl.org
Subject: Re: [perl #121512] .pmc not loaded if @INC has a trailing slash
CC: Perl5 Porters <perl5-porters [...] perl.org>
From: "Matthew Horsfall (alh)" <wolfsage [...] gmail.com>
Download (untitled) / with headers
text/plain 804b
On Mon, Mar 31, 2014 at 7:28 PM, Tony Cook via RT <perlbug-followup@perl.org> wrote: Show quoted text
> 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.
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 the case of dirs that already end with '/', we're calling SvGROW with one more byte than we end up using? Or is there nothing wrong with SvGROW to an arbitrary length and SvCUR_set to a smaller size? Thanks, -- Matthew Horsfall (alh)

Message body is not shown because sender requested not to inline it.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 502b
On Tue Apr 01 09:42:26 2014, alh wrote: Show quoted text
> Side question (related to both of these patches) - is it bad that in > the case of dirs that already end with '/', we're calling SvGROW with > one more byte than we end up using? Or is there nothing wrong with > SvGROW to an arbitrary length and SvCUR_set to a smaller size?
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
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 683b
On Tue Apr 01 21:12:13 2014, tonyc wrote: Show quoted text
> On Tue Apr 01 09:42:26 2014, alh wrote:
> > Side question (related to both of these patches) - is it bad that in > > the case of dirs that already end with '/', we're calling SvGROW with > > one more byte than we end up using? Or is there nothing wrong with > > SvGROW to an arbitrary length and SvCUR_set to a smaller size?
> > 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
Alright, thanks. I've pushed this to blead. Closing. -- Matthew Horsfall (alh) -- -- Matthew Horsfall (alh)
RT-Send-CC: perl5-porters [...] perl.org
Relevant commit: 9fdd5a7ac74817cfaab65f7284f98ea66faca324 -- Matthew Horsfall (alh)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org