summaryrefslogtreecommitdiff
path: root/gc/default/default.c
diff options
context:
space:
mode:
authorYuta Saito <[email protected]>2025-02-18 16:06:36 +0000
committerYuta Saito <[email protected]>2025-02-19 11:46:12 +0900
commiteac35edfd1101e8f7c34dbdd7b595fdac8f0ad4c (patch)
tree99763c439ee6653313f69d60a01949dc3fd26abd /gc/default/default.c
parent4f7dfbe58ee2915b0724251c6464c9b4e0c34245 (diff)
[wasm] Stop using mprotect(PROT_NONE) on WASI
we had been using a stub weak definition of `mprotect` in wasm/missing.c so far, but wasi-sdk 23 added mprotect emulation to wasi-libc[^1], so the emulation is now linked instead. However, the emulation doesn't support PROT_NONE and fails with ENOSYS, so we need to avoid calling mprotect completely on WASI. [^1]: https://github.com/WebAssembly/wasi-libc/commit/7528b13170462c82e367d91ae0ecead84e470ceb
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12776
Diffstat (limited to 'gc/default/default.c')
-rw-r--r--gc/default/default.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gc/default/default.c b/gc/default/default.c
index 7e0049bb4f..4cf39a0331 100644
--- a/gc/default/default.c
+++ b/gc/default/default.c
@@ -3199,6 +3199,10 @@ protect_page_body(struct heap_page_body *body, DWORD protect)
DWORD old_protect;
return VirtualProtect(body, HEAP_PAGE_SIZE, protect, &old_protect) != 0;
}
+#elif defined(__wasi__)
+// wasi-libc's mprotect emulation does not support PROT_NONE
+enum {HEAP_PAGE_LOCK, HEAP_PAGE_UNLOCK};
+#define protect_page_body(body, protect) 1
#else
enum {HEAP_PAGE_LOCK = PROT_NONE, HEAP_PAGE_UNLOCK = PROT_READ | PROT_WRITE};
#define protect_page_body(body, protect) !mprotect((body), HEAP_PAGE_SIZE, (protect))