wasm-micro-runtime icon indicating copy to clipboard operation
wasm-micro-runtime copied to clipboard

Failure to create a thread - min stack size

Open simon-hrabec opened this issue 8 months ago • 0 comments

I run WASM code on a Raspberry Pi 4 (ARM64, using their OS but with the RT patch) using WAMR, and my WASM code fails when it tries to create a new thread (unlike with Wasmtime and Wasmer).

It fails on this specific line - https://github.com/bytecodealliance/wasm-micro-runtime/blob/73914caa9b05cd702232aa719410b44143385061/core/shared/platform/common/posix/posix_thread.c#L67

Note that PTHREAD_STACK_MIN is a compile-time constant. And the stack_size value comes from here https://github.com/bytecodealliance/wasm-micro-runtime/blob/73914caa9b05cd702232aa719410b44143385061/core/iwasm/common/wasm_runtime_common.c#L4824 and is also a compile-time constant.

I believe I either compiled the iwasm wrong or there is an issue in the config file https://github.com/bytecodealliance/wasm-micro-runtime/blob/73914caa9b05cd702232aa719410b44143385061/core/config.h#L394 In my specific case PTHREAD_STACK_MIN is defined but PTHREAD_STACK_DEFAULT is not. This then leaves APP_THREAD_STACK_SIZE_DEFAULT to be (64 * 1024), which is smaller than PTHREAD_STACK_MIN.

Changing the config.h fixed the issue for me and I was able to run my code.

simon-hrabec avatar Dec 04 '23 04:12 simon-hrabec