This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #31851] Threading crash with closures
[perl5.git] / pad.c
diff --git a/pad.c b/pad.c
index f1d15ab..0c00cff 100644 (file)
--- a/pad.c
+++ b/pad.c
@@ -1410,7 +1410,9 @@ Perl_cv_clone(pTHX_ CV *proto)
 #endif
     CvGV(cv)           = CvGV(proto);
     CvSTASH(cv)                = CvSTASH(proto);
+    OP_REFCNT_LOCK;
     CvROOT(cv)         = OpREFCNT_inc(CvROOT(proto));
+    OP_REFCNT_UNLOCK;
     CvSTART(cv)                = CvSTART(proto);
     CvOUTSIDE(cv)      = (CV*)SvREFCNT_inc(outside);
     CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto);