tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

erlang -> asmjit -> mremap questions/bugs



Hi!

Erlang comes with a JIT: asmjit.

The current version doesn't work with PaX MPROTECT. I filed a bug
report and asmjit added code using mremap().

https://github.com/asmjit/asmjit/blob/master/src/asmjit/core/virtmem.cpp#L619

The asmjit self-tests work, but in erlang with the new version there
are segfaults.

https://github.com/erlang/otp/issues/6909#issuecomment-1446606936

An Erlang developer helped debugging and found weird behaviour:

https://github.com/asmjit/asmjit/issues/399#issuecomment-1448640096

It seems the problem is that mmap() in the mremap(2) man page example
(which was used to implement the asmjit version) is not using
MAP_SHARED.

- I'd like to add MAP_SHARED in the mmap() call in the mremap(2) man
  page example. Is that fine?

- Reading mmap(2) it seems that one of MAP_SHARED or MAP_PRIVATE is
  required, but there is no error if none is provided. Should we change
  mmap() to return an error in that case?

- Why does MAP_PRIVATE (instead of MAP_SHARED) not work?

- Does anyone have an idea why the old asmjit code (shm_open() instead
  of mremap()) might still be working on NetBSD 9 but not on NetBSD
  10.99.2? Both have PaX MPROTECT enabled by default, and the mremap()
  code.

Thanks,
 Thomas


Home | Main Index | Thread Index | Old Index