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).

  • Defaulted to memfd-backed mappings where available
    • 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.
    • Anonymous maps are a last resort, but they must be rwx because they do not allow multiple views (see !189 (comment 2519148)).
  • 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!

Fixes #1

Edited by amyspark

Merge request reports

Loading