Skip to content

Print an error on async stack overflow #9304

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

Merged

Conversation

alexcrichton
Copy link
Member

This commit updates Wasmtime's handling of traps on Unix platforms to print an error message on stack overflow when the guard page is hit. This is distinct from stack overflow in WebAssembly which raises a normal trap and can be caught. This is instead to be used on misconfigured hosts where the async stack is too small or wasm was allowed to take up too much of the async stack. Currently no error message is printed and the program simply aborts with a core dump which can be difficult to debug.

This instead registers the range of the async guard page with the trap handling infrastructure to test the faulting address and if it lies within this range. If so then a small message is printed and then the program is aborted with libc::abort().

This does not impact the safety of any prior embedding or fix any issues. It's instead intended purely as a diagnostic tool to help users more quickly understand that stack size configuration settings are the likely culprit.

@alexcrichton alexcrichton requested a review from a team as a code owner September 24, 2024 20:18
@alexcrichton alexcrichton requested review from elliottt and removed request for a team September 24, 2024 20:18
@alexcrichton
Copy link
Member Author

This is inspired by #9298 where stack overflows on the CLI in async fibers might be more common now.

@github-actions github-actions bot added wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API. labels Sep 24, 2024
This commit updates Wasmtime's handling of traps on Unix platforms to
print an error message on stack overflow when the guard page is hit.
This is distinct from stack overflow in WebAssembly which raises a
normal trap and can be caught. This is instead to be used on
misconfigured hosts where the async stack is too small or wasm was
allowed to take up too much of the async stack. Currently no error
message is printed and the program simply aborts with a core dump which
can be difficult to debug.

This instead registers the range of the async guard page with the trap
handling infrastructure to test the faulting address and if it lies
within this range. If so then a small message is printed and then the
program is aborted with `libc::abort()`.

This does not impact the safety of any prior embedding or fix any
issues. It's instead intended purely as a diagnostic tool to help users
more quickly understand that stack size configuration settings are the
likely culprit.
@alexcrichton alexcrichton force-pushed the print-async-stack-overflow branch from ae22051 to 770efaa Compare September 25, 2024 14:38
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all seems reasonable to me!

@alexcrichton alexcrichton added this pull request to the merge queue Sep 26, 2024
Merged via the queue into bytecodealliance:main with commit 110e70f Sep 26, 2024
127 checks passed
@alexcrichton alexcrichton deleted the print-async-stack-overflow branch September 26, 2024 04:27
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Sep 30, 2024
This commit fixes an issue with bytecodealliance#9304 where the asan build of
`wasmtime-fiber` has broken which was preventing oss-fuzz from updating
and making progress.
github-merge-queue bot pushed a commit that referenced this pull request Sep 30, 2024
This commit fixes an issue with #9304 where the asan build of
`wasmtime-fiber` has broken which was preventing oss-fuzz from updating
and making progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants