Skip to content

Commit

Permalink
Use main_thread->ec from rb_vm_main_ractor_ec
Browse files Browse the repository at this point in the history
rb_vm_main_ractor_ec was introduced to allow rb_postponed_job_* to work
when fired on non-Ruby threads, which have no EC set, and that is its
only use.

When RUBY_MN_THREADS=1 is set ractor->threads.running_ec is NULL when
the shared thread is sleeping. This instead grabs the EC directly from
the main thread which seems to always be set.

Fixes [Bug #20016]

Co-authored-by: Dustin Brown <dbrown9@gmail.com>
  • Loading branch information
jhawthorn and dustinbrownman committed Dec 21, 2023
1 parent 1710eb9 commit 1f03042
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ractor.c
Expand Up @@ -2481,7 +2481,7 @@ rb_ractor_terminate_all(void)
rb_execution_context_t *
rb_vm_main_ractor_ec(rb_vm_t *vm)
{
return vm->ractor.main_ractor->threads.running_ec;
return vm->ractor.main_thread->ec;
}

static VALUE
Expand Down

0 comments on commit 1f03042

Please sign in to comment.