From 1ba05f5b2d7b1701242023b5ac156b169f1ded90 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 7 Dec 2020 13:32:20 +0900 Subject: [PATCH] need more lock in finalize_list() Some data should be accessed in parallel so they should be protected by the lock. --- gc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gc.c b/gc.c index 77229768bf..603541b2fd 100644 --- a/gc.c +++ b/gc.c @@ -2735,6 +2735,7 @@ make_io_zombie(rb_objspace_t *objspace, VALUE obj) static void obj_free_object_id(rb_objspace_t *objspace, VALUE obj) { + ASSERT_vm_locking(); st_data_t o = (st_data_t)obj, id; GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID)); @@ -3672,17 +3673,17 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie) run_final(objspace, zombie); - GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE); - if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) { - obj_free_object_id(objspace, zombie); - } - - RZOMBIE(zombie)->basic.flags = 0; - GC_ASSERT(heap_pages_final_slots > 0); - GC_ASSERT(page->final_slots > 0); - RB_VM_LOCK_ENTER(); { + GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE); + if (FL_TEST(zombie, FL_SEEN_OBJ_ID)) { + obj_free_object_id(objspace, zombie); + } + + RZOMBIE(zombie)->basic.flags = 0; + GC_ASSERT(heap_pages_final_slots > 0); + GC_ASSERT(page->final_slots > 0); + heap_pages_final_slots--; page->final_slots--; page->free_slots++;