From 817cd5991d6304a2368824acbfc0b0e95c2aa7a7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku <kaz@kylheku.com> Date: Thu, 24 Jun 2021 22:01:38 -0700 Subject: signals: disable stack overflow in handler. * signal.c (sig_handler): For a is_cpu_exception signal, we temporarily disable the stack limit. It might be executing on the sigaltstack buffer, which is almost certainly below the stack limit. * tests/012/stack.tl: New test case. We raise a SIGSEGV and check that in the handler, the stack limit is disabled, and that we can executed code. --- tests/012/stack.tl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/012/stack.tl') diff --git a/tests/012/stack.tl b/tests/012/stack.tl index a8d06487..879d3d27 100644 --- a/tests/012/stack.tl +++ b/tests/012/stack.tl @@ -29,3 +29,14 @@ (set-stack-limit orig) nil (set-stack-limit 65536) orig (set-stack-limit orig) 65536) + +(set-sig-handler sig-segv + (lambda (signal async-p) + (assert (null (get-stack-limit))) + (throw 'out))) + +(test + (catch + (raise sig-segv) + (out () :sig)) + :sig) -- cgit v1.2.3