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

ruby-changes:60040

From: Nobuyoshi <ko1@a...>
Date: Thu, 13 Feb 2020 15:23:13 +0900 (JST)
Subject: [ruby-changes:60040] 716e05b823 (ruby_2_7): Fixed a segfault `GC.verify_compaction_references`

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

From 716e05b82338d75452e86c999ae3e5874a642ecd Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 27 Jan 2020 10:46:57 +0900
Subject: Fixed a segfault `GC.verify_compaction_references`

Which is by coercion of `Qundef`, when any keyword argument
without `toward:` option is given.  [Bug #16598]

diff --git a/gc.c b/gc.c
index 131ffb8..4704925 100644
--- a/gc.c
+++ b/gc.c
@@ -8618,7 +8618,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8618
 
 /*
  *  call-seq:
- *     GC.verify_compaction_references                  -> nil
+ *     GC.verify_compaction_references(toward: nil, double_heap: nil) -> nil
  *
  *  Verify compaction reference consistency.
  *
@@ -8656,7 +8656,7 @@ gc_verify_compaction_references(int argc, VALUE *argv, VALUE mod) https://github.com/ruby/ruby/blob/trunk/gc.c#L8656
         }
 
         rb_get_kwargs(opt, keyword_ids, 0, 2, kwvals);
-        if (rb_intern("empty") == rb_sym2id(kwvals[0])) {
+        if (kwvals[0] != Qundef && rb_intern("empty") == rb_sym2id(kwvals[0])) {
             use_toward_empty = TRUE;
         }
         if (kwvals[1] != Qundef && RTEST(kwvals[1])) {
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb
index e93e775..75d9b01 100644
--- a/test/ruby/test_gc_compact.rb
+++ b/test/ruby/test_gc_compact.rb
@@ -39,6 +39,8 @@ class TestGCCompact < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_gc_compact.rb#L39
     hash = list_of_objects.hash
     GC.verify_compaction_references(toward: :empty)
     assert_equal hash, list_of_objects.hash
+    GC.verify_compaction_references(double_heap: false)
+    assert_equal hash, list_of_objects.hash
   end
 
   def walk_ast ast
-- 
cgit v0.10.2


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

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