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

Handling "Exception: wasi proc exit"

Open nchamzn opened this issue 2 years ago • 3 comments

Hi,

After this change, is an embedder expected to check the exception matches "Exception: wasi proc exit" as iwasm now does to validate if there was an error? How stable can we expect that string to be?

Thanks.

nchamzn avatar Jan 18 '24 10:01 nchamzn

Hi, "wasi proc exit" is a normal behavior and the exception will be cleared by runtime before wasi app main function returns. https://github.com/bytecodealliance/wasm-micro-runtime/blob/8b37048823677d9229b7458b064a515b19744c9c/core/iwasm/common/wasm_application.c#L132-L137 Please use wasm_runtime_get_exception to check whether there was exception thrown.

wenyongh avatar Jan 19 '24 02:01 wenyongh

Hi, sorry - I meant as an embedder so not using iwasm. I think at the moment if we call a wasm function then we are required to check for an exception and then ignore it if it matches "Exception: wasi proc exit"?

nchamzn avatar Jan 19 '24 09:01 nchamzn

Hi, yes, the "wasi proc exit" is only thrown when the wasm app is a wasi module, and it is cleared by runtime if the function to call is "_start" function and developer uses wasm_application_execute_main to call it. If developer calls other functions or calls "_start" function without using wasm_application_execute_main, normally he should ignore the "wasi proc exit" by himself.

wenyongh avatar Jan 19 '24 10:01 wenyongh