This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix $/ init for multiple interpreters/threads
authorGurusamy Sarathy <gsar@cpan.org>
Sat, 18 Jul 1998 01:17:28 +0000 (01:17 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sat, 18 Jul 1998 01:17:28 +0000 (01:17 +0000)
p4raw-id: //depot/perl@1523

ext/Thread/Thread.xs
perl.c
util.c

index be1e7af..5d47cd0 100644 (file)
@@ -158,6 +158,8 @@ threadstart(void *arg)
     Safefree(tmps_stack);
     Safefree(ofs);
 
+    SvREFCNT_dec(rs);
+    SvREFCNT_dec(nrs);
     SvREFCNT_dec(statname);
     Safefree(screamfirst);
     Safefree(screamnext);
diff --git a/perl.c b/perl.c
index 9e29975..fe1df90 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -164,9 +164,6 @@ perl_construct(register PerlInterpreter *sv_interp)
            SvREFCNT(&sv_yes) = (~(U32)0)/2;
        }
 
-       nrs = newSVpv("\n", 1);
-       rs = SvREFCNT_inc(nrs);
-
 #ifdef PERL_OBJECT
        /* TODO: */
        /* sighandlerp = sighandler; */
@@ -186,6 +183,9 @@ perl_construct(register PerlInterpreter *sv_interp)
 #endif
     }
 
+    nrs = newSVpv("\n", 1);
+    rs = SvREFCNT_inc(nrs);
+
     init_stacks(ARGS);
 #ifdef MULTIPLICITY
     init_interp();
@@ -428,7 +428,10 @@ perl_destruct(register PerlInterpreter *sv_interp)
     Safefree(ors);     /* $\ */
     ors = Nullch;
 
-    SvREFCNT_dec(nrs); /* $\ helper */
+    SvREFCNT_dec(rs);  /* $/ */
+    rs = Nullsv;
+
+    SvREFCNT_dec(nrs); /* $/ helper */
     nrs = Nullsv;
 
     multiline = 0;     /* $* */
diff --git a/util.c b/util.c
index 6f4bb6e..eb52ee5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2783,7 +2783,7 @@ new_struct_thread(struct perl_thread *t)
     tainted = t->Ttainted;
     curpm = t->Tcurpm;         /* XXX No PMOP ref count */
     nrs = newSVsv(t->Tnrs);
-    rs = newSVsv(t->Trs);
+    rs = SvREFCNT_inc(nrs);
     last_in_gv = (GV*)SvREFCNT_inc(t->Tlast_in_gv);
     ofslen = t->Tofslen;
     ofs = savepvn(t->Tofs, ofslen);