tarantool / tarantool/tarantool

JIT fails to allocate mcode memory on M1 for Tarantool

Open
#7,571 0 comments 0 reactions 1 assignee View on GitHub

@Buristan is already working on this.

Since Aug 15, 2022.

arm luajit osx
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

During running JIT-related tests the trace assembling occasionally fails with the following reason in jit.dump output:

failed to allocate mcode memory

This is happens due to none of probed pseudo-random addresses are suited for JIT engine, because all of them are out of LJ_TARGET_JUMPRANGE (+-27Mb). Looks like this happens due to bunch of loaded .dylib libraries (libcurl, libicu, etc.) so all well-suited addresses are already in use and mmap() just returned to big address.

Also, a bunch of problems I faced while trying to resolve the issue:

  1. We can't link with the shared luajit library as far as Tarantool uses internal routines from the luajit, so they won't be provided by the shared library.
  2. On M1 due to security reasons we can't link the final executed binary with -no_pie option:
ld: warning: -no_pie ignored for arm64

As a result, we can't set -image_base for it too:

ld: warning: Linking with PIE, -image_base will be ignored
  1. Looks like there are no analogues of linker scripts for macos (at least I don't find any suited replacements for ld --verbose, -T option), so we can't just add something like the following in the default linker script:
.text.luajit : {
      . = 0x21000000;
      *libluajit.a:*(.text .text.*)
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.