develooper Front page | perl.perl5.porters | Postings from May 2002

[PATCH] Re: perl@16433

Thread Previous | Thread Next
From:
sthoenna
Date:
May 7, 2002 19:06
Subject:
[PATCH] Re: perl@16433
Message ID:
cII28gzkgaOS092yn@efn.org
In article <20020507061915.Z31692@alpha.hut.fi>,
Jarkko Hietaniemi <jhi@iki.fi> wrote:
>On Mon, May 06, 2002 at 08:01:10PM -0700, Yitzchak Scott-Thoennes wrote:
>> In article <20020506175038.P31692@alpha.hut.fi>,
>> Jarkko Hietaniemi <jhi@iki.fi> wrote:
>> >- IO::Scalar 'inner references' problem [Yitzchak?]
>> 
>> This isn't an IO::Scalar problem, it's a self-tie problem.  Haven't
>
>Ooops, sorry, forgot to update the detail.
>
>> had a lot of time to look at it, perhaps someone who knows something
>> about self-ties could take a look?  The change to the sv_magic call in
>
>Not me, sorry.  All I did back then (AFAICR) was to put in
>a stopgap for disabling self-ties until we figure out a solution--
>maybe I shouldn't have, since then we seemingly forgot about it.
>The simplest change would be to back out the stopgap changes, I think.

That doesn't help.  That was only one of the two things breaking self-tied
globs.

>
>> broke self-tied globs (and I think scalars) one way; the change to tie
>> the pvio not the pvgv broke self-tied globs another way.  I think the
>> fix will lie in adding additional non-refcounted cases to sv_magicext
>> but am not sure that will work right for globs.  And I haven't yet
>> found the code that handled mg_obj for self-tied objects being Nullsv.

Here's a fix (minimally tested...full build and tests are still running):

--- sv.c.orig	Mon May  6 11:50:00 2002
+++ sv.c	Tue May  7 17:52:12 2002
@@ -4466,7 +4466,9 @@ Perl_sv_magicext(pTHX_ SV* sv, SV* obj, 
 	(SvTYPE(obj) == SVt_PVGV &&
 	    (GvSV(obj) == sv || GvHV(obj) == (HV*)sv || GvAV(obj) == (AV*)sv ||
 	    GvCV(obj) == (CV*)sv || GvIOp(obj) == (IO*)sv ||
-	    GvFORM(obj) == (CV*)sv)))
+	    GvFORM(obj) == (CV*)sv)) ||
+	(how == PERL_MAGIC_tiedscalar &&
+	    SvROK(obj) && (SvRV(obj) == sv || GvIO(SvRV(obj)) == (IO*)sv)))
     {
 	mg->mg_obj = obj;
     }
End of Patch.

This does worry me a little.  If someone does something like:

sub pkg::TIEHANDLE {bless $_[1]}
{
   my $self=Symbol::gensym;
   tie *$self, 'pkg', $self;
   *FOO = *$self{IO};
)

I think this leaves *FOO (really *FOO{IO}) tied to a freed object.
But I can't see any way around this.

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