aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-30 15:24:36 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-30 16:34:38 +1300
commit388281c5c92d4c04bfb08aeac7513770de9ea128 (patch)
treea6bb09ae1b7387222b6ba1a8bbf1db22bcab688f /eval.c
parent48b94b791997881929c739c64f95ac30f3fd0bb9 (diff)
downloadruby-388281c5c92d4c04bfb08aeac7513770de9ea128.tar.gz
Fix order of operations during `rb_ec_finalize`.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index 43a50840ae..16f72d9c0d 100644
--- a/eval.c
+++ b/eval.c
@@ -162,7 +162,11 @@ static void
rb_ec_scheduler_finalize(rb_execution_context_t *ec)
{
rb_thread_t *thread = rb_ec_thread_ptr(ec);
- rb_thread_scheduler_set(thread->self, Qnil);
+ EC_PUSH_TAG(ec);
+ if (EC_EXEC_TAG() == TAG_NONE) {
+ rb_thread_scheduler_set(thread->self, Qnil);
+ }
+ EC_POP_TAG();
}
static void
@@ -217,6 +221,10 @@ 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;
@@ -278,9 +286,6 @@ rb_ec_cleanup(rb_execution_context_t *ec, volatile int ex)
}
}
- // If the user code defined a scheduler for the top level thread, run it:
- rb_ec_scheduler_finalize(ec);
-
mjit_finish(true); // We still need ISeqs here.
rb_ec_finalize(ec);