perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: mod_perl2 (ModPerl::Registry) crashes httpd if request-object is used in a subroutine
Date Tue, 20 Jan 2004 00:14:42 GMT
Perrin Harkins wrote:
> Alexander Bergolth wrote:
> 
>> When I'm using the request-object in a subroutine without having passed
>> it to the sub as a parameter, the apache child processes die with a 
>> segmentation fault when being reused.
> 
> 
> Well, it probably shouldn't segfault, but you can't do that.  You are 
> creating a closure which will permanently keep a copy of the very first 
> $r that existed in that process, but $r is really an apache structure 
> that gets freed after each request.  If you need a copy of $r but don't 
> want to pass it, and you are running in pre-fork MPM, you can use the 
> Apache->request() call.

I've looked at trying to avoid the segfault. I think we can't much do about 
it. Any object with C guts can be trapped in the closure and contain a pointer 
to invalid data on subsequent accesses. You can't check whether the pointer to 
the C object is invalid or not. Since its members all look valid and the 
memory it used to occupy has been freed already, it may or may not be 
overtaken by someone else, so there is no reliable test.

Let's say we have added some signature to each object that marks it as 
destroyed on DESTROY. Then we could check that validity flag in every method 
attempting to use that object. But it'll add CPU and memory overhead which 
normally is not needed, since the closure created by Alexander is a bug in his 
program and not a normal behavior.

I'm quite sure that you will have the same problem with mp1, if you run that 
closure script on it.

__________________________________________________________________
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


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Mime
View raw message