This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix assertion failure with undef &my_sub/&anon
[perl5.git] / t / op / anonsub.t
index ceb8d09..d65acfe 100644 (file)
@@ -98,3 +98,16 @@ print __ANON__;
 sub(){3};
 EXPECT
 42
+########
+# NAME undef &anon giving it a freed GV
+$_ = sub{};
+delete $::{__ANON__};
+undef &$_; # SvREFCNT_dec + inc on a GV with a refcnt of 1
+           # so now SvTYPE(CvGV(anon)) is 0xff == freed
+if (!eval { require B }) { # miniperl, presumably
+    print "__ANON__\n";
+} else {
+    print B::svref_2object($_)->GV->NAME, "\n";
+}
+EXPECT
+__ANON__