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
Enache Adrian
February 17, 2003 12:22
Re: odd (or not so odd?) segmentation fault in 5.8.0
Message ID:
On Mon, Feb 17, 2003 at 07:23:58PM +0000, Dave Mitchell wrote:
> What happens is as follows:
>     sub P::FETCH { $a+1 }
>     $a = 1;
>     tie $a, P;
>     $x = $a;
> is executed as follows:
> 1) the plain SV associated with $a gets the value 1
> 2) The $a gets magic attached to it
> 3) an attempt is made to get the value of $a
>   3a) $a's magic is temporarily disabled, then FETCH is called
>   3b) FETCH accesses the current value of (plain) $a, which is 1, and
>       returns that plus 1
>   3c) the returned value from FETCH is assigned to $a's SV, ie SvNVX($a) = 2

Where ( please give me a source reference ) does this happen ?
This certainly looks like a bug.

> Whether this is the correct or best possible behaviour is another matter -
> personally I think it is reasonable given the complexities of tie.

No. That isn't reasonable.
    print $a, $a, $a, $a
should get the same value for each $a.
(note that FETCH doesn't modify in any way the value of the $a scalar -
neither the magic nor the regular).


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