perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <>
Subject Handler leakage
Date Mon, 02 Mar 2009 16:58:11 GMT

I have just stumbled on the following behavior.


  package My::Object;
  sub handler : method {
    my ($self, $r)=@_;

    $r->push_handlers(PerlLogHandler =>
                      sub {

  sub DESTROY {...}


<Location /handler>
  PerlResponseHandler $My::XX->handler
<Location /quit>
  PerlResponseHandler "sub {undef $My::XX; $_[0]->child_terminate; 0;}"

If /quit is called the $My::XX object is undefined. So the one and only 
reference to the global object is released and it has to be destroyed. 
That works but only if /handler hasn't been called before.

The reason can be found in modperl_handler.c. Each time /handler is 
called a new closure is stored in $PL_modglobal{ANONSUB}{$id}. 
Unfortunately the closure is never deleted from the hash I believe. So 
since $self is in the pad each time /handler is called a reference is 
added to $My::XX from the closure.

I think that analysis is correct (not very sure) but I don't really know 
how to fix it.

Any hints, ideas?


Need professional mod_perl support?
Just hire me:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message