Skip to content

Commit f5ef758

Browse files
ko1claude
andcommitted
thread: a new Ractor must not inherit the creating thread's fiber storage
thread_create_core inherited fiber storage unconditionally, so a new Ractor's main fiber received the creating thread's fiber-local storage, whose entries may be objects owned by the creating Ractor. Skip the inheritance for Ractor main threads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3548065 commit f5ef758

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

thread.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,12 @@ thread_create_core(VALUE thval, struct thread_create_params *params)
845845
"can't start a new thread (frozen ThreadGroup)");
846846
}
847847

848-
rb_fiber_inherit_storage(ec, th->ec->fiber_ptr);
848+
/* A new Ractor must not inherit the creating thread's fiber storage: its
849+
* entries may be objects owned by the creating Ractor. Only threads created
850+
* within the same Ractor inherit it. */
851+
if (params->type != thread_invoke_type_ractor_proc) {
852+
rb_fiber_inherit_storage(ec, th->ec->fiber_ptr);
853+
}
849854

850855
switch (params->type) {
851856
case thread_invoke_type_proc:

0 commit comments

Comments
 (0)