Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Dev

possible bug in Apache2::XSLoader and APR::XSLoader

 

 

ModPerl dev RSS feed   Index | Next | Previous | View Threaded


torsten.foertsch at gmx

Jun 27, 2008, 10:35 AM

Post #1 of 3 (685 views)
Permalink
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
Attachments: XSLoader.diff (0.84 KB)


gozer at ectoplasm

Jun 27, 2008, 10:40 AM

Post #2 of 3 (651 views)
Permalink
Re: possible bug in Apache2::XSLoader and APR::XSLoader [In reply to]

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/
Attachments: signature.asc (0.24 KB)


torsten.foertsch at gmx

Jun 28, 2008, 2:50 AM

Post #3 of 3 (642 views)
Permalink
Re: possible bug in Apache2::XSLoader and APR::XSLoader [In reply to]

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[at]gmx.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe[at]perl.apache.org
For additional commands, e-mail: dev-help[at]perl.apache.org

ModPerl dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.