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

Re: odd (or not so odd?) segmentation fault in 5.8.0

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
February 17, 2003 03:19
Subject:
Re: odd (or not so odd?) segmentation fault in 5.8.0
Message ID:
20030217111556.A13561@fdgroup.com
On Mon, Feb 17, 2003 at 02:14:59AM +0200, Enache Adrian wrote:
> I expected from it to:
> 
> 1. print '(1) (1) (1)' ... 
> 2. go in some crazy loop.


Before proceeding, mg_get() saves, then turns off, any magic associated
with the SV  - I guess to avoid recursive crazy loops like you mention.

This is why 'untie $a', and '$a' have no magical effect within
FETCH().

The cause of the original coredump was that *a = \1 was immediately
freeing the tied scalar, since things pushed onto the stack aren't
refcounted. You can (almost) achieve similar effects with code like

    $a = 1; f($a);
    sub f { *a = \1; do_something_with($_[0]) }

except that av_fetch() has explicit code it in such that when it
tries to retrieve element n from @_, it checks that its a freed scalar,
and if so, returns undef instead. This is pure hackery since sometimes the
sv may have since been reassigned.

-- 
But Pity stayed his hand. "It's a pity I've run out of bullets",
he thought. - "Bored of the Rings"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About