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

ruby-changes:69326

From: Aaron <ko1@a...>
Date: Fri, 22 Oct 2021 07:47:54 +0900 (JST)
Subject: [ruby-changes:69326] 844588f915 (master): Push compaction page alignment check down

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

From 844588f9157b364244a7d34ee0fcc70ccc2a7dd9 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Thu, 21 Oct 2021 13:27:56 -0700
Subject: Push compaction page alignment check down

It seems like `gc_verify_compaction_references` is not protected in case
alignment is wrong.  This commit pushes the alignment check down to
`gc_start_internal` so that anyone trying to compact will check page
alignment

I think this method may be getting called on PowerPC and the alignment
might be wrong.

  http://rubyci.s3.amazonaws.com/ppc64le/ruby-master/log/20211021T190006Z.fail.html.gz
---
 gc.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/gc.c b/gc.c
index 4451218f71..84df8a79eb 100644
--- a/gc.c
+++ b/gc.c
@@ -9296,6 +9296,24 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L9296
 
     /* For now, compact implies full mark / sweep, so ignore other flags */
     if (RTEST(compact)) {
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
+        /* If Ruby's heap pages are not a multiple of the system page size, we
+         * cannot use mprotect for the read barrier, so we must disable compaction. */
+        int pagesize;
+        pagesize = (int)sysconf(_SC_PAGE_SIZE);
+        if ((HEAP_PAGE_SIZE % pagesize) != 0) {
+            rb_raise(rb_eNotImpError, "Compaction isn't available on this platform");
+        }
+#endif
+
+    /* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for
+     * the read barrier, so we must disable compaction. */
+#if !defined(__MINGW32__) && !defined(_WIN32)
+        if (!USE_MMAP_ALIGNED_ALLOC) {
+            rb_raise(rb_eNotImpError, "Compaction isn't available on this platform");
+        }
+#endif
+
         reason |= GPR_FLAG_COMPACT;
     }
     else {
@@ -10250,24 +10268,6 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data) https://github.com/ruby/ruby/blob/trunk/gc.c#L10268
 static VALUE
 gc_compact(rb_execution_context_t *ec, VALUE self)
 {
-#if defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE)
-    /* If Ruby's heap pages are not a multiple of the system page size, we
-     * cannot use mprotect for the read barrier, so we must disable compaction. */
-    int pagesize;
-    pagesize = (int)sysconf(_SC_PAGE_SIZE);
-    if ((HEAP_PAGE_SIZE % pagesize) != 0) {
-        rb_raise(rb_eNotImpError, "Compaction isn't available on this platform");
-    }
-#endif
-
-    /* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for
-     * the read barrier, so we must disable compaction. */
-#if !defined(__MINGW32__) && !defined(_WIN32)
-    if (!USE_MMAP_ALIGNED_ALLOC) {
-        rb_raise(rb_eNotImpError, "Compaction isn't available on this platform");
-    }
-#endif
-
     /* Run GC with compaction enabled */
     gc_start_internal(ec, self, Qtrue, Qtrue, Qtrue, Qtrue);
 
-- 
cgit v1.2.1


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

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