Is it safe to have two exec_env
s at the same time?
#2381
-
Let's assume we have The only problem here is with Why do we need this strange variable? I've only found that it is used to handle signals, but if I'm not aiming to signal wasm modules, will it affect somehow in another way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, using exec_env_tls is due to using hardware trap to implement boundary check of linear memory access: Maybe you can temporarily save the exec_env_tls before calling worker wasm module, and restore it after calling: #include "core/iwasm/common/wasm_runtime_common.h"
call_worker ()
{
exec_env_backup = wasm_runtime_get_exec_env_tls();
wasm_runtime_set_exec_env_tls(NULL);
call worker wasm module
wasm_runtime_set_exec_env_tls(exec_env_backup );
} |
Beta Was this translation helpful? Give feedback.
Hi, using exec_env_tls is due to using hardware trap to implement boundary check of linear memory access:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/build_wamr.md#disable-boundary-check-with-hardware-trap
Since when out of bounds memory access occurs, the signal handler will be triggered to handle it, and inside the signal handler, there is no good way to know the exec_env of current thread, we store it into thread local storage to retrieve it quickly.
Maybe you can temporarily save the exec_env_tls before calling worker wasm module, and restore it after calling: