Project

General

Profile

Bug #16598

Backport af899503 to ruby_2_7

Added by nagachika (Tomoyuki Chikanaga) 7 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:97008]

Description

nobu said that the fix at af899503 is also necessary for ruby_2_7 branch.

Updated by nobu (Nobuyoshi Nakada) 7 months ago

  • Description updated (diff)

A patch without gc.rb.

commit 030a30a0dc301e79b147233d2142822915f7dde9
Author:     Nobuyoshi Nakada <nobu@ruby-lang.org>
AuthorDate: 2020-01-27 10:46:57 +0900
Commit:     Nobuyoshi Nakada <nobu@ruby-lang.org>
CommitDate: 2020-01-28 09:49:53 +0900

    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 131ffb8246..4704925abc 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

 /*
  *  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)
         }

         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 e93e775279..75d9b01f2c 100644
--- a/test/ruby/test_gc_compact.rb
+++ b/test/ruby/test_gc_compact.rb
@@ -39,6 +39,8 @@
     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

Updated by naruse (Yui NARUSE) 5 months ago

  • Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE

ruby_2_7 716e05b82338d75452e86c999ae3e5874a642ecd [Backport #16598].

Also available in: Atom PDF