Rework `rb_ec_scheduler_finalize` to ensure exceptions are printed.

This commit is contained in:
Samuel Williams 2020-10-01 14:20:26 +13:00
Родитель dd2e95fb26
Коммит a88fe61a3e
1 изменённых файлов: 19 добавлений и 14 удалений

33
eval.c
Просмотреть файл

@ -146,9 +146,28 @@ ruby_options(int argc, char **argv)
return iseq;
}
static void
rb_ec_scheduler_finalize(rb_execution_context_t *ec)
{
rb_thread_t *thread = rb_ec_thread_ptr(ec);
enum ruby_tag_type state;
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
rb_thread_scheduler_set(thread->self, Qnil);
}
else {
state = error_handle(ec, state);
}
EC_POP_TAG();
}
static void
rb_ec_teardown(rb_execution_context_t *ec)
{
// If the user code defined a scheduler for the top level thread, run it:
rb_ec_scheduler_finalize(ec);
EC_PUSH_TAG(ec);
if (EC_EXEC_TAG() == TAG_NONE) {
rb_vm_trap_exit(rb_ec_vm_ptr(ec));
@ -158,17 +177,6 @@ rb_ec_teardown(rb_execution_context_t *ec)
rb_ec_clear_all_trace_func(ec);
}
static void
rb_ec_scheduler_finalize(rb_execution_context_t *ec)
{
rb_thread_t *thread = rb_ec_thread_ptr(ec);
EC_PUSH_TAG(ec);
if (EC_EXEC_TAG() == TAG_NONE) {
rb_thread_scheduler_set(thread->self, Qnil);
}
EC_POP_TAG();
}
static void
rb_ec_finalize(rb_execution_context_t *ec)
{
@ -222,9 +230,6 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
rb_threadptr_interrupt(th);
rb_threadptr_check_signal(th);
// If the user code defined a scheduler for the top level thread, run it:
rb_ec_scheduler_finalize(ec);
EC_PUSH_TAG(ec);
if ((state = EC_EXEC_TAG()) == TAG_NONE) {
th = th0;