summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-17 12:08:57 -0500
committerBen Gamari <ben@well-typed.com>2022-03-07 23:27:02 +0000
commite7f548bdcfc46a0894c4fd71ce0c600eaaa147b4 (patch)
treecb2cf9215b7c7240cf51a73b25dacc4995bf5d02
parentb814255e64078ebf91e8b5d2fca2f3891e59aa74 (diff)
downloadhaskell-wip/T20649-8.10.tar.gz
rts: Ensure that markCAFs marks object codewip/T20649-8.10
Previously `markCAFs` would only evacuate CAFs' indirectees. This would allow reachable object code to be unloaded by the linker as `evacuate` may never be called on the CAF itself, despite it being reachable via the `{dyn,revertible}_caf_list`s. To fix this we teach `markCAFs` to explicit call `markObjectCode`, ensuring that the linker is aware of objects reachable via the CAF lists. Fixes #20649. (cherry picked from commit 29e0307185ea98d262e0fca4c5a72503634ebf5b)
-rw-r--r--rts/sm/GCAux.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/rts/sm/GCAux.c b/rts/sm/GCAux.c
index 55b4f99596..9805a76f44 100644
--- a/rts/sm/GCAux.c
+++ b/rts/sm/GCAux.c
@@ -11,6 +11,7 @@
#include "Rts.h"
#include "GC.h"
+#include "CheckUnload.h"
#include "Storage.h"
#include "Compact.h"
#include "Task.h"
@@ -145,20 +146,26 @@ revertCAFs( void )
void
markCAFs (evac_fn evac, void *user)
{
- StgIndStatic *c;
-
- for (c = dyn_caf_list;
+ /* N.B. We must both ensure that the indirectee is
+ * evacuated and that we let the linker know that the CAF
+ * itself is still reachable, lest it be collected (see
+ * #20649).
+ */
+ for (StgIndStatic *c = dyn_caf_list;
((StgWord) c | STATIC_FLAG_LIST) != (StgWord)END_OF_CAF_LIST;
c = (StgIndStatic *)c->static_link)
{
c = (StgIndStatic *)UNTAG_STATIC_LIST_PTR(c);
evac(user, &c->indirectee);
+ markObjectCode(c);
}
- for (c = revertible_caf_list;
+
+ for (StgIndStatic *c = revertible_caf_list;
((StgWord) c | STATIC_FLAG_LIST) != (StgWord)END_OF_CAF_LIST;
c = (StgIndStatic *)c->static_link)
{
c = (StgIndStatic *)UNTAG_STATIC_LIST_PTR(c);
evac(user, &c->indirectee);
+ markObjectCode(c);
}
}