You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Torsten Foertsch <to...@gmx.net> on 2008/06/27 19:35:45 UTC
possible bug in Apache2::XSLoader and APR::XSLoader
Hi,
what is the purpose of Apache2::XSLoader and APR::XSLoader?
Both modules contain a load() function that reads:
sub load {
return unless BOOTSTRAP;
XSLoader::load(@_);
}
I believe this is wrong. The XSLoader::load function contains this code:
my @modparts = split(/::/,$module);
my $modfname = $modparts[-1];
my $modpname = join('/',@modparts);
my $modlibname = (caller())[1];
my $c = @modparts;
$modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext";
You see $modlibname is built from the caller's filename. If APR::XSLoader is
used this caller is /path/to/APR/XSLoader.pm and not as expected by the code
the filename of the caller of APR::XSLoader::load.
As a result XSLoader tries to load the shared lib from the wrong location.
A simple change makes it work as expected:
goto &XSLoader::load;
This way instead of pushing a new frame on the call stack the current
(APR::XSLoader::load) frame is replaced by XSLoader::load. Hence caller()
sees the original caller.
Torsten
Re: possible bug in Apache2::XSLoader and APR::XSLoader
Posted by Torsten Foertsch <to...@gmx.net>.
On Fri 27 Jun 2008, Philippe M. Chiasson wrote:
> > As a result XSLoader tries to load the shared lib from the wrong
> > location.
> >
> > A simple change makes it work as expected:
> >
> > goto &XSLoader::load;
> >
> > This way instead of pushing a new frame on the call stack the current
> > (APR::XSLoader::load) frame is replaced by XSLoader::load. Hence caller()
> > sees the original caller.
>
> Sounds like a correct fix to me.
Committed as revision 672484.
Hey, that was my first commit to trunk, :-)
Torsten
--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: possible bug in Apache2::XSLoader and APR::XSLoader
Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Torsten Foertsch wrote:
> Hi,
>
> what is the purpose of Apache2::XSLoader and APR::XSLoader?
>
> Both modules contain a load() function that reads:
>
> sub load {
> return unless BOOTSTRAP;
> XSLoader::load(@_);
> }
>
> I believe this is wrong. The XSLoader::load function contains this code:
>
> my @modparts = split(/::/,$module);
> my $modfname = $modparts[-1];
>
> my $modpname = join('/',@modparts);
> my $modlibname = (caller())[1];
> my $c = @modparts;
> $modlibname =~ s,[\\/][^\\/]+$,, while $c--; # Q&D basename
> my $file = "$modlibname/auto/$modpname/$modfname.$dl_dlext";
>
> You see $modlibname is built from the caller's filename. If APR::XSLoader is
> used this caller is /path/to/APR/XSLoader.pm and not as expected by the code
> the filename of the caller of APR::XSLoader::load.
>
> As a result XSLoader tries to load the shared lib from the wrong location.
>
> A simple change makes it work as expected:
>
> goto &XSLoader::load;
>
> This way instead of pushing a new frame on the call stack the current
> (APR::XSLoader::load) frame is replaced by XSLoader::load. Hence caller()
> sees the original caller.
Sounds like a correct fix to me.
--
Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/