From 4f0c5f1273cb756b886f3a63930e8aa8698aa5c2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Dec 2016 06:58:49 -0800 Subject: Cancel in-progress gc if handling async signal. If a signal goes off in the middle of gc that is routed to an async lambda handler, we should cancel gc, so the handler finds the heap in a good state. Of course, the handler must not return in this case, or else the interrupted gc will try to resume. * gc.c (inprogress): New static flag. (gc): Increment and decrement inprogress variable. Abort if re-entered. (gc_inprogress): New function. (unmark): Do not clear FREE flags, only REACHABLE. (gc_cancel): New function. * gc.h (gc_inprogress, gc_cancel): Declared. * signal.c (sig_handler): In the async lambda case, check for an in-progress gc and cancel it. --- signal.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'signal.c') diff --git a/signal.c b/signal.c index ef64c64e..2bab8ad8 100644 --- a/signal.c +++ b/signal.c @@ -94,6 +94,8 @@ static void sig_handler(int sig) if (!in_interrupt && async_sig_enabled) { uw_simple_catch_begin; async_sig_enabled = 0; + if (gc_inprogress()) + gc_cancel(); if (funcall2(lambda, num_fast(sig), t)) sig_deferred |= (1UL << sig); uw_unwind { -- cgit v1.2.3