Skip to content

Is it safe to have two exec_envs at the same time? #2381

Answered by wenyongh
NinevskiyK asked this question in Q&A
Discussion options

You must be logged in to vote

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:

#include "core/iwasm/common/wasm_runtime_common.h"
call_worker ()
{
    exec_env_backup = wasm_runtim…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NinevskiyK
Comment options

Answer selected by NinevskiyK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants