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

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

Thread Previous | Thread Next
From:
Enache Adrian
Date:
March 2, 2003 00:48
Subject:
Re: odd (or not so odd?) segmentation fault in 5.8.0
Message ID:
20030302084927.GA21571@ratsnest.hole
On Sat, Mar 01, 2003 at 10:09:17PM -0800, Yitzchak Scott-Thoennes wrote:
> On Mon, 17 Feb 2003 22:22:16 +0200, enache@rdslink.ro wrote:
> >Where ( please give me a source reference ) does this happen ?
> >This certainly looks like a bug.
> 
> Which part looks like a bug?  This is just how get/set magic works
> (excluding overloading, which is a horse of a different colour).  The
> fields of the SV are used as kind of a buffer.  The get magic is
> called and the results placed in the SV, from whence they are accessed
> just as if there was no magic.  They can be changed, just as if there
> were no magic, and then the set magic is called, which reads the new
> value from the SV itself.
> 
> I think the source reference you want is the sv_setsv in mg.c's
> S_magic_methpack.  (The scheme I describe is implemented in different
> places for different types of magic.)

Please forget the false noise.
It was just some confusion in my brain :-)

Dave Mitchell has been then ( ~ 2 weeks ago ) so kind to definitely
enlighten me on this matter.

On Mon, Feb 17, 2003 at 08:40:44PM +0000, Dave Mitchell wrote:
> 
> The perl statememt
> 
>     $x = $a
> 
> calls pp_sassign(), which does SvSetMagicSV(dst,src), which is just a
> macro wrapper that does 
> 
>     sv_setsv_flags(dst, src, SV_GMAGIC);
>     if (SvSMAGICAL(dst)) mg_set(dst);
> 
> sv_setsv_flags() itself does roughly the following:
> 
>     if (SvGMAGICAL(src)) {
> 	mg_get(src);
>     SvNVX(dst) = SvNVX(src);
> 
> and mg_get() does
> 
>     save_magic(mgs_ix, sv); /* save the magic and then unset it */
>     foreach (magic)
> 	call the magic handler
> 	which happens to call FETCH, and copy the NV returned from FETCH
> 	into the NVX() slot of $a
> 

Regards
Adi

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