wasm-micro-runtime: TSAN fast interpreter failure
During PoC of #2679 I’ve found another data race in exception handling https://gist.github.com/Zzzabiyaka/dcad23be15bad484966e91b8da3d659a.
set_exception_visitor in the stacktrace makes me suspicious about #2509. @yamt, would you be able to look into that issue ?
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- wasm_exec_env_set_module_inst: grab cluster->lock fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2680 — committed to yamt/wasm-micro-runtime by yamt 8 months ago
- Grab `cluster->lock` when modifying `exec_env->module_inst` (#2685) Fixes: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2680 And when switching back to the original module_inst, p... — committed to bytecodealliance/wasm-micro-runtime by yamt 8 months ago
- Remove TSAN suppression for execute_post_instantiate_functions (#2741) The problem has been fixed: #2680. — committed to bytecodealliance/wasm-micro-runtime by eloparco 8 months ago
these functions propagate an exception via the return value. while we should propagate it to the original module_inst at least for the purpose of wasm_runtime_terminate, i’m not sure if it’s appropriate for existing users of the api. i need to think about it a bit more. (thus the PR is a draft)
This seems to be because that before creating a new thread, runtime will instantiate the module instance for it (and do the instantiation in the parent thread), and at the end of instantiating, runtime executes the
startof the module, and to make the exec_env consistent with the exec_envs in the parent thread’s call stack, runtime temporarily replaceexec_env->module_instwith the child module instance.There may be two options: (1) since the
startfunction has been called in the main thread in the first time instantiation, we don’t call it again in the later instantiation, (2) addcluster->lockfor replacingexec_env->module_inst, executing start and restoring theexec_env->module_instin the later instantiation.@yamt how do think?