Skip to content

Commit

Permalink
avoid running finish_task inside of throw_internal
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vtjnash committed Sep 28, 2015
1 parent 4f063d8 commit 279f0a2
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 279f0a2

Please sign in to comment.