Skip to content

Commit

Permalink
macos: use posix_spawn instead of fork
Browse files Browse the repository at this point in the history
Applications running on hardened runtime based on Chromium/Electron
create mmap regions using MAP_JIT flag. With macOS Big Sur the fork()
calls done by uv_spawn have become slow. This is because fork() seems
to physically copy all JIT memory regions (no-copy-on-write). On
previous OS, these regions weren't accessible at all in the forked
process, explaining the regression.

The fix is to use posix_spawn() on macOS. This spawns a new process
directly, without copying any memory mappings.

Note that fork() is still used on earlier versions of macOS if the
necessary posix_spawn() platform-specific extensions are not available.

Fixes: libuv#3050
PR-URL: libuv#3064
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
  • Loading branch information
jpcanepa authored and pdesantis committed Feb 3, 2021
1 parent 9c3d692 commit 39968db
Showing 1 changed file with 487 additions and 11 deletions.
Loading

0 comments on commit 39968db

Please sign in to comment.