From 703753294347f51a0bf3f0f01569d03088122680 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Wed, 1 Sep 2021 21:05:05 -0500 Subject: [PATCH] Errored threads always emit stacktrace or supervisor event. That way, it is much harder to swallow errors. Error swallowing behavior would have to be done explicitly by wrapping fibers with `protect` or `try`. --- src/core/ev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/ev.c b/src/core/ev.c index 0bdbd794..adcc56b1 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1209,14 +1209,17 @@ JanetFiber *janet_loop1(void) { Janet res; JanetSignal sig = janet_continue_signal(task.fiber, task.value, &res, task.sig); void *sv = task.fiber->supervisor_channel; + int is_suspended = sig == JANET_SIGNAL_EVENT || sig == JANET_SIGNAL_YIELD || sig == JANET_SIGNAL_INTERRUPT; if (NULL == sv) { - if (sig != JANET_SIGNAL_EVENT && sig != JANET_SIGNAL_YIELD && sig != JANET_SIGNAL_INTERRUPT) { + if (!is_suspended) { janet_stacktrace(task.fiber, res); } } else if (sig == JANET_SIGNAL_OK || (task.fiber->flags & (1 << sig))) { JanetChannel *chan = janet_channel_unwrap(sv); janet_channel_push(chan, make_supervisor_event(janet_signal_names[sig], task.fiber, chan->is_threaded), 2); + } else if (!is_suspended) { + janet_stacktrace(task.fiber, res); } if (sig == JANET_SIGNAL_INTERRUPT) { /* On interrupts, return the interrupted fiber immediately */