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

ruby-changes:68769

From: Mike <ko1@a...>
Date: Thu, 21 Oct 2021 08:13:29 +0900 (JST)
Subject: [ruby-changes:68769] 7a75e9bbaf (master): ujit_asm: if mmap() fails with the address hint, try without

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

From 7a75e9bbaf47ce597361f7a9e7c8550a5d7e15ed Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@g...>
Date: Thu, 11 Feb 2021 12:13:14 -0500
Subject: ujit_asm: if mmap() fails with the address hint, try without

valgrind doesn't seem to support the address hint, and so the fallback
to using NULL will allow valgrind to run.
---
 ujit_asm.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ujit_asm.c b/ujit_asm.c
index a5d7f480bc..c580414539 100644
--- a/ujit_asm.c
+++ b/ujit_asm.c
@@ -137,9 +137,19 @@ uint8_t* alloc_exec_mem(uint32_t mem_size) https://github.com/ruby/ruby/blob/trunk/ujit_asm.c#L137
         0
     );
 
+    if (mem_block == MAP_FAILED) {
+        mem_block = (uint8_t*)mmap(
+            NULL, // try again without the address hint (e.g., valgrind)
+            mem_size,
+            PROT_READ | PROT_WRITE | PROT_EXEC,
+            MAP_PRIVATE | MAP_ANONYMOUS,
+            -1,
+            0
+            );
+    }
+
     // Check that the memory mapping was successful
-    if (mem_block == MAP_FAILED)
-    {
+    if (mem_block == MAP_FAILED) {
         fprintf(stderr, "mmap call failed\n");
         exit(-1);
     }
-- 
cgit v1.2.1


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

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