[perl #31851] Threading crash with closures
[p5sagit/p5-mst-13.2.git] / pad.c
diff --git a/pad.c b/pad.c
index 0b0491c..0c00cff 100644 (file)
--- a/pad.c
+++ b/pad.c
 /*
 =head1 Pad Data Structures
 
+This file contains the functions that create and manipulate scratchpads,
+which are array-of-array data structures attached to a CV (ie a sub)
+and which store lexical variables and opcode temporary and per-thread
+values.
+
 =for apidoc m|AV *|CvPADLIST|CV *cv
 CV's can have CvPADLIST(cv) set to point to an AV.
 
@@ -588,7 +593,7 @@ Perl_pad_findmy(pTHX_ char *name)
  */
 
 PADOFFSET
-Perl_find_rundefsvoffset()
+Perl_find_rundefsvoffset(pTHX)
 {
     SV *out_sv;
     int out_flags;
@@ -1405,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);