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

ruby-changes:73716

From: nagachika <ko1@a...>
Date: Sun, 25 Sep 2022 13:43:40 +0900 (JST)
Subject: [ruby-changes:73716] c356c31f77 (ruby_3_1): merge revision(s) 86d061294d3cc1656e18d0e1fd4b4f290da16944: [Backport #18928]

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

From c356c31f77b2d7c7c7f40f5b19dbb0961ea5f803 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sun, 25 Sep 2022 13:00:25 +0900
Subject: merge revision(s) 86d061294d3cc1656e18d0e1fd4b4f290da16944: [Backport
 #18928]

	[Bug #18928] Fix crash in WeakMap

	In wmap_live_p, if is_pointer_to_heap returns false, then the page is
	either in the tomb or has already been freed, so the object is dead. In
	this case, wmap_live_p should return false.
	---
	 gc.c | 21 +++++++++++----------
	 1 file changed, 11 insertions(+), 10 deletions(-)
---
 gc.c      | 21 +++++++++++----------
 version.h |  2 +-
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/gc.c b/gc.c
index 7863f9590a..030a4627bd 100644
--- a/gc.c
+++ b/gc.c
@@ -12035,20 +12035,21 @@ static int https://github.com/ruby/ruby/blob/trunk/gc.c#L12035
 wmap_live_p(rb_objspace_t *objspace, VALUE obj)
 {
     if (SPECIAL_CONST_P(obj)) return TRUE;
-    if (is_pointer_to_heap(objspace, (void *)obj)) {
-        void *poisoned = asan_unpoison_object_temporary(obj);
+    /* If is_pointer_to_heap returns false, the page could be in the tomb heap
+     * or have already been freed. */
+    if (!is_pointer_to_heap(objspace, (void *)obj)) return FALSE;
 
-        enum ruby_value_type t = BUILTIN_TYPE(obj);
-        int ret = (!(t == T_NONE || t >= T_FIXNUM || t == T_ICLASS) &&
-                   is_live_object(objspace, obj));
+    void *poisoned = asan_unpoison_object_temporary(obj);
 
-        if (poisoned) {
-            asan_poison_object(obj);
-        }
+    enum ruby_value_type t = BUILTIN_TYPE(obj);
+    int ret = (!(t == T_NONE || t >= T_FIXNUM || t == T_ICLASS) &&
+                is_live_object(objspace, obj));
 
-        return ret;
+    if (poisoned) {
+        asan_poison_object(obj);
     }
-    return TRUE;
+
+    return ret;
 }
 
 static int
diff --git a/version.h b/version.h
index 7f851815b0..2dd1b4d533 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11
 # 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 58
+#define RUBY_PATCHLEVEL 59
 
 #define RUBY_RELEASE_YEAR 2022
 #define RUBY_RELEASE_MONTH 9
-- 
cgit v1.2.1


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

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