develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [perl #21347] segfault in UNIVERSAL::AUTOLOAD

Thread Previous | Thread Next
Rafael Garcia-Suarez
February 24, 2003 13:18
Re: [perl #21347] segfault in UNIVERSAL::AUTOLOAD
Message ID:
Enache Adrian wrote:
> Perl blesses the reference qr// returns into a hypothetical
> "Regexp" package (see pp_qr() - pp_hot.c:1140) . It seems that the
> only use for this trick is that
> 	$a = qr/ ... /;
> 	ref $a
> returns 'Regexp'. This is used by a lot a Perl modules/scripts.
> When the time comes for the qr// to be freed, the code inside
> sv_clear() tries to call its DESTROY method - since it is an
> object. (sv.c:5261)
> DESTROY doesn't exist in the 'Regexp' stash: if the user defined
> a UNIVERSAL::AUTOLOAD sub, that will be called instead.
> If that AUTOLOAD uses qr//'s, the recursion happens.

Thanks for that explanation.

> I have 2 ideas to fix that:
> 1) Completely drop the 'Regexp' stash trick. Let $a = qr/../ be
> a simple reference. Hack sv_reftype to return "Regexp" if the SV
> its argument points to is a 'r'-magical variable.

You can try this to see what breaks. From what I can see, some
adjustements may be needed in Data::Dumper. However I think this is a
cleaner solution than :

> 2) Put a dummy DESTROY method in the 'Regexp' stash.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About