diff options
author | Takano Akio <aljee@hyper.cx> | 2013-09-06 19:55:37 +0900 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2013-09-08 03:55:06 -0500 |
commit | 41296315f7b1e0eccfa6c94c49f1cdd977f741fb (patch) | |
tree | e7f8e1cb080277815ed9737b76d956ce9ae07973 | |
parent | d85044f6b201eae0a9e453b89c0433608e0778f0 (diff) | |
download | haskell-41296315f7b1e0eccfa6c94c49f1cdd977f741fb.tar.gz |
Avoid allocating while holding a lock (#8242)
This reverts commit 6770663f764db76dbb7138ccb3aea0527d194151.
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: Austin Seipp <aseipp@pobox.com>
-rw-r--r-- | rts/PrimOps.cmm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm index 08e7af08a1..dbced84083 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -460,14 +460,6 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer { W_ c, info; - LOCK_CLOSURE(w, info); - - if (info == stg_DEAD_WEAK_info) { - // Already dead. - unlockClosure(w, info); - return (0); - } - ALLOC_PRIM (SIZEOF_StgCFinalizerList) c = Hp - SIZEOF_StgCFinalizerList + WDS(1); @@ -478,6 +470,14 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer StgCFinalizerList_eptr(c) = eptr; 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); StgWeak_cfinalizers(w) = c; |