You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dorian Taylor <do...@foobarsystems.com> on 2004/11/22 20:58:44 UTC

mod_perl, SVN::Core-related segfault condition

it's kind of a grey area as to where this problem is living - hence
the double post. taking a mod_perl module that uses SVN::Core (e.g.
SVN::Web), and either preloading it via PerlLoadModule/PerlModule,
or the + notation in PerlResponseHandler will cause apache to
segfault somewhere around modperl_perl_call_endav (the perl END
block handler). SVN::Core's END block contains apr_terminate().
it seems some sort of desynch is occurring in the teardown after
the initial preflight apache configuration phase. i suspect that
by the time SVN::Core's END block is executed, the pool has already
been freed by mod_perl. my understanding of these inner workings
is fairly limited though.

the platform is osx 10.3.6, apache 2.1.0-dev (worker.c), perl 5.8.5,
mod_perl 1.99_18, apr and apr-util 1.0.1, and subversion 1.1.1.

here's the backtrace. strangely, modperl_perl_call_endav is missing
from the stack, but it shows up if you set the breakpoint to it.

Breakpoint 1, 0x00610758 in modperl_perl_call_list ()
(gdb) bt
#0  0x00610758 in modperl_perl_call_list ()
Reading memory from the sp at: bffffb00
Reading memory from the sp at: bffffb00
Reading memory from the sp at: bffffb00
#1  0x00619998 in modperl_perl_destruct ()
#2  0x006083f0 in modperl_interp_destroy ()
#3  0x006095f0 in modperl_tipool_destroy ()
#4  0x00608548 in modperl_interp_pool_destroy ()
#5  0x003a5f74 in run_cleanups (cref=0x18bc828) at memory/unix/apr_pools.c:1973
#6  0x003a5678 in apr_pool_destroy (pool=0x18bc818) at memory/unix/apr_pools.c:714
#7  0x003a55c0 in apr_pool_clear (pool=0x1806218) at memory/unix/apr_pools.c:673
#8  0x0002870c in main (argc=3, argv=0xbffffe88) at main.c:653


cheers

.dorian

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Stas Bekman <st...@stason.org>.
Dorian Taylor wrote:
> On Tue, Nov 23, 2004 at 10:08:49PM +0000, Dorian Taylor wrote:
> 
>>>But I don't see the problem that you describe.
>>
>>hm, i guess that makes the problem either a mac thing, an apr thing
>>or an apache thing.
> 
> 
> apparently it's httpd-2.1. damnit. that means now i have to backport
> mod_dav_lock.

Better fix 2.1 before 2.2 is released.

> oh well, mystery solved.

so what is the problem? Why doesn't it happen with httpd-2.0?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Dorian Taylor <do...@foobarsystems.com>.
On Tue, Nov 23, 2004 at 10:08:49PM +0000, Dorian Taylor wrote:
> > But I don't see the problem that you describe.
> 
> hm, i guess that makes the problem either a mac thing, an apr thing
> or an apache thing.

apparently it's httpd-2.1. damnit. that means now i have to backport
mod_dav_lock.

oh well, mystery solved.

.d

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Dorian Taylor <do...@foobarsystems.com>.
> But I don't see the problem that you describe.

hm, i guess that makes the problem either a mac thing, an apr thing
or an apache thing.
 
> Though I've httpd-2.0 and apr-0. Does this distro crash for you?

i'm rolling back now. i have httpd-2.1 for mod_dav_lock (i tried
just grabbing that separately and building it against 2.0 but there
have been significant enough changes in the api to thwart that),
and apr-1.0 (considered 'best-available' by apache but oddly enough
won't build against httpd-2.0.52).
 
> Is it possible that your httpd and this module are compiled against 
> different libapr versions?

yeah, they're the identical libraries, i had already made that
mistake a couple weeks ago. ;).

anyway, rebuilding all this is going to take a bit. will post results
when i'm done.

.d

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> Dorian Taylor wrote:
> 
>> argh, spacy today.
>>
>> *here* is the file.
> 
> 
> Hmm, I've further extended your distro to include a live A-T setup
> (attached). I've added:
> 
> % cat t/conf/extra.conf.in
> PerlModule +APR::CrashMe

I've also tried:

% rm t/conf/extra.conf.in
% echo "PerlLoadModule APR::CrashMe" > t/conf/extra.conf.last.in

with the same result (last.in ensures that @INC and Apache2.pm are 
adjusted by the time it's Included)


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Stas Bekman <st...@stason.org>.
Dorian Taylor wrote:
> argh, spacy today.
> 
> *here* is the file.

Hmm, I've further extended your distro to include a live A-T setup
(attached). I've added:

% cat t/conf/extra.conf.in
PerlModule +APR::CrashMe

and some things in Makefile.PL.

But I don't see the problem that you describe.

Though I've httpd-2.0 and apr-0. Does this distro crash for you?

Is it possible that your httpd and this module are compiled against 
different libapr versions?

(ah, don't forget to re-adjust LIBS/INC :)

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: mod_perl, SVN::Core-related segfault condition

Posted by Dorian Taylor <do...@foobarsystems.com>.
argh, spacy today.

*here* is the file.

Re: mod_perl, SVN::Core-related segfault condition

Posted by Dorian Taylor <do...@foobarsystems.com>.
oops, sorry, was in the wrong mutt window.

> >what exactly is required from mod_perl in the preflight config
> >stage? does it basically just `use' every preloaded module in the
> >conf to see if it can?
 
> I'm not sure what do you ask. I meant apr design problem, not modperl's 
> one. mod_perl does not init apr, httpd does.

ah, gotcha.
 
> BTW, I think you may have the same problem with mod_cgi. I'm not sure 
> whether apr_terminate is called on child process shutdown.

interesting, i'll look.

> OK, so post that XS module that reproduces the problem and I'll see if 
> something can be done.

attached. you'll need to supply LIBS and INC to the Makefile.PL.
 
> It depends on how it is implemented. The fix should be most likely in the 
> SVN module. It should detect that it's running under Apache or APR 
> environment and in which case not run the shutdown of apr environment. And 
> this solution will be transparent to mod_perl.

i guess anything that accesses apr directly is affected. SVN::Core
should probably really use APR::Pool anyway. i'll discuss it with the author.

# httpd.conf
PerlLoadModule APR::CrashMe

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Stas Bekman <st...@stason.org>.
Dorian Taylor wrote:

>>>i suspect though that anything trying to directly call apr_terminate()
>>
>>>from an END block would do the same. the debugger gets all fuzzy
>>
>>>when it gets into there though.
>>
>>Yeah, sounds like a design problem.
> 
> 
> what exactly is required from mod_perl in the preflight config
> stage? does it basically just `use' every preloaded module in the
> conf to see if it can?

I'm not sure what do you ask. I meant apr design problem, not modperl's 
one. mod_perl does not init apr, httpd does.

BTW, I think you may have the same problem with mod_cgi. I'm not sure 
whether apr_terminate is called on child process shutdown.

>>Are you in rush to get this fixed? Or can I try to finish a few other 
>>things first (though not urgent).
> 
> 
> a bit of one. i'm basically doing a kind of a reimplementation of
> mod_negotiation, mod_dir and mod_mime (plus a couple other things)
> to work on svn repositories. those modules interface directly with
> the filesystem, so i need to provide a different method for emulating
> various features of the filesystem. i wanted to do them up in
> mod_perl with SVN::Core.

OK, so post that XS module that reproduces the problem and I'll see if 
something can be done.

>>If you have an XS module that doesn't depend on SVN that would be handy too.
> 
> 
> yeah, that's what i'm going to be working on. just basically BEGIN
> { apr_initialize() } END { apr_terminate() }, in xs. i bet it'll
> do the same thing.

It depends on how it is implemented. The fix should be most likely in the 
SVN module. It should detect that it's running under Apache or APR 
environment and in which case not run the shutdown of apr environment. And 
this solution will be transparent to mod_perl.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mod_perl, SVN::Core-related segfault condition

Posted by Dorian Taylor <do...@foobarsystems.com>.
> getting things to work. I first spent hours trying to get the mandrake 
> cooker binaries to work, but eventually I've built everything from source.

yeah i went that way installing it all on my mac. i typically find
i end up needing the source for reference if nothing else at one
point or another.

> >oh, and swig 1.3.22 or higher won't work, because the guy changed
> >the way it works. i used 1.3.20.
> 
> really? oh my, luckily I had swig-1.3.21-5mdk

yeah, that was worth a couple hours of head-scratching.
 
> >i suspect though that anything trying to directly call apr_terminate()
> >from an END block would do the same. the debugger gets all fuzzy
> >when it gets into there though.
> 
> Yeah, sounds like a design problem.

what exactly is required from mod_perl in the preflight config
stage? does it basically just `use' every preloaded module in the
conf to see if it can?

> Thanks I think I'm OK now and I prefer to work on my own machine :)

ok, no worries.

> Are you in rush to get this fixed? Or can I try to finish a few other 
> things first (though not urgent).

a bit of one. i'm basically doing a kind of a reimplementation of
mod_negotiation, mod_dir and mod_mime (plus a couple other things)
to work on svn repositories. those modules interface directly with
the filesystem, so i need to provide a different method for emulating
various features of the filesystem. i wanted to do them up in
mod_perl with SVN::Core.

> If you have an XS module that doesn't depend on SVN that would be handy too.

yeah, that's what i'm going to be working on. just basically BEGIN
{ apr_initialize() } END { apr_terminate() }, in xs. i bet it'll
do the same thing.

.d

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html