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

ruby-changes:66857

From: Peter <ko1@a...>
Date: Thu, 22 Jul 2021 03:41:05 +0900 (JST)
Subject: [ruby-changes:66857] 31144fe987 (master): Change GC verification to walk all pages

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

From 31144fe9876f5624e1fe7ed8f529e28fc4d65bdb Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Wed, 21 Jul 2021 13:56:32 -0400
Subject: Change GC verification to walk all pages

`gc_verify_internal_consistency_` does not walk pages in the tomb heap
so numbers were off. This commit changes it to walk all allocated pages.
---
 gc.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gc.c b/gc.c
index 9ccd26d..239bf95 100644
--- a/gc.c
+++ b/gc.c
@@ -7497,9 +7497,9 @@ check_children_i(const VALUE child, void *ptr) https://github.com/ruby/ruby/blob/trunk/gc.c#L7497
 }
 
 static int
-verify_internal_consistency_i(void *page_start, void *page_end, size_t stride, void *ptr)
+verify_internal_consistency_i(void *page_start, void *page_end, size_t stride,
+                              struct verify_internal_consistency_struct *data)
 {
-    struct verify_internal_consistency_struct *data = (struct verify_internal_consistency_struct *)ptr;
     VALUE obj;
     rb_objspace_t *objspace = data->objspace;
 
@@ -7702,8 +7702,10 @@ gc_verify_internal_consistency_(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L7702
     gc_report(5, objspace, "gc_verify_internal_consistency: start\n");
 
     /* check relations */
-
-    objspace_each_objects(objspace, verify_internal_consistency_i, &data, FALSE);
+    for (size_t i = 0; i < heap_allocated_pages; i++) {
+        struct heap_page *page = heap_pages_sorted[i];
+        verify_internal_consistency_i(page->start, page->start + page->total_slots, sizeof(RVALUE), &data);
+    }
 
     if (data.err_count != 0) {
 #if RGENGC_CHECK_MODE >= 5
@@ -7756,8 +7758,7 @@ gc_verify_internal_consistency_(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L7758
 	if (heap_pages_final_slots != data.zombie_object_count ||
 	    heap_pages_final_slots != list_count) {
 
-            // TODO: debug it
-            rb_warn("inconsistent finalizing object count:\n"
+            rb_bug("inconsistent finalizing object count:\n"
                     "  expect %"PRIuSIZE"\n"
                     "  but    %"PRIuSIZE" zombies\n"
                     "  heap_pages_deferred_final list has %"PRIuSIZE" items.",
-- 
cgit v1.1


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

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