From b5563f638f28741c304f708c3da58469c3f8988e Mon Sep 17 00:00:00 2001 From: Matin Zadehdolatabad Date: Mon, 8 Feb 2021 17:22:37 +0330 Subject: [PATCH 1/2] deps: V8: Workaround MacOS 11.2 code page decommit failures [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 Commit-Queue: Michael Lippautz Auto-Submit: Jakob Kummerow Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/heads/master@{#72559} Related issue #37061 --- deps/v8/src/base/platform/platform-posix.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deps/v8/src/base/platform/platform-posix.cc b/deps/v8/src/base/platform/platform-posix.cc index 68d651b15fefdc..f1ba13de0a4486 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)); From 45dee7d7f076e9654226117ab22aa58cc40492ce Mon Sep 17 00:00:00 2001 From: matinzd Date: Tue, 9 Feb 2021 14:22:04 +0330 Subject: [PATCH 2/2] bump: v8: v8_embedder_string to 25 --- common.gypi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.gypi b/common.gypi index 7c7ece7a381d6b..80c2395cbdec20 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.24', + 'v8_embedder_string': '-node.25', ##### V8 defaults for Node.js #####