develooper Front page | perl.perl5.porters | Postings from August 2001

[patch] ithreads + refto bug

From:
Doug MacEachern
Date:
August 1, 2001 09:46
Subject:
[patch] ithreads + refto bug
Message ID:
Pine.LNX.4.21.0108010937240.7498-100000@mako.covalent.net
strange bug, happens in both 5.6.x and bleedperl, the following script:

package Foo;

use strict;

sub TIEHANDLE { bless {} }

my $cnt = 'a';

sub READ {
    $_[1] = $cnt++;
    1;
}

sub do_read {
    my $fh = shift;

    read $fh, my $buff, 1;
    print "->$buff<-\n";
}

$|=1;

tie *STDIN, 'Foo';

read STDIN, my $buff, 1;
print "=>$buff<=\n";

do_read(\*STDIN);

untie *STDIN;

prints:
=>a<=

then in the call to do_read(\*STDIN), $fh is no longer tied.
with vanilla (non-ithreads) Perl, it prints the expected:
=>a<=
->b<-

the bug seems to be S_refto (called by pp_srefgen), which the patch below
fixes, all tests pass.

Index: pp.c
===================================================================
RCS file: /usr/local/cvs_repository/perl-current-mirror/pp.c,v
retrieving revision 1.1.1.33
diff -u -r1.1.1.33 pp.c
--- pp.c	2001/07/31 15:56:35	1.1.1.33
+++ pp.c	2001/08/01 16:37:16
@@ -467,7 +467,7 @@
 	SvTEMP_off(sv);
 	(void)SvREFCNT_inc(sv);
     }
-    else if (SvPADTMP(sv))
+    else if (SvPADTMP(sv) && !(isGV(sv) && GvIN_PAD(sv)))
 	sv = newSVsv(sv);
     else {
 	SvTEMP_off(sv);




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About