summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-04 11:02:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-04 11:02:06 -0700
commitebca89d000e512851b4f06e5f478635ee70b3f19 (patch)
tree1358002795eb073be5a5493d2ee5200a6dbfa590
parent9d8a89af69dfa46c7b74c2ffe049a5deddd67274 (diff)
downloadtxr-ebca89d000e512851b4f06e5f478635ee70b3f19.tar.gz
txr-ebca89d000e512851b4f06e5f478635ee70b3f19.tar.bz2
txr-ebca89d000e512851b4f06e5f478635ee70b3f19.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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index ee47f054..924d7d65 100644
--- a/gc.c
+++ b/gc.c
@@ -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) {