[前][次][番号順一覧][スレッド一覧]

ruby-changes:63988

From: Koichi <ko1@a...>
Date: Mon, 7 Dec 2020 13:33:15 +0900 (JST)
Subject: [ruby-changes:63988] 1ba05f5b2d (master): need more lock in finalize_list()

https://git.ruby-lang.org/ruby.git/commit/?id=1ba05f5b2d

From 1ba05f5b2d7b1701242023b5ac156b169f1ded90 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Mon, 7 Dec 2020 13:32:20 +0900
Subject: need more lock in finalize_list()

Some data should be accessed in parallel so they should be protected
by the lock.

diff --git a/gc.c b/gc.c
index 7722976..603541b 100644
--- a/gc.c
+++ b/gc.c
@@ -2735,6 +2735,7 @@ make_io_zombie(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L2735
 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L3673
 
 	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++;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]