diff options
author | Alexis King <lexi.lambda@gmail.com> | 2022-09-26 17:17:32 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-10-01 00:37:43 -0400 |
commit | 95ead839fd39e0aa781dca9b1268b243c29ccaeb (patch) | |
tree | 268170724781267f0ac9bff800f4947d0fc896c1 /rts/Continuation.c | |
parent | 4baf7b1ceaef2d4f49e81e5786a855e22ed864bf (diff) | |
download | haskell-95ead839fd39e0aa781dca9b1268b243c29ccaeb.tar.gz |
Fix a bug in continuation capture across multiple stack chunks
Diffstat (limited to 'rts/Continuation.c')
-rw-r--r-- | rts/Continuation.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/rts/Continuation.c b/rts/Continuation.c index 09be4d368e..fbc279574f 100644 --- a/rts/Continuation.c +++ b/rts/Continuation.c @@ -472,12 +472,14 @@ StgClosure *captureContinuationAndAbort(Capability *cap, StgTSO *tso, StgPromptT stack = pop_stack_chunk(cap, tso); for (StgWord i = 0; i < full_chunks; i++) { - memcpy(cont_stack, stack->sp, stack->stack_size * sizeof(StgWord)); - cont_stack += stack->stack_size; + const size_t chunk_words = stack->stack + stack->stack_size - stack->sp - sizeofW(StgUnderflowFrame); + memcpy(cont_stack, stack->sp, chunk_words * sizeof(StgWord)); + cont_stack += chunk_words; stack = pop_stack_chunk(cap, tso); } memcpy(cont_stack, stack->sp, last_chunk_words * sizeof(StgWord)); + cont_stack += last_chunk_words; stack->sp += last_chunk_words; } |