perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sreeji K Das <>
Subject [BUG?] PerlFreshRestart gives undef. subs (not the one in FAQ !!)
Date Tue, 26 Feb 2002 14:04:36 GMT
Hi All,
I had been banging my head on this problem for a while
& finally I guess I've found a solution.

Following was the problem:
I had

PerlFreshRestart On
PerlRestartHandler Apache::Symbol

in my conf. I needed the restart func. & didn't want
to use other alternates (like Apache::Reload, StatINC
..etc.). Whenever I did a kill -USR1 I used to get
random 'Undefined subroutine xyz called at..'.
Following seems to be the problem:

mod_perl does something like the following on restart:
while (($k, $v) = each(%INC))
 delete($INC{$k}); eval("require $k");

Now assume that %INC has keys, File::Basename in
that order in %INC.
So following is the sequence:
delete from %INC

Now let's say does a 'use File::Basename' & then
calls basename($temp) (ie. some func in
However 'use File::Basename' will not happen, since
perl sees that it exists in %INC (see man perldoc &
the entry of use/require/do). However, the truth is
All functions in File::Basename had been undef'd by
Apache::Symbol (this needs to be done, otherwise I get
a func. redefined for all functions on restart).
So the call basename($temp) fails with a fatal error
'Undefined subroutine File::Basename::basename called
at ...' !!

Since %INC is a hash, each time you'd get a different
'Undefined sub' message. For eg. in the above example,
if File::Basename had come b4 in %INC, then we
wouldn't have got any errors.

So the work around that I did is to undef %INC after
making a copy. Now perl would load all modules
properly. I went back in time (!) for a while & found
that mod_perl-1.19 implements things correctly.

Attached simple patch corrected my problem. Would some
mod_perl guru do a proper fix (I dunno the internals
much) & release a version ?

BTW, there was another bug in Apache::Symbol. ie. the
perl -MDevel::Symdump -e '$t = new Devel::Symdump;
foreach ($t->packages) { print "$_\n"; "'
prints <none> as one of the packages (Only in perl
5.6.1). A work around for the same is also attached.

Hope I've made things clear. I can prepare some test
scripts to demo these problems, if some1 really
requires that.


Attached is the patch 

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
View raw message