mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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.
This commit is contained in:
parent
ad3d210bea
commit
07a93b1e37
Notes:
git
2022-10-17 16:26:56 +00:00
Merged-By: maximecb <maximecb@ruby-lang.org>
1 changed files with 5 additions and 0 deletions
5
yjit.c
5
yjit.c
|
@ -74,6 +74,11 @@ rb_yjit_mark_writable(void *mem_block, uint32_t mem_size)
|
||||||
void
|
void
|
||||||
rb_yjit_mark_executable(void *mem_block, uint32_t mem_size)
|
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)) {
|
if (mprotect(mem_block, mem_size, PROT_READ | PROT_EXEC)) {
|
||||||
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s\n",
|
rb_bug("Couldn't make JIT page (%p, %lu bytes) executable, errno: %s\n",
|
||||||
mem_block, (unsigned long)mem_size, strerror(errno));
|
mem_block, (unsigned long)mem_size, strerror(errno));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue