From 9d8a89af69dfa46c7b74c2ffe049a5deddd67274 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 4 Jul 2021 09:53:29 -0700 Subject: stack-limit: bug: not handling RLIM_INFINITY. * gc.c (gc_init): We must check rlim_cur for the RLIM_INFINITY value indicating unlimited stack, and not misuse this value as a limit number, otherwise hilarity ensues. This reproduced on an older platform with make 3.81, which calls setrlimit to bring about an unlimited stack, passed on to child processes. Because of this txr segfaulted, as a consequence of a false positive. * tests/012/stack.tl (stack-limited): New variable which indicates whether there is a stack limit. If there isn't, we avoid running the fork-based test case. Also, we set the stack limit to 32768 so we have a limit against which to run some of the tests. --- tests/012/stack.tl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/012/stack.tl b/tests/012/stack.tl index 879d3d27..9a7534bb 100644 --- a/tests/012/stack.tl +++ b/tests/012/stack.tl @@ -1,5 +1,7 @@ (load "../common") +(defvar stack-limited (set-stack-limit 32768)) + (defun recur () (recur)) (defmacro so (expr) @@ -8,12 +10,13 @@ (test (so (recur)) :so) -(test (let ((pid (fork))) - (cond - ((zerop pid) (set-stack-limit 0) (recur)) - (t (let ((status (wait pid))) - (w-ifsignaled status))))) - t) +(if stack-limited + (test (let ((pid (fork))) + (cond + ((zerop pid) (set-stack-limit 0) (recur)) + (t (let ((status (wait pid))) + (w-ifsignaled status))))) + t)) (defmacro infexp () ^(foo (infexp))) -- cgit v1.2.3