On Thu, 13 Feb 2003 00:38:59 -0500, mark@mark.mielke.cc wrote: >I haven't seen this reported yet. I'll try to track it down tomorrow, >but in case anybody in the know can point out the problem immediately: > >$ perl -e 'sub TIESCALAR {bless[]} sub FETCH {*a=\1;1} >> tie($a,__PACKAGE__); print $a' >zsh: segmentation fault perl -e > >Of course, this is an odd thing to do, and therefore, I'm not >surprised that there are no regression tests to catch this. My goal >was to use a tie() to provide demand loading of an object. The first >time through, access is through a tie() that initializes the object, >removes the tie, and returns the object. The second time through, and >later, the object itself is referenced, and the tie() is gone. You may be able to get the behaviour you want by returning from FETCH an object (with no other references to it) with a DESTROY method that unties and sets your tied variable. The segfault is in mg_get. Looks to me like after returning from FETCH, we have an sv that's already been freed. The code calls SvMAGIC to see if the get func we just called added new magic at the head of the list, and that seems to return a garbage pointer (though I don't see the segfault until it loops and looks up mg->mg_virtual for the "newly added" magic). You may be able to get things working just by having a $dummy=\$a out there so as not to acually free the original sv.Thread Previous | Thread Next