summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-10-21 08:02:28 -0700
committerJeremy Evans <code@jeremyevans.net>2021-10-21 08:26:02 -0700
commit119626da947bf6492ef7a27abf3bf12de5d0d95a (patch)
tree26401d6e0126d03a193c15a01781ef152017f670
parentd74f1e1623a622b2e880e7043857e13b5919c47e (diff)
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.
-rw-r--r--ruby.c6
1 files changed, 6 insertions, 0 deletions
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)
*/
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() */