-
Notifications
You must be signed in to change notification settings - Fork 613
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
Add wasm_runtime_detect_native_stack_overflow_size #3355
Add wasm_runtime_detect_native_stack_overflow_size #3355
Conversation
yamt
commented
Apr 25, 2024
•
edited
Loading
edited
- Add a few API (per-host function override of native stack requirement #3325)
- Adapt the runtime to use them
- Adapt samples/native-stack-overflow to use them
- Add a few missing overflow checks in the interpreters
- build and run the sample on the CI
c2976a3
to
dd6e020
Compare
windows failure looks like #2776 macos failure looks unrelated:
|
The two CIs were re-run and are OK now. |
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 with minor issues
core/iwasm/include/wasm_export.h
Outdated
* Otherwise, raise a "native stack overflow" trap and returns false. | ||
* | ||
* Note: please do not expect a very strict detection. it's a good idea | ||
* to give some margins. wasm_runtime_detect_native_stack_overflow itslf |
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.
Had better itself
core/iwasm/include/wasm_export.h
Outdated
* Ensure that the calling thread still has a reasonable amount of | ||
* native stack (WASM_STACK_GUARD_SIZE bytes) available. | ||
* | ||
* If enough stack is left, returns true. |
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.
had better returns
-> return
?
core/iwasm/include/wasm_export.h
Outdated
* native stack (WASM_STACK_GUARD_SIZE bytes) available. | ||
* | ||
* If enough stack is left, returns true. | ||
* Otherwise, raise a "native stack overflow" trap and returns false. |
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.
had better returns
-> return
?
dd6e020
to
e0eb25f
Compare
force pushed to resolve a conflict with #3358 |
this changes the accounting by one small function call. i don't think it can cause real problems though.
…verflow replace homegrown check.
This allows each native function to require more native stack. cf. bytecodealliance#3325
To avoid: LLVM ERROR: Only small, tiny and large code models are allowed on AArch64
as i have no good way to debug right now. the failure seen on the CI: ``` ====== Interpreter test1 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 24576 | failed | ok | Exception: native stack overflow ====== Interpreter WAMR_DISABLE_HW_BOUND_CHECK=1 test1 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 3568 | failed | ok | Exception: native stack overflow 3568 - 24576 | failed | ok | Exception: wasm operand stack overflow ====== AOT test1 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 24576 | failed | ok | Exception: native stack overflow ====== AOT WAMR_DISABLE_HW_BOUND_CHECK=1 test1 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 4000 | failed | ok | Exception: native stack overflow 4000 - 24576 | ok | ok | ====== Interpreter test2 stack size | fail? | leak? | exception --------------------------------------------------------------------------- 0 - 24576 | failed | ok | Exception: native stack overflow ====== Interpreter WAMR_DISABLE_HW_BOUND_CHECK=1 test2 ./run.sh: line 12: 14708 Segmentation fault: 11 out/native-stack-overflow.WAMR_DISABLE_HW_BOUND_CHECK out/wasm-apps/testapp.wasm ${NAME} ```
fix an infinite loop in consume_stack1
e971376
to
6196f1c
Compare
rebased after #3366 |
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI Signed-off-by: victoryang00 <[email protected]>
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI Signed-off-by: victoryang00 <[email protected]>
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI Signed-off-by: victoryang00 <[email protected]>
…3355) - Add a few API (bytecodealliance#3325) ```c wasm_runtime_detect_native_stack_overflow_size wasm_runtime_detect_native_stack_overflow ``` - Adapt the runtime to use them - Adapt samples/native-stack-overflow to use them - Add a few missing overflow checks in the interpreters - Build and run the sample on the CI Signed-off-by: victoryang00 <[email protected]>