diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-07-04 11:02:06 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-04 11:02:06 -0700 |
commit | 4673a0166dd3b91c8343df420a320b4610b973f7 (patch) | |
tree | 1358002795eb073be5a5493d2ee5200a6dbfa590 | |
parent | 371966c2c5c9724103e455f2697436e158aebaf2 (diff) | |
download | txr-4673a0166dd3b91c8343df420a320b4610b973f7.tar.gz txr-4673a0166dd3b91c8343df420a320b4610b973f7.tar.bz2 txr-4673a0166dd3b91c8343df420a320b4610b973f7.zip |
stack-limit: always set a stack limit.
Even if built without getrlimit, and even if getrlimit
reports an unlimited stack size, set up a default limit.
* gc.c (DFL_STACK_LIMIT): New preprocessor symbol, defined as
128 kilbytes for a small memory configuration, otherwise
16 megabytes.
(gc_init): Set up a default stack limit unconditionally
based on DFL_STACK_LIMIT before probing getrlimit.
-rw-r--r-- | gc.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -57,6 +57,7 @@ #define FULL_GC_INTERVAL 20 #define FRESHOBJ_VEC_SIZE (2 * HEAP_SIZE) #define DFL_MALLOC_DELTA_THRESH (16L * 1024 * 1024) +#define DFL_STACK_LIMIT (128 * 1024L) #else #define HEAP_SIZE 16384 #define CHECKOBJ_VEC_SIZE (2 * HEAP_SIZE) @@ -64,6 +65,7 @@ #define FULL_GC_INTERVAL 40 #define FRESHOBJ_VEC_SIZE (8 * HEAP_SIZE) #define DFL_MALLOC_DELTA_THRESH (64L * 1024 * 1024) +#define DFL_STACK_LIMIT (16384 * 1024L) #endif #if HAVE_MEMALIGN || HAVE_POSIX_MEMALIGN @@ -893,6 +895,7 @@ int gc_inprogress(void) void gc_init(val *stack_bottom) { gc_stack_bottom = stack_bottom; + gc_stack_limit = gc_stack_bottom - DFL_STACK_LIMIT / sizeof (val); #if HAVE_RLIMIT struct rlimit rl; if (getrlimit(RLIMIT_STACK, &rl) == 0) { |