threadStackOverflow: check whether stack squeezing released some stack (#3677)
authorSimon Marlow <marlowsd@gmail.com>
Wed, 25 Nov 2009 12:59:17 +0000 (12:59 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Wed, 25 Nov 2009 12:59:17 +0000 (12:59 +0000)
commitd2c874dc74e2d99eda70d83e9b540f54c45c2154
tree0a5db339727ea1557e7cc1205cda0cc1d327c7f8
parent69ba3e6bbae81ce02f6ea66d0686667b7dfb7e8f
threadStackOverflow: check whether stack squeezing released some stack (#3677)

In a stack overflow situation, stack squeezing may reduce the stack
size, but we don't know whether it has been reduced enough for the
stack check to succeed if we try again.  Fortunately stack squeezing
is idempotent, so all we need to do is record whether *any* squeezing
happened.  If we are at the stack's absolute -K limit, and stack
squeezing happened, then we try running the thread again.

We also want to avoid enlarging the stack if squeezing has already
released some of it.  However, we don't want to get into a
pathalogical situation where a thread has a nearly full stack (near
its current limit, but not near the absolute -K limit), keeps
allocating a little bit, squeezing removes a little bit, and then it
runs again.  So to avoid this, if we squeezed *and* there is still
less than BLOCK_SIZE_W words free, then we enlarge the stack anyway.
includes/rts/Constants.h
rts/Schedule.c
rts/ThreadPaused.c