diff options
author | GHC GitLab CI <ghc-ci@gitlab-haskell.org> | 2020-11-25 23:03:58 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-11-30 19:21:56 -0500 |
commit | f72f27a325c16bf2975ee2a8a49c439b46ee8498 (patch) | |
tree | 0fe720eedcba7510f2925f27cc0a9f1b638a13da | |
parent | cae06fc404b8be27bf0bab2b51e4343b23b896e9 (diff) | |
download | haskell-f72f27a325c16bf2975ee2a8a49c439b46ee8498.tar.gz |
ThreadPaused: Don't zero slop until free vars are pushed
When threadPaused blackholes a thunk it calls `OVERWRITING_CLOSURE` to
zero the slop for the benefit of the sanity checker. Previously this was
done *before* pushing the thunk's free variables to the update
remembered set. Consequently we would pull zero'd pointers to the update
remembered set.
(cherry picked from commit 3e75b0dbaca5fbd8abc529d70c1df159f5bfbaa4)
-rw-r--r-- | includes/rts/storage/ClosureMacros.h | 4 | ||||
-rw-r--r-- | rts/ThreadPaused.c | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/includes/rts/storage/ClosureMacros.h b/includes/rts/storage/ClosureMacros.h index 5674322bd2..b841ef8be0 100644 --- a/includes/rts/storage/ClosureMacros.h +++ b/includes/rts/storage/ClosureMacros.h @@ -520,11 +520,15 @@ INLINE_HEADER StgWord8 *mutArrPtrsCard (StgMutArrPtrs *a, W_ n) #if defined(PROFILING) || defined(DEBUG) #define OVERWRITING_CLOSURE(c) \ overwritingClosure(c) +#define OVERWRITING_CLOSURE_SIZE(c, size) \ + overwritingClosureSize(c, size) #define OVERWRITING_CLOSURE_MUTABLE(c, off) \ overwritingMutableClosureOfs(c, off) #else #define OVERWRITING_CLOSURE(c) \ do { (void) sizeof(c); } while(0) +#define OVERWRITING_CLOSURE_SIZE(c, size) \ + do { (void) sizeof(c); (void) sizeof(size); } while(0) #define OVERWRITING_CLOSURE_MUTABLE(c, off) \ do { (void) sizeof(c); (void) sizeof(off); } while(0) #endif diff --git a/rts/ThreadPaused.c b/rts/ThreadPaused.c index 13fc2b4ca0..9f41fa1ab3 100644 --- a/rts/ThreadPaused.c +++ b/rts/ThreadPaused.c @@ -314,10 +314,6 @@ threadPaused(Capability *cap, StgTSO *tso) continue; } - // zero out the slop so that the sanity checker can tell - // where the next closure is. - OVERWRITING_CLOSURE(bh); - // an EAGER_BLACKHOLE or CAF_BLACKHOLE gets turned into a // BLACKHOLE here. #if defined(THREADED_RTS) @@ -345,11 +341,16 @@ threadPaused(Capability *cap, StgTSO *tso) // overwrite to the update remembered set. // N.B. We caught the WHITEHOLE case above. updateRemembSetPushThunkEager(cap, - THUNK_INFO_PTR_TO_STRUCT(bh_info), - (StgThunk *) bh); + THUNK_INFO_PTR_TO_STRUCT(bh_info), + (StgThunk *) bh); } } + // zero out the slop so that the sanity checker can tell + // where the next closure is. N.B. We mustn't do this until we have + // pushed the free variables to the update remembered set above. + OVERWRITING_CLOSURE_SIZE(bh, closure_sizeW_(bh, INFO_PTR_TO_STRUCT(bh_info))); + // The payload of the BLACKHOLE points to the TSO RELAXED_STORE(&((StgInd *)bh)->indirectee, (StgClosure *)tso); SET_INFO_RELEASE(bh,&stg_BLACKHOLE_info); |