Add write barriers from Ractor::Port to Ractor

Ractor::Port will mark the ractor, so we must issue a write barrier.

This was detected by wbcheck, but we've also seen it in CI:

    verify_internal_consistency_reachable_i: WB miss (O->Y) 0x000071507d8bff80 ractor/port/Ractor::Port ractor/port -> 0x0000715097f5a470 ractor/Ractor r:1
    <internal:kernel>:48: [BUG] gc_verify_internal_consistency: found internal inconsistency.
This commit is contained in:
John Hawthorn 2025-06-07 21:39:27 -07:00
parent aaa956e8f1
commit 89b3e47192
Notes: git 2025-06-18 17:08:58 +00:00

View file

@ -81,6 +81,7 @@ ractor_port_init(VALUE rpv, rb_ractor_t *r)
struct ractor_port *rp = RACTOR_PORT_PTR(rpv);
rp->r = r;
RB_OBJ_WRITTEN(rpv, Qundef, r->pub.self);
rp->id_ = ractor_genid_for_port(r);
ractor_add_port(r, ractor_port_id(rp));
@ -102,6 +103,7 @@ ractor_port_initialzie_copy(VALUE self, VALUE orig)
struct ractor_port *dst = RACTOR_PORT_PTR(self);
struct ractor_port *src = RACTOR_PORT_PTR(orig);
dst->r = src->r;
RB_OBJ_WRITTEN(self, Qundef, dst->r->pub.self);
dst->id_ = ractor_port_id(src);
return self;