develooper Front page | perl.perl5.porters | Postings from October 2000

Re: Did change 1307 (GSAR) break self ties?

Thread Previous | Thread Next
Gurusamy Sarathy
October 2, 2000 08:42
Re: Did change 1307 (GSAR) break self ties?
Message ID:
On Sun, 01 Oct 2000 16:58:04 BST, Alan Burlison wrote:
>I think I've managed to track down where self-ties are broken.  It is in
>pp_hot.c in pp_aelem, 4 lines from the bottom of the function:
>    if (!lval && SvGMAGICAL(sv))        /* see note in pp_helem() */
>        sv = sv_mortalcopy(sv);
>This was added I believe as part of change 1307, to get local to work on
>tied hashes.  However, in the case of self-ties it doesn't work, as the
>call to sv_mortalcopy then calls mg_get, which then recurses into
>pp_aelem with inevitable consequences.  I've tried temporarily removing
>the call to sv_mortalcopy, but that still doesn't fix the problem,
>although I'm not quite sure why.  I'm assuming the correct fix is to
>disable magic for the tied array for the duration of the call to
>sv_mortalcopy, but the save_magic and restore_magic functions are local
>to mg.c.  I'm a bit wary of promoting them to be global, as they should
>probably be renamed (mg_save/mg_restore?) which involves changing
>I'd like some help and advice from someone please - Gurusamay, as your
>name is against the changes in this area (761, 802 and 1307) could you
>advise?  I know it is a long time ago, but you probably have a far
>better idea than I do of the correct fix.

I doubt that change#1307 is the problem--we call sv_mortalcopy() in
lots of other situations.

IIRC, Chip did the work to support self-ties (prompted by Joshua's
reports, maybe).  I remember thinking at the time that the patch that
we added might not really support self-referential ties in general
(as opposed a variable tied to itself, in particular).  I'm not sure
about the details now, but it may have been something to do with
scenarios like A-tiedto-B-tiedto-C-tiedto...tiedto-A not working.

Whittling it down to a small test case may prove educational.


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