diff options
author | Austin Seipp <aseipp@pobox.com> | 2013-09-08 02:08:45 -0500 |
---|---|---|
committer | Austin Seipp <aseipp@pobox.com> | 2013-09-08 03:55:06 -0500 |
commit | d85044f6b201eae0a9e453b89c0433608e0778f0 (patch) | |
tree | 2ef70aed38ac9ee9b0c7dc3f1cdf8a8e79091c11 /includes | |
parent | c73d372bfebb5acee45e196d4e8694b656c7fd82 (diff) | |
download | haskell-d85044f6b201eae0a9e453b89c0433608e0778f0.tar.gz |
Default to infinite stack size (#8189)
When servicing a stack overflows, only throw an exception to the given
thread if the user explicitly set a max stack size, using +RTS -K.
Otherwise just service it normally and grow the stack.
In case we actually run out of *heap* (stack chuncks are allocated on
the heap), then we need to bail by calling the stackOverflow() hook and
exit immediately.
Authored-by: Ben Gamari <bgamari.foss@gmail.com>
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Rts.h | 3 | ||||
-rw-r--r-- | includes/rts/Constants.h | 2 | ||||
-rw-r--r-- | includes/rts/storage/GC.h | 13 |
3 files changed, 13 insertions, 5 deletions
diff --git a/includes/Rts.h b/includes/Rts.h index 122637c465..ee10a1044b 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -250,7 +250,7 @@ void getWin32ProgArgv(int *argc, wchar_t **argv[]); void setWin32ProgArgv(int argc, wchar_t *argv[]); #endif -void stackOverflow(void); +void stackOverflow(StgTSO* tso); void stg_exit(int n) GNU_ATTRIBUTE(__noreturn__); @@ -268,6 +268,7 @@ int stg_sig_install (int, int, void *); #define EXIT_INTERRUPTED 252 #define EXIT_HEAPOVERFLOW 251 #define EXIT_KILLED 250 +#define EXIT_STACKOVERFLOW 249 /* ----------------------------------------------------------------------------- Miscellaneous garbage diff --git a/includes/rts/Constants.h b/includes/rts/Constants.h index 494abe2b22..deb550ee97 100644 --- a/includes/rts/Constants.h +++ b/includes/rts/Constants.h @@ -234,7 +234,7 @@ * stopped for one reason or another. See typedef StgThreadReturnCode * in TSO.h. */ -#define HeapOverflow 1 /* might also be StackOverflow */ +#define HeapOverflow 1 #define StackOverflow 2 #define ThreadYielding 3 #define ThreadBlocked 4 diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h index fb5e21e832..07bc65128f 100644 --- a/includes/rts/storage/GC.h +++ b/includes/rts/storage/GC.h @@ -130,9 +130,15 @@ extern generation * oldest_gen; StgPtr allocate(Capability *cap, W_ n) Allocates memory from the nursery in - the current Capability. This can be - done without taking a global lock, - unlike allocate(). + the current Capability. This can be + done without taking a global lock, + unlike allocate(). In the event of a + heap overflow the program will be + terminated. + + StgPtr allocateFail(Capability *cap, W_ n) + Similar to allocate() but returns NULL + in the event of a heap overflow. StgPtr allocatePinned(Capability *cap, W_ n) Allocates a chunk of contiguous store @@ -154,6 +160,7 @@ extern generation * oldest_gen; -------------------------------------------------------------------------- */ StgPtr allocate ( Capability *cap, W_ n ); +StgPtr allocateFail ( Capability *cap, W_ n ); StgPtr allocatePinned ( Capability *cap, W_ n ); /* memory allocator for executable memory */ |