Skip to content

Overhaul JIT memory management

amyspark requested to merge amyspark/orc:mmap-fix-protection into main

Hi all,

This is a MR to discuss (and probably address) the issues we found in !176 (merged).

  • Removed all the extra approaches to mappings creation in favour of only anonymous mappings
    • This spares us from going through all of the options, which will fail with noexec mounts anyway.
    • It also removes the leak of the temporary file.
  • Fixed the mmap(2) calls to be rw, not rwx
    • This issue is already the subject of the execmem SELinux policy.
  • Implemented cache flushing for Windows x86
    • This was already required by VirtualProtect and implemented by Seungha for Arm
  • Fixed a potential VirtualAlloc crash caused by passing a size of 0 to the allocation call
    • This was previously overridden by the default 65k mapping size
    • Also includes logging the error as it happens
  • Removed the chunk management in favour of a single mapping per program
    • This may be inefficient, but has the big advantage of allowing us to properly free the OrcPrograms along with the mappings they use, and remove the need for accessing the global lock
  • Unpublished the global lock functions
    • There are no more uses after this, except during the library initialisation 🎉

Let me know what you think!

Merge request reports