-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initialize WASI stdio handles to invalid for better error handling #4092
base: main
Are you sure you want to change the base?
Conversation
我开始也是用 os_get_invalid_handle 函数,后面发现它返回的是 os_file_handle 类型,而 stdio 是 os_raw_file_handle 类型。 所以我改成下面这样的。 #if WASM_ENABLE_LIBC_WASI != 0 && defined(BH_PLATFORM_WINDOWS) |
c8053b1
to
32e10b9
Compare
32e10b9
to
cf8b932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
core/iwasm/aot/aot_loader.c
Outdated
*/ | ||
module->wasi_args.stdio[0] = -1; | ||
module->wasi_args.stdio[1] = -1; | ||
module->wasi_args.stdio[2] = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In windows platform, the os_raw_file_handle type is defined as HANDLE
type, and the invalid value is INVALID_HANDLE_VALUE
, refer to:
typedef HANDLE os_raw_file_handle; |
HANDLE raw_dir_handle = INVALID_HANDLE_VALUE; |
So here it seems we had better add macro to control the code? Some what like:
#ifndef BH_PLATFORM_WINDOWS
module->wasi_args.stdio[0] = -1;
module->wasi_args.stdio[1] = -1;
module->wasi_args.stdio[2] = -1;
#else
module->wasi_args.stdio[0] = INVALID_HANDLE_VALUE;
module->wasi_args.stdio[1] = INVALID_HANDLE_VALUE;
module->wasi_args.stdio[2] = INVALID_HANDLE_VALUE;
#endif
… handle representation
f93f222
to
e82bd0b
Compare
fix #4081