When we copy things out of a hash and increment the
Artur Bergman [Sun, 26 Jan 2003 22:37:21 +0000 (22:37 +0000)]
refcount of the shared scalar, we really must protect
that refcount increase with a lock, or else it might not
happen. Fixes segfault when objects would prematurely
be killed.

p4raw-id: //depot/perl@18593

ext/threads/shared/shared.xs

index c5a210f..a3f27e7 100644 (file)
@@ -672,7 +672,9 @@ sharedsv_array_mg_copy(pTHX_ SV *sv, MAGIC* mg,
     MAGIC *nmg = sv_magicext(nsv,mg->mg_obj,
                            toLOWER(mg->mg_type),&sharedsv_elem_vtbl,
                            name, namlen);
+    ENTER_LOCK;
     SvREFCNT_inc(SHAREDSvPTR(shared));
+    LEAVE_LOCK;
     nmg->mg_flags |= MGf_DUP;
     return 1;
 }