You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jim Winstead <ji...@trainedmonkey.com> on 2000/06/26 22:59:38 UTC

recursion in Apache::Constants::AUTOLOAD?

We were seeing some servers spin out of control (allocating memory
slowly) in Apace::Constants::AUTOLOAD (which apparently has been
reported in the mailing list before).

The attached patch fixes the problems for us. Could someone who
understands what is going on here shed some light?

Jim

Re: recursion in Apache::Constants::AUTOLOAD?

Posted by Jim Winstead <ji...@trainedmonkey.com>.
On Aug 15, Doug MacEachern wrote:
> On Mon, 26 Jun 2000, Jim Winstead wrote:
> 
> > We were seeing some servers spin out of control (allocating memory
> > slowly) in Apace::Constants::AUTOLOAD (which apparently has been
> > reported in the mailing list before).
> > 
> > The attached patch fixes the problems for us. Could someone who
> > understands what is going on here shed some light?
> 
> ouch, how did you trigger this problem?  i don't see how that could
> happen Apache::Constants::__AUTOLOAD should always be defined inside
> httpd.  does this version of your patch prevent it?

good question. i have no idea what triggered it. and since our
patch seems to have cleared up the problem for us (which i think
we only ever saw on production servers), i'm reluctant to try a
new one.

perhaps it is related to this old problem:

http://marc.theaimsgroup.com/?l=apache-modperl&m=94528502827088&w=2

jim

Re: recursion in Apache::Constants::AUTOLOAD?

Posted by David Alan Pisoni <da...@cnation.com>.
Sorry I don't have much in the way of details, but we had this problem several months ago (probably in a previous version of mod_perl), but it silently went away.
(I'm reminded of it because recently I was reviewing the handler() of our recently open-sourced embedded parser, Apache::XPP, and found that the constants had been hard-coded to avoid the AUTOLOAD() spinning.  I put the constant calls back in :-)

Enjoy,
David

At 8.17 -0700 9/28/2000, Doug MacEachern wrote:
>On Mon, 26 Jun 2000, Jim Winstead wrote:
>
>> We were seeing some servers spin out of control (allocating memory
>> slowly) in Apace::Constants::AUTOLOAD (which apparently has been
>> reported in the mailing list before).
>>
>> The attached patch fixes the problems for us. Could someone who
>> understands what is going on here shed some light?
>
>i still don't understand how __AUTOLOAD can be undefined inside the
>server.  this patch adds an extra check that will prevent recursion if
>__AUTOLOAD is somehow undefined and print a stacktrace to give some idea
>where the problem is.
>
>Index: Constants/Constants.pm
>===================================================================
>RCS file: /home/cvs/modperl/Constants/Constants.pm,v
>retrieving revision 1.20
>diff -u -r1.20 Constants.pm
>--- Constants/Constants.pm	2000/03/03 20:42:01	1.20
>+++ Constants/Constants.pm	2000/09/28 15:12:36
>@@ -17,9 +17,16 @@
> if ($ENV{MOD_PERL}) {
>     #outside of mod_perl this will recurse looking for __AUTOLOAD, grr
>     *AUTOLOAD  = sub {
>-	#why must we stringify first???
>-	__AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
>-	goto &$Apache::Constants::AUTOLOAD;
>+        if (defined &__AUTOLOAD) { #make extra sure we don't recurse
>+            #why must we stringify first???
>+            __AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
>+            goto &$Apache::Constants::AUTOLOAD;
>+        }
>+        else {
>+            require Carp;
>+            Carp::confess("__AUTOLOAD is undefined, ",
>+                          "trying to AUTOLOAD $Apache::Constants::AUTOLOAD");
>+        }
>     };
> }
> 


Re: recursion in Apache::Constants::AUTOLOAD?

Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 26 Jun 2000, Jim Winstead wrote:

> We were seeing some servers spin out of control (allocating memory
> slowly) in Apace::Constants::AUTOLOAD (which apparently has been
> reported in the mailing list before).
> 
> The attached patch fixes the problems for us. Could someone who
> understands what is going on here shed some light?

i still don't understand how __AUTOLOAD can be undefined inside the
server.  this patch adds an extra check that will prevent recursion if
__AUTOLOAD is somehow undefined and print a stacktrace to give some idea
where the problem is.

Index: Constants/Constants.pm
===================================================================
RCS file: /home/cvs/modperl/Constants/Constants.pm,v
retrieving revision 1.20
diff -u -r1.20 Constants.pm
--- Constants/Constants.pm	2000/03/03 20:42:01	1.20
+++ Constants/Constants.pm	2000/09/28 15:12:36
@@ -17,9 +17,16 @@
 if ($ENV{MOD_PERL}) {
     #outside of mod_perl this will recurse looking for __AUTOLOAD, grr
     *AUTOLOAD  = sub {
-	#why must we stringify first???
-	__AUTOLOAD() if "$Apache::Constants::AUTOLOAD"; 
-	goto &$Apache::Constants::AUTOLOAD;
+        if (defined &__AUTOLOAD) { #make extra sure we don't recurse
+            #why must we stringify first???
+            __AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
+            goto &$Apache::Constants::AUTOLOAD;
+        }
+        else {
+            require Carp;
+            Carp::confess("__AUTOLOAD is undefined, ",
+                          "trying to AUTOLOAD $Apache::Constants::AUTOLOAD");
+        }
     };
 }
 


Re: recursion in Apache::Constants::AUTOLOAD?

Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 26 Jun 2000, Jim Winstead wrote:

> We were seeing some servers spin out of control (allocating memory
> slowly) in Apace::Constants::AUTOLOAD (which apparently has been
> reported in the mailing list before).
> 
> The attached patch fixes the problems for us. Could someone who
> understands what is going on here shed some light?

ouch, how did you trigger this problem?  i don't see how that could
happen Apache::Constants::__AUTOLOAD should always be defined inside
httpd.  does this version of your patch prevent it?

--- Constants/Constants.pm      2000/03/03 20:42:01     1.20
+++ Constants/Constants.pm      2000/08/16 04:05:45
@@ -18,7 +18,7 @@
     #outside of mod_perl this will recurse looking for __AUTOLOAD, grr
     *AUTOLOAD  = sub {
        #why must we stringify first???
-       __AUTOLOAD() if "$Apache::Constants::AUTOLOAD"; 
+       __AUTOLOAD() unless $Apache::Constants::AUTOLOAD =~ /__AUTOLOAD$/;
        goto &$Apache::Constants::AUTOLOAD;
     };
 }