Commit 6770663f authored by ian@well-typed.com's avatar ian@well-typed.com

Check for a weak pointer being dead before we do any allocation for it

parent d61c623e
......@@ -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;
......
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