ruby-changes:64038
From: Koichi <ko1@a...>
Date: Wed, 9 Dec 2020 15:16:24 +0900 (JST)
Subject: [ruby-changes:64038] 45b29754cf (master): need the lock for debug checking.
https://git.ruby-lang.org/ruby.git/commit/?id=45b29754cf From 45b29754cfba8435bc4980a87cd0d32c648f8a2e Mon Sep 17 00:00:00 2001 From: Koichi Sasada <ko1@a...> Date: Wed, 9 Dec 2020 14:49:06 +0900 Subject: need the lock for debug checking. Checking code (RGENGC_CHECK_MODE > 0) need a VM lock because it refers objspace. diff --git a/gc.c b/gc.c index 603541b..f7d00cb 100644 --- a/gc.c +++ b/gc.c @@ -2084,18 +2084,25 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L2084 #if RGENGC_CHECK_MODE p->as.values.v1 = p->as.values.v2 = p->as.values.v3 = 0; - GC_ASSERT(RVALUE_MARKED(obj) == FALSE); - GC_ASSERT(RVALUE_MARKING(obj) == FALSE); - GC_ASSERT(RVALUE_OLD_P(obj) == FALSE); - GC_ASSERT(RVALUE_WB_UNPROTECTED(obj) == FALSE); - if (flags & FL_PROMOTED1) { - if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj)); - } - else { - if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj)); + RB_VM_LOCK_ENTER_NO_BARRIER(); + { + check_rvalue_consistency(obj); + + GC_ASSERT(RVALUE_MARKED(obj) == FALSE); + GC_ASSERT(RVALUE_MARKING(obj) == FALSE); + GC_ASSERT(RVALUE_OLD_P(obj) == FALSE); + GC_ASSERT(RVALUE_WB_UNPROTECTED(obj) == FALSE); + + if (flags & FL_PROMOTED1) { + if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj)); + } + else { + if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj)); + } + if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj)); } - if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj)); + RB_VM_LOCK_LEAVE_NO_BARRIER(); #endif if (UNLIKELY(wb_protected == FALSE)) { @@ -2146,8 +2153,6 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace, https://github.com/ruby/ruby/blob/trunk/gc.c#L2153 } } #endif - check_rvalue_consistency(obj); - // RUBY_DEBUG_LOG("obj:%p (%s)", (void *)obj, obj_type_name(obj)); return obj; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/