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

ruby-changes:74061

From: Tatsuya <ko1@a...>
Date: Tue, 18 Oct 2022 01:26:55 +0900 (JST)
Subject: [ruby-changes:74061] 07a93b1e37 (master): YJIT: Do not call `mprotect` when `mem_size` is zero (#6563)

https://git.ruby-lang.org/ruby.git/commit/?id=07a93b1e37

From 07a93b1e378bf2ea356b0561e5e89e60d30fc684 Mon Sep 17 00:00:00 2001
From: Tatsuya Kawano <tatsuya@h...>
Date: Tue, 18 Oct 2022 00:26:36 +0800
Subject: YJIT: Do not call `mprotect` when `mem_size` is zero (#6563)

This allows x86_64 based YJIT to run on Docker Desktop on Apple silicon (arm64)
Mac because it will avoid a subtle behavior difference in `mprotect` system call
between the Linux kernel and `qemu-x86_64` user space emulator.
---
 yjit.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/yjit.c b/yjit.c
index 838956f7b4..a53e2ca709 100644
--- a/yjit.c
+++ b/yjit.c
@@ -74,6 +74,11 @@ rb_yjit_mark_writable(void *mem_block, uint32_t mem_size) https://github.com/ruby/ruby/blob/trunk/yjit.c#L74
 void
 rb_yjit_mark_executable(void *mem_block, uint32_t mem_size)
 {
+    // Do not call mprotect when mem_size is zero. Some platforms may return
+    // an error for it. https://github.com/Shopify/ruby/issues/450
+    if (mem_size == 0) {
+        return;
+    }
     if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
         rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s\n",
             mem_block, (unsigned long)mem_size, strerror(errno));
-- 
cgit v1.2.3


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

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