wasm-micro-runtime
wasm-micro-runtime copied to clipboard
Is `wasm_runtime_module_malloc` thread-safe?
I get strange failures when calling wasm_runtime_module_malloc
with different module instances from multiple threads, does it mean that this function is not thread safe? I use Alloc_With_Allocator
option in RuntimeInitArgs
. It's expected that in may be not thread safe with Alloc_With_Pool
, but if if calls malloc
it should be safe or not?
Also, can Alloc_With_Pool
be used with multiple module instance running at the same time, if allocating will be performed under global mutex? What also should be in critical section?
Hi, how do you build your wasm application ?
If your wasm application are built as LIBC-WASI
mode, you need to hack the wasi-libc
's dlmalloc.o as the dlmalloc
function implemented by wasi-libc is not thread-safe, please refer to Build with libc-WASI
section in pthread_library.md for more details.
If you are using LIBC-BUILTIN
mode, then wasm_runtime_module_malloc
is thread-safe.
Hi, how do you build your wasm application ?
I compile it with Emscripten emcc testapp.c -s STANDALONE_WASM -s ERROR_ON_UNDEFINED_SYMBOLS=0 -O2 -s TOTAL_MEMORY=6MB -o testapp.wasm --no-entry
, but actually no explicit allocations are performed in wasm app.
Ok, I'll try different emcc options or another compiler.