diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-06-15 16:36:29 +0100 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-06-15 16:36:29 +0100 |
commit | 6770663f764db76dbb7138ccb3aea0527d194151 (patch) | |
tree | 52e6d4f828f4bb379b365541f14de8b5871832cc /rts/PrimOps.cmm | |
parent | d61c623ed6b2d352474a7497a65015dbf6a72e12 (diff) | |
download | haskell-6770663f764db76dbb7138ccb3aea0527d194151.tar.gz |
Check for a weak pointer being dead before we do any allocation for it
Diffstat (limited to 'rts/PrimOps.cmm')
-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 8d2bc2f0a9..b44dfe7f5c 100644 --- a/rts/PrimOps.cmm +++ b/rts/PrimOps.cmm @@ -404,6 +404,14 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer { W_ c, info; + ("ptr" info) = ccall lockClosure(w "ptr"); + + if (info == stg_DEAD_WEAK_info) { + // Already dead. + unlockClosure(w, info); + return (0); + } + ALLOC_PRIM (SIZEOF_StgCFinalizerList) c = Hp - SIZEOF_StgCFinalizerList + WDS(1); @@ -414,14 +422,6 @@ stg_addCFinalizzerToWeakzh ( W_ fptr, // finalizer StgCFinalizerList_eptr(c) = eptr; StgCFinalizerList_flag(c) = flag; - ("ptr" info) = ccall lockClosure(w "ptr"); - - if (info == stg_DEAD_WEAK_info) { - // Already dead. - unlockClosure(w, info); - return (0); - } - StgCFinalizerList_link(c) = StgWeak_cfinalizers(w); StgWeak_cfinalizers(w) = c; |