Hi, I've been experimenting more with the pthread API on OSX and noticed that it always crashes on the second os_mprotect
call from:
`static bool init_stack_guard_pages()
. This happens if AOT is enabled (even if not used by the module.
A quick reading online seems to suggest that on OSX mprotect can be used for regions that have been mmapped only.
I didn't do much investigation on this but just to check that I'm not using this the wrong way around before I file a bug.
Hi, the init_stack_guard_pages is required when the memory access boundary check (besides with native stack overflow check) with hardware trap feature is enabled for AOT/JIT, so as to improve the performance. Not sure whether pthread_get_stackaddr_np and pthread_get_stacksize_np in os_thread_get_stack_boundary are called and work well in OSX platform:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/shared/platform/common/posix/posix_thread.c#L339-L341
If not and if it returns NULL, runtime will return false in latest code:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/shared/platform/common/posix/posix_thread.c#L415
And not sure whether the native stack space are pages mmaped? If not, mprotect may report error.
If the feature isn't supported, please disable it:
cmake -DWAMR_DISABLE_HW_BOUND_CHECK=1
wamrc --bounds-checks=1
to generate bound check instructions in AOT codeOk, I'll check if there's something on my side, since i've tested this on OSX and fails on that mprotect call
Last updated: Nov 22 2024 at 16:03 UTC