summaryrefslogtreecommitdiff
path: root/utils
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-29 13:06:20 -0400
commit5630dde68185f96da026a4e0c722fe6631633299 (patch)
tree973de628f322377ce523fcfb09a2ae25bd74f295 /utils
parent724d0dc04645b21865bcd1877b7cc77e9a3fe9b2 (diff)
downloadhaskell-5630dde68185f96da026a4e0c722fe6631633299.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 'utils')
-rw-r--r--utils/deriveConstants/Main.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/utils/deriveConstants/Main.hs b/utils/deriveConstants/Main.hs
index 9a57ecf682..ca17b061e4 100644
--- a/utils/deriveConstants/Main.hs
+++ b/utils/deriveConstants/Main.hs
@@ -418,9 +418,11 @@ wanteds os = concat
,structField Both "StgEntCounter" "link"
,structField Both "StgEntCounter" "entry_count"
- ,closureSize Both "StgUpdateFrame"
- ,closureSize C "StgCatchFrame"
- ,closureSize C "StgStopFrame"
+ ,closureSize Both "StgUpdateFrame"
+ ,closureSize C "StgCatchFrame"
+ ,closureSize C "StgStopFrame"
+ ,closureSize C "StgDeadThreadFrame"
+ ,closureField C "StgDeadThreadFrame" "result"
,closureSize Both "StgMutArrPtrs"
,closureField Both "StgMutArrPtrs" "ptrs"