Initialize ractor thgroup in thread_do_start_proc

Followup: https://github.com/ruby/ruby/pull/13013
This commit is contained in:
Jean Boussier 2025-03-31 10:34:46 +02:00
parent 5e421ce8d9
commit 532b9246d3
Notes: git 2025-03-31 09:14:50 +00:00

View File

@ -576,6 +576,8 @@ thread_do_start_proc(rb_thread_t *th)
if (th->invoke_type == thread_invoke_type_ractor_proc) {
VALUE self = rb_ractor_self(th->ractor);
th->thgroup = th->ractor->thgroup_default = rb_obj_alloc(cThGroup);
VM_ASSERT(FIXNUM_P(args));
args_len = FIX2INT(args);
args_ptr = ALLOCA_N(VALUE, args_len);
@ -796,7 +798,6 @@ struct thread_create_params {
// for normal proc thread
VALUE args;
VALUE proc;
VALUE group;
// for ractor
rb_ractor_t *g;
@ -855,13 +856,7 @@ thread_create_core(VALUE thval, struct thread_create_params *params)
}
th->priority = current_th->priority;
if (params->group) {
th->thgroup = params->group;
}
else {
th->thgroup = current_th->thgroup;
}
th->pending_interrupt_queue = rb_ary_hidden_new(0);
th->pending_interrupt_queue_checked = 0;
@ -1001,19 +996,12 @@ rb_thread_create(VALUE (*fn)(void *), void *arg)
VALUE
rb_thread_create_ractor(rb_ractor_t *r, VALUE args, VALUE proc)
{
VALUE thgroup = r->thgroup_default = rb_obj_alloc(cThGroup);
#if RACTOR_CHECK_MODE > 0
rb_ractor_setup_belonging_to(thgroup, r->pub.id);
#endif
struct thread_create_params params = {
.type = thread_invoke_type_ractor_proc,
.g = r,
.group = thgroup,
.args = args,
.proc = proc,
};
RB_GC_GUARD(thgroup);
return thread_create_core(rb_thread_alloc(rb_cThread), &params);;
}