summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2009-05-28 13:33:57 +0000
committerSimon Marlow <marlowsd@gmail.com>2009-05-28 13:33:57 +0000
commit32ca5da8e5f380a777edf2dacc734c4b67d41f20 (patch)
treefd238a2c25e075ed7c2ecc944b743623ec7e7e82
parentc34d7dd7c5d01910e5a73b1da3a72ad1a20fa692 (diff)
downloadhaskell-32ca5da8e5f380a777edf2dacc734c4b67d41f20.tar.gz
Fix #3156: ensure preconditions of splitLargeBlock()
-rw-r--r--rts/Schedule.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 0b4c5b6284..f376286a80 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2436,9 +2436,16 @@ threadStackUnderflow (Task *task STG_UNUSED, StgTSO *tso)
tso_size_w = tso_sizeW(tso);
- if (tso_size_w < MBLOCK_SIZE_W ||
+ if (tso_size_w < MBLOCK_SIZE_W ||
+ // TSO is less than 2 mblocks (since the first mblock is
+ // shorter than MBLOCK_SIZE_W)
+ (tso_size_w - BLOCKS_PER_MBLOCK*BLOCK_SIZE_W) % MBLOCK_SIZE_W != 0 ||
+ // or TSO is not a whole number of megablocks (ensuring
+ // precondition of splitLargeBlock() below)
(nat)(tso->stack + tso->stack_size - tso->sp) > tso->stack_size / 4)
+ // or stack is using more than 1/4 of the available space
{
+ // then do nothing
return tso;
}