summaryrefslogtreecommitdiff
path: root/rts/include/stg/MiscClosures.h
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-04-04 21:43:27 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-25 10:20:05 -0400
commite09afbf2a998beea7783e3de5dce5dd3c6ff23db (patch)
tree126afde30070ef8a13cee9a558eb1f5192b5c1ea /rts/include/stg/MiscClosures.h
parent41cf758b3f50554e0aa5240a5898b693758d9670 (diff)
downloadhaskell-e09afbf2a998beea7783e3de5dce5dd3c6ff23db.tar.gz
rts: Refactor handling of dead threads' stacks
This fixes a bug that @JunmingZhao42 and I noticed while working on her MMTK port. Specifically, in stg_stop_thread we used stg_enter_info as a sentinel at the tail of a stack after a thread has completed. However, stg_enter_info expects to have a two-field payload, which we do not push. Consequently, if the GC ends up somehow the stack it will attempt to interpret data past the end of the stack as the frame's fields, resulting in unsound behavior. To fix this I eliminate this hacky use of `stg_stop_thread` and instead introduce a new stack frame type, `stg_dead_thread_info`. Not only does this eliminate the potential for the previously mentioned memory unsoundness but it also more clearly captures the intended structure of the dead threads' stacks.
Diffstat (limited to 'rts/include/stg/MiscClosures.h')
-rw-r--r--rts/include/stg/MiscClosures.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/rts/include/stg/MiscClosures.h b/rts/include/stg/MiscClosures.h
index e87eba0931..b5efd9636b 100644
--- a/rts/include/stg/MiscClosures.h
+++ b/rts/include/stg/MiscClosures.h
@@ -159,6 +159,7 @@ RTS_RET(stg_ctoi_t61);
RTS_RET(stg_ctoi_t62);
RTS_RET(stg_apply_interp);
+RTS_RET(stg_dead_thread);
RTS_ENTRY(stg_IND);
RTS_ENTRY(stg_IND_STATIC);