diff options
author | Matin Zadehdolatabad <zadehdolatabad@gmail.com> | 2021-02-08 17:22:37 +0330 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-02-11 19:11:49 +0100 |
commit | 530ef9150984301d98a60bf6620c65044f7dbf57 (patch) | |
tree | f8128f74c7e7fc18ea0e1dd33d04bf0d8a5c2048 | |
parent | 73e0245a161b531957caf80bb113ac9e7329a9db (diff) | |
download | node-new-530ef9150984301d98a60bf6620c65044f7dbf57.tar.gz |
deps: V8: cherry-pick 0c8b6e415c30
Original commit message:
[mac][wasm] Work around MacOS 11.2 code page decommit failures
MacOS 11.2 refuses to set "no access" permissions on memory that
we previously used for JIT-compiled code. It is still unclear
whether this is WAI on the part of the kernel. In the meantime,
as a workaround, we use madvise(..., MADV_FREE_REUSABLE) instead
of mprotect(..., NONE) when discarding code pages. This is inspired
by what Chromium's gin platform does.
Fixed: v8:11389
Change-Id: I866586932573b4253002436ae5eee4e0411c45fc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2679688
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72559}
Refs: https://github.com/v8/v8/commit/0c8b6e415c3020a987d2287f1543d629cd993535
Fixes: https://github.com/nodejs/node/issues/37061
PR-URL: https://github.com/nodejs/node/pull/37276
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ash Cripps <acripps@redhat.com>
-rw-r--r-- | common.gypi | 2 | ||||
-rw-r--r-- | deps/v8/src/base/platform/platform-posix.cc | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/common.gypi b/common.gypi index 7fb2a5f99b..3d030895b0 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.21', + 'v8_embedder_string': '-node.22', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index ab0d7839a4..67746173d5 100644 --- a/deps/v8/src/base/platform/platform-posix.cc +++ b/deps/v8/src/base/platform/platform-posix.cc @@ -415,6 +415,16 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { int prot = GetProtectionFromMemoryPermission(access); int ret = mprotect(address, size, prot); + + // MacOS 11.2 on Apple Silicon refuses to switch permissions from + // rwx to none. Just use madvise instead. +#if defined(V8_OS_MACOSX) + if (ret != 0 && access == OS::MemoryPermission::kNoAccess) { + ret = madvise(address, size, MADV_FREE_REUSABLE); + return ret == 0; + } +#endif + if (ret == 0 && access == OS::MemoryPermission::kNoAccess) { // This is advisory; ignore errors and continue execution. USE(DiscardSystemPages(address, size)); |