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

ruby-changes:64235

From: Koichi <ko1@a...>
Date: Thu, 17 Dec 2020 18:13:55 +0900 (JST)
Subject: [ruby-changes:64235] da3438a504 (master): sync obj_to_id_tbl

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

From da3438a50454706cce2e5b06bdad498b42977f8f Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 17 Dec 2020 17:29:05 +0900
Subject: sync obj_to_id_tbl

objspace->obj_to_id_tbl is a shared table so we need to synchronize
it to access.

diff --git a/gc.c b/gc.c
index a5ef670..386e140 100644
--- a/gc.c
+++ b/gc.c
@@ -4046,9 +4046,9 @@ cached_object_id(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L4046
     VALUE id;
     rb_objspace_t *objspace = &rb_objspace;
 
+    RB_VM_LOCK_ENTER();
     if (st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, &id)) {
         GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
-        return id;
     }
     else {
         GC_ASSERT(!FL_TEST(obj, FL_SEEN_OBJ_ID));
@@ -4061,9 +4061,10 @@ cached_object_id(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L4061
         st_insert(objspace->id_to_obj_tbl, (st_data_t)id, (st_data_t)obj);
         if (already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
         FL_SET(obj, FL_SEEN_OBJ_ID);
-
-        return id;
     }
+    RB_VM_LOCK_LEAVE();
+
+    return id;
 }
 
 static VALUE
-- 
cgit v0.10.2


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

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