summaryrefslogtreecommitdiff
path: root/rts/RtsStartup.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-03-01 13:50:20 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-25 10:18:54 -0400
commite7c4719d8990a58abd9073731a36922a843ba797 (patch)
treecf286fc7835fd930106ceb2314dc55a985dc31fa /rts/RtsStartup.c
parent9af091f7ced3c76abf86b607d775c0746bfbabd7 (diff)
downloadhaskell-e7c4719d8990a58abd9073731a36922a843ba797.tar.gz
Ensure that wired-in exception closures aren't GC'd
As described in Note [Wired-in exceptions are not CAFfy], a small set of built-in exception closures get special treatment in the code generator, being declared as non-CAFfy despite potentially containing CAF references. The original intent of this treatment for the RTS to then add StablePtrs for each of the closures, ensuring that they are not GC'd. However, this logic was not applied consistently and eventually removed entirely in 951c1fb0. This lead to #21141. Here we fix this bug by reintroducing the StablePtrs and document the status quo. Closes #21141.
Diffstat (limited to 'rts/RtsStartup.c')
-rw-r--r--rts/RtsStartup.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 27002ca81b..491d745668 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -214,6 +214,16 @@ static void initBuiltinGcRoots(void)
#else
getStablePtr((StgPtr)processRemoteCompletion_closure);
#endif
+
+ /*
+ * See Note [Wired-in exceptions are not CAFfy] in GHC.Core.Make.
+ * These are precisely the functions for which we construct `Id`s using
+ * GHC.Core.Make.mkExceptionId.
+ */
+ getStablePtr((StgPtr)absentSumFieldError_closure);
+ getStablePtr((StgPtr)raiseUnderflowException_closure);
+ getStablePtr((StgPtr)raiseOverflowException_closure);
+ getStablePtr((StgPtr)raiseDivZeroException_closure);
}
void