Fix calculation in threadStackOverflow
authorSimon Marlow <marlowsd@gmail.com>
Sat, 30 Sep 2017 18:11:07 +0000 (13:11 -0500)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 16 Oct 2017 08:23:46 +0000 (09:23 +0100)
Summary:
The calculation was too conservative, and could result in copying zero
frames into the new stack chunk, which caused a knock-on failure in
the interpreter.

Test Plan: Tested on an in-house repro (not shareable, unfortunately)

Reviewers: niteria, bgamari, austin, erikd

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D4052

rts/Threads.c

index 836cdd6..79c86f7 100644 (file)
@@ -640,8 +640,8 @@ threadStackOverflow (Capability *cap, StgTSO *tso)
             // if including this frame would exceed the size of the
             // new stack (taking into account the underflow frame),
             // then stop at the previous frame.
-            if (sp + size > old_stack->stack + (new_stack->stack_size -
-                                                sizeofW(StgUnderflowFrame))) {
+            if (sp + size > old_stack->sp + (new_stack->stack_size -
+                                             sizeofW(StgUnderflowFrame))) {
                 break;
             }
             sp += size;