From 358277a921d4f0d2b71415f95fd813cb0e27ad87 Mon Sep 17 00:00:00 2001 From: rm155 Date: Mon, 15 Apr 2024 15:20:05 -0400 Subject: [PATCH] Confirm object-graph safety at barrier creation point --- internal/gc.h | 19 ++++++++++--------- vm_sync.c | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/gc.h b/internal/gc.h index 1511728279ddcc..5f3597d2958576 100644 --- a/internal/gc.h +++ b/internal/gc.h @@ -143,15 +143,16 @@ void rb_global_tables_init(void); void rb_absorb_objspace_of_closing_ractor(rb_ractor_t *receiving_ractor, rb_ractor_t *closing_ractor); typedef enum { - OGS_FLAG_NONE = 0x000, - OGS_FLAG_NOT_RUNNING = 0x001, - OGS_FLAG_BLOCKING = 0x002, - OGS_FLAG_BARRIER_WAITING = 0x004, - OGS_FLAG_ENTERING_VM_LOCK = 0x008, - OGS_FLAG_RUNNING_LOCAL_GC = 0x010, - OGS_FLAG_RUNNING_GLOBAL_GC = 0x020, - OGS_FLAG_ABSORBING_OBJSPACE = 0x040, - OGS_FLAG_COND_AND_BARRIER = 0x080, + OGS_FLAG_NONE = 0x000, + OGS_FLAG_NOT_RUNNING = 0x001, + OGS_FLAG_BLOCKING = 0x002, + OGS_FLAG_BARRIER_WAITING = 0x004, + OGS_FLAG_BARRIER_CREATING = 0x008, + OGS_FLAG_ENTERING_VM_LOCK = 0x010, + OGS_FLAG_RUNNING_LOCAL_GC = 0x020, + OGS_FLAG_RUNNING_GLOBAL_GC = 0x040, + OGS_FLAG_ABSORBING_OBJSPACE = 0x080, + OGS_FLAG_COND_AND_BARRIER = 0x100, }; struct rb_order_chain_node { diff --git a/vm_sync.c b/vm_sync.c index 0af76c82d1d8f9..4cbbd4871d5944 100644 --- a/vm_sync.c +++ b/vm_sync.c @@ -223,7 +223,9 @@ rb_vm_barrier(void) VM_ASSERT(cr == GET_RACTOR()); VM_ASSERT(rb_ractor_status_p(cr, ractor_running)); + rb_ractor_object_graph_safety_advance(cr, OGS_FLAG_BARRIER_CREATING); rb_ractor_sched_barrier_start(vm, cr); + rb_ractor_object_graph_safety_withdraw(cr, OGS_FLAG_BARRIER_CREATING); } }