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.
Showing
- rts/Schedule.c 3 additions, 1 deletionrts/Schedule.c
- rts/StgMiscClosures.cmm 10 additions, 0 deletionsrts/StgMiscClosures.cmm
- rts/StgStartup.cmm 8 additions, 8 deletionsrts/StgStartup.cmm
- rts/include/rts/storage/Closures.h 7 additions, 0 deletionsrts/include/rts/storage/Closures.h
- rts/include/stg/MiscClosures.h 1 addition, 0 deletionsrts/include/stg/MiscClosures.h
- utils/deriveConstants/Main.hs 1 addition, 0 deletionsutils/deriveConstants/Main.hs
Loading
Please register or sign in to comment