From: Father Chrysostomos Date: Mon, 28 Oct 2013 19:31:22 +0000 (-0700) Subject: Make PL_incgv fully refcounted X-Git-Tag: upstream/5.20.0~1433 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f03015cd13f257d2f93b154f1f908d7d6cc407e0;p=platform%2Fupstream%2Fperl.git Make PL_incgv fully refcounted It was only reference-counted in the main thread: $ ./perl -Ilib -e 'delete $::{INC}; eval q"my $foo : bar"' $ ./perl -Ilib -e 'use threads; async {delete $::{INC}; eval q"my $foo : bar"}->join' Assertion failed: (SvTYPE(_gvgp) == SVt_PVGV || SvTYPE(_gvgp) == SVt_PVLV), function S_apply_attrs_my, file op.c, line 2600. Abort trap: 6 --- diff --git a/perl.c b/perl.c index 8aa6a3f..4c80edb 100644 --- a/perl.c +++ b/perl.c @@ -949,7 +949,6 @@ perl_destruct(pTHXx) PL_initav = NULL; /* shortcuts just get cleared */ - PL_incgv = NULL; PL_hintgv = NULL; PL_errgv = NULL; PL_argvoutgv = NULL; @@ -964,12 +963,14 @@ perl_destruct(pTHXx) PL_debstash = NULL; SvREFCNT_dec(PL_envgv); + SvREFCNT_dec(PL_incgv); SvREFCNT_dec(PL_argvgv); SvREFCNT_dec(PL_replgv); SvREFCNT_dec(PL_DBgv); SvREFCNT_dec(PL_DBline); SvREFCNT_dec(PL_DBsub); PL_envgv = NULL; + PL_incgv = NULL; PL_argvgv = NULL; PL_replgv = NULL; PL_DBgv = NULL; diff --git a/sv.c b/sv.c index 2ced7e3..8ef01c9 100644 --- a/sv.c +++ b/sv.c @@ -13566,7 +13566,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, #endif PL_envgv = gv_dup_inc(proto_perl->Ienvgv, param); - PL_incgv = gv_dup(proto_perl->Iincgv, param); + PL_incgv = gv_dup_inc(proto_perl->Iincgv, param); PL_hintgv = gv_dup_inc(proto_perl->Ihintgv, param); PL_origfilename = SAVEPV(proto_perl->Iorigfilename); PL_diehook = sv_dup_inc(proto_perl->Idiehook, param); diff --git a/t/op/threads.t b/t/op/threads.t index 2a52efc..61889a9 100644 --- a/t/op/threads.t +++ b/t/op/threads.t @@ -9,7 +9,7 @@ BEGIN { skip_all_without_config('useithreads'); skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); - plan(26); + plan(27); } use strict; @@ -391,4 +391,12 @@ EOF is $::hypogamma, 3, 'globs cloned and joined are not recloned'; } +fresh_perl_is( + 'use threads;' . + 'async { delete $::{INC}; eval q"my $foo : bar" } ->join; print "ok\n";', + "ok", + {}, + 'no crash when deleting $::{INC} in thread' +); + # EOF