From 279f0a2582b1f5d632dab1999f5d51b1621686da Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Mon, 28 Sep 2015 02:22:38 -0400 Subject: [PATCH] avoid running finish_task inside of throw_internal if throw_internal is running from the segv_handler, there might not be enough stack to run arbitrary functions this change, therefore, makes stack overflow in tasks more reliable --- src/task.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/task.c b/src/task.c index cbd8d9bcf853c4..50c8cceb9d8e31 100644 --- a/src/task.c +++ b/src/task.c @@ -238,8 +238,16 @@ static void NOINLINE NORETURN start_task() { // this runs the first time we switch to a task jl_task_t *t = jl_current_task; + jl_value_t *res; throw_if_exception_set(t); - jl_value_t *res = jl_apply(t->start, NULL, 0); + JL_TRY { + res = jl_apply(t->start, NULL, 0); + } + JL_CATCH { + res = jl_exception_in_transit; + t->exception = res; + jl_gc_wb(t, res); + } finish_task(t, res); abort(); } @@ -668,17 +676,11 @@ void NORETURN throw_internal(jl_value_t *e) jl_longjmp(jl_current_task->eh->eh_ctx, 1); } else { - if (jl_current_task == jl_root_task) { - jl_printf(JL_STDERR, "fatal: error thrown and no exception handler available.\n"); - jl_static_show(JL_STDERR, e); - jl_printf(JL_STDERR, "\n"); - jlbacktrace(); - jl_exit(1); - } - jl_current_task->exception = e; - jl_gc_wb(jl_current_task, e); - finish_task(jl_current_task, e); - assert(0); + jl_printf(JL_STDERR, "fatal: error thrown and no exception handler available.\n"); + jl_static_show(JL_STDERR, e); + jl_printf(JL_STDERR, "\n"); + jlbacktrace(); + jl_exit(1); } assert(0); }