Commit 41296315 authored by aljee@hyper.cx's avatar aljee@hyper.cx Committed by thoughtpolice

Avoid allocating while holding a lock (#8242)

This reverts commit 6770663f.

If the program enters the garbage collector with the closure
lock held, it will confuse the garbage collector and will
result in an infinite loop in evacuate().
Signed-off-by: thoughtpolice's avatarAustin Seipp <aseipp@pobox.com>
parent d85044f6
...@@ -460,14 +460,6 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer ...@@ -460,14 +460,6 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer
{ {
W_ c, info; W_ c, info;
LOCK_CLOSURE(w, info);
if (info == stg_DEAD_WEAK_info) {
// Already dead.
unlockClosure(w, info);
return (0);
}
ALLOC_PRIM (SIZEOF_StgCFinalizerList) ALLOC_PRIM (SIZEOF_StgCFinalizerList)
c = Hp - SIZEOF_StgCFinalizerList + WDS(1); c = Hp - SIZEOF_StgCFinalizerList + WDS(1);
...@@ -478,6 +470,14 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer ...@@ -478,6 +470,14 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer
StgCFinalizerList_eptr(c) = eptr; StgCFinalizerList_eptr(c) = eptr;
StgCFinalizerList_flag(c) = flag; StgCFinalizerList_flag(c) = flag;
LOCK_CLOSURE(w, info);
if (info == stg_DEAD_WEAK_info) {
// Already dead.
unlockClosure(w, info);
return (0);
}
StgCFinalizerList_link(c) = StgWeak_cfinalizers(w); StgCFinalizerList_link(c) = StgWeak_cfinalizers(w);
StgWeak_cfinalizers(w) = c; StgWeak_cfinalizers(w) = c;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment