From: Nicholas Clark Date: Wed, 22 Feb 2006 00:23:49 +0000 (+0000) Subject: Change 24643 made the mistake of assuming that CvCONST can only be true X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cfae286ee950aa5c0910601410971733f656001f;p=p5sagit%2Fp5-mst-13.2.git Change 24643 made the mistake of assuming that CvCONST can only be true on XSUBs. Somehow it can also end up on perl subs. Bug spotted by and test case from Marcus Holland-Moritz. p4raw-id: //depot/perl@27267 --- diff --git a/sv.c b/sv.c index 44defbe..21a2d13 100644 --- a/sv.c +++ b/sv.c @@ -9833,7 +9833,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) if (!CvISXSUB(dstr)) CvROOT(dstr) = OpREFCNT_inc(CvROOT(dstr)); OP_REFCNT_UNLOCK; - if (CvCONST(dstr)) { + if (CvCONST(dstr) && CvISXSUB(dstr)) { CvXSUBANY(dstr).any_ptr = GvUNIQUE(CvGV(dstr)) ? SvREFCNT_inc(CvXSUBANY(dstr).any_ptr) : sv_dup_inc((SV *)CvXSUBANY(dstr).any_ptr, param); diff --git a/t/op/threads.t b/t/op/threads.t index 7fecba1..f699fc2 100644 --- a/t/op/threads.t +++ b/t/op/threads.t @@ -18,7 +18,7 @@ BEGIN { print "1..0 # Skip: no dynamic loading on miniperl, no threads\n"; exit 0; } - plan(4); + plan(5); } use threads; @@ -96,3 +96,13 @@ sub do_sort_threads { do_sort_threads(2); # crashes ok(1); + +# Change 24643 made the mistake of assuming that CvCONST can only be true on +# XSUBs. Somehow it can also end up on perl subs. +fresh_perl_is(<<'EOI', 'ok', { }, 'cloning constant subs'); +use constant x=>1; +use threads; +$SIG{__WARN__} = sub{}; +async sub {}; +print "ok"; +EOI