Skip to content

maxStkSize can overflow

The maxStkSize field of GC_FLAGS is a nat, or unsigned int. It's measured in words, but still 32G is not an unreasonable amount of memory by today's standards.

Maybe it's unlikely that anyone would want to set the stack size limit to more than 32G. But if you happen to have just over 40G of physical memory then the default stack size limit will overflow to a value just above zero and then Bad Things would happen.

If we want to actually enforce stack limits that are greater than 2^32^ words, we would need to increase the size of the tot_stack_size field of a TSO also.

Simple test of overflow behavior: ghci +RTS -K32.0001G will exit with a stack overflow.

Trac metadata
Trac field Value
Version 7.8.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC simonmar
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information