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

ruby-changes:66825

From: nagachika <ko1@a...>
Date: Sun, 18 Jul 2021 11:42:42 +0900 (JST)
Subject: [ruby-changes:66825] ca6ebde821 (ruby_3_0): merge revision(s) 1fac99afdae2671a9ca86bead5bde4d0e2eff1b4: [Backport #18030]

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

From ca6ebde821991cb558003c3a1d680eaa8df3169d Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sun, 18 Jul 2021 10:58:55 +0900
Subject: merge revision(s) 1fac99afdae2671a9ca86bead5bde4d0e2eff1b4: [Backport
 #18030]

	skip marking for uninitialized imemo_env.

	RUBY_INTERNAL_EVENT_NEWOBJ can expose uninitialized imemo_env
	objects and marking it will cause critical error. This patch
	skips marking on uninitialized imemo_env.

	See: http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20210329T183003Z.fail.html.gz

	Shortest repro-code is provided by mame-san.
	---
	 gc.c                           | 16 ++++++++++------
	 test/objspace/test_objspace.rb | 13 +++++++++++++
	 2 files changed, 23 insertions(+), 6 deletions(-)
---
 gc.c                           | 16 ++++++++++------
 test/objspace/test_objspace.rb | 13 +++++++++++++
 version.h                      |  4 ++--
 3 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/gc.c b/gc.c
index 4bd9641..b9ca9c1 100644
--- a/gc.c
+++ b/gc.c
@@ -6187,12 +6187,16 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L6187
       case imemo_env:
 	{
 	    const rb_env_t *env = (const rb_env_t *)obj;
-            GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
-	    GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
-            gc_mark_values(objspace, (long)env->env_size, env->env);
-	    VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
-            gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
-	    gc_mark(objspace, (VALUE)env->iseq);
+
+            if (LIKELY(env->ep)) {
+                // just after newobj() can be NULL here.
+                GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
+                GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
+                gc_mark_values(objspace, (long)env->env_size, env->env);
+                VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
+                gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
+                gc_mark(objspace, (VALUE)env->iseq);
+            }
 	}
 	return;
       case imemo_cref:
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 6b956e6..5fd4113 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -243,6 +243,19 @@ class TestObjSpace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L243
     GC.enable
   end
 
+  def test_trace_object_allocations_gc_stress
+    prev = GC.stress
+    GC.stress = true
+
+    ObjectSpace.trace_object_allocations{
+      proc{}
+    }
+
+    assert true # success
+  ensure
+    GC.stress = prev
+  end
+
   def test_dump_flags
     info = ObjectSpace.dump("foo".freeze)
     assert_match(/"wb_protected":true, "old":true/, info)
diff --git a/version.h b/version.h
index e22880c..0ae26b7 100644
--- a/version.h
+++ b/version.h
@@ -12,11 +12,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 108
+#define RUBY_PATCHLEVEL 109
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 7
-#define RUBY_RELEASE_DAY 7
+#define RUBY_RELEASE_DAY 18
 
 #include "ruby/version.h"
 
-- 
cgit v1.1


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

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