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

ruby-changes:69321

From: Jeremy <ko1@a...>
Date: Fri, 22 Oct 2021 00:28:31 +0900 (JST)
Subject: [ruby-changes:69321] 119626da94 (master): Force disable yjit on OpenBSD

https://git.ruby-lang.org/ruby.git/commit/?id=119626da94

From 119626da947bf6492ef7a27abf3bf12de5d0d95a Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 21 Oct 2021 08:02:28 -0700
Subject: Force disable yjit on OpenBSD

TestRubyOptions#test_enable was broken on OpenBSD after the yjit
merge. --yjit (and --enable-all, which enables --yjit) fails on
OpenBSD because yjit uses an insecure mmap call (both writable
and executable), in alloc_exec_mem, which OpenBSD does not allow.

This can probably be reverted if yjit switches to a more secure
mmap design (writable xor executable).  This would involve
initially calling mmap with PROT_READ | PROT_WRITE, and after writing
of executable code has finished, using mprotect to switch to
PROT_READ | PROT_EXEC. I believe Firefox uses this approach for
their Javascript engine since Firefox 46.
---
 ruby.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ruby.c b/ruby.c
index 85ef9cbd80..0a130a3e02 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1871,6 +1871,12 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1871
          */
         rb_warning("-K is specified; it is for 1.8 compatibility and may cause odd behavior");
 
+#ifdef __OpenBSD__
+    /* Disable yjit on OpenBSD, stops --enable-all from failing with:
+       mmap call failed: Not supported */
+    opt->features.set &= ~FEATURE_BIT(yjit);
+#endif
+
 #if USE_MJIT
     if (opt->features.set & FEATURE_BIT(jit)) {
         opt->mjit.on = TRUE; /* set mjit.on for ruby_show_version() API and check to call mjit_init() */
-- 
cgit v1.2.1


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

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