local (*in) = @_; $in = 5;
this gets wrapped as:
sub handler {
local (*in) = @_;
$in = 5;
}and then called as:
handler($r);
so the above code corrupts the guts $r, while keeping it a valid object.
Here is Devel::Peek::Dump($r) before the above handler is called:
SV = RV(0x82c8cb8) at 0x81bcab0
REFCNT = 1
FLAGS = (PADBUSY,PADMY,ROK)
RV = 0x853a4c8
SV = PVMG(0x88d3190) at 0x853a4c8
REFCNT = 5
FLAGS = (OBJECT,IOK,pIOK)
IV = 143444264
NV = 0
PV = 0
STASH = 0x81de51c "Apache::RequestRec"Here it is after:
SV = RV(0x82c8cb8) at 0x81bcab0
REFCNT = 1
FLAGS = (PADBUSY,PADMY,ROK)
RV = 0x853a4c8
SV = PVMG(0x88d3190) at 0x853a4c8
REFCNT = 5
FLAGS = (OBJECT,IOK,pIOK)
IV = 5
NV = 0
PV = 0
STASH = 0x81de51c "Apache::RequestRec"as you can see it's essentially the same thing, but its IV slot which contains a C reference to the real object is now corrupted (got the assignment). So there is no way to check whether the object is valid. But luckily we can dereference the object and preserve it guts, no matter what horrors are done to it ;)
Here is my take on this issue
Index: lib/ModPerl/RegistryCooker.pm =================================================================== RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v retrieving revision 1.35 diff -u -r1.35 RegistryCooker.pm --- lib/ModPerl/RegistryCooker.pm 23 Mar 2003 04:52:24 -0000 1.35 +++ lib/ModPerl/RegistryCooker.pm 22 Aug 2003 07:30:27 -0000 @@ -181,7 +181,14 @@
{ # run the code and preserve warnings setup when it's done
no warnings;
+
+ my $r_iv = $$r; # people do things...
eval { $cv->($r, @_) };
+ unless (ref($r) eq 'SCALAR' && $$r == $r_iv) {
+ warn "dude, you just killed \$r! ($self->{FILENAME})\n";
+ $$r = $r_iv; # restore the IV slot
+ }
+
ModPerl::Global::special_list_call(END => $package);
}Adolph, please try your old code that you posted here earlier, after you apply this patch. RegistryCooker shouldn't be affected anylonger.
I'm not sure whether we should apply this patch. Comments?
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
