This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Clone lex sub names properly
authorFather Chrysostomos <sprout@cpan.org>
Mon, 15 Sep 2014 00:50:11 +0000 (17:50 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 15 Sep 2014 00:50:11 +0000 (17:50 -0700)
I used share_hek_hek, which is wrong.  HEKs are not shared between
interpreters, so it must be hek_dup.

ext/XS-APItest/t/clone-with-stack.t
sv.c

index 7a0cd29..3f68c93 100644 (file)
@@ -17,7 +17,7 @@ if (not $Config{'useithreads'}) {
     skip_all("clone_with_stack requires threads");
 }
 
-plan(4);
+plan(5);
 
 fresh_perl_is( <<'----', <<'====', undef, "minimal clone_with_stack" );
 use XS::APItest;
@@ -65,3 +65,16 @@ X-Y-0:1:2:3:4-Z
 ====
 
 }
+
+{
+    fresh_perl_is( <<'----', <<'====', undef, "with a lexical sub" );
+use XS::APItest;
+use experimental lexical_subs=>;
+my sub f { print "42\n" }
+clone_with_stack();
+f();
+----
+42
+====
+
+}
diff --git a/sv.c b/sv.c
index 556c68d..c8ff66a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13403,7 +13403,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param)
                if (CvDYNFILE(dstr)) CvFILE(dstr) = SAVEPV(CvFILE(dstr));
                if (CvNAMED(dstr))
                    SvANY((CV *)dstr)->xcv_gv_u.xcv_hek =
-                       share_hek_hek(CvNAME_HEK((CV *)sstr));
+                       hek_dup(CvNAME_HEK((CV *)sstr), param);
                /* don't dup if copying back - CvGV isn't refcounted, so the
                 * duped GV may never be freed. A bit of a hack! DAPM */
                else