From 89b3e4719209d47f223256daee4bccbe7ae92d60 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Sat, 7 Jun 2025 21:39:27 -0700 Subject: [PATCH] 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 :48: [BUG] gc_verify_internal_consistency: found internal inconsistency. --- ractor_sync.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ractor_sync.c b/ractor_sync.c index 204c800a06..30c386663c 100644 --- a/ractor_sync.c +++ b/ractor_sync.c @@ -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;