diff options
author | Samuel Williams <[email protected]> | 2020-10-01 14:20:26 +1300 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2020-10-01 16:56:05 +1300 |
commit | a88fe61a3e3079fd4bd0172374dfa8bd229a90d5 (patch) | |
tree | 105e1ab8ba535c78a3224058c7636c29567ce243 /eval.c | |
parent | dd2e95fb26b89ce060631af0fd372b5780a443dd (diff) |
Rework `rb_ec_scheduler_finalize` to ensure exceptions are printed.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3610
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -147,26 +147,34 @@ ruby_options(int argc, char **argv) } static void -rb_ec_teardown(rb_execution_context_t *ec) +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 (EC_EXEC_TAG() == TAG_NONE) { - rb_vm_trap_exit(rb_ec_vm_ptr(ec)); + if ((state = EC_EXEC_TAG()) == TAG_NONE) { + rb_thread_scheduler_set(thread->self, Qnil); + } + else { + state = error_handle(ec, state); } EC_POP_TAG(); - rb_ec_exec_end_proc(ec); - rb_ec_clear_all_trace_func(ec); } static void -rb_ec_scheduler_finalize(rb_execution_context_t *ec) +rb_ec_teardown(rb_execution_context_t *ec) { - rb_thread_t *thread = rb_ec_thread_ptr(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_thread_scheduler_set(thread->self, Qnil); + rb_vm_trap_exit(rb_ec_vm_ptr(ec)); } EC_POP_TAG(); + rb_ec_exec_end_proc(ec); + rb_ec_clear_all_trace_func(ec); } static void @@ -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; |