use __asyncify in fd_read, allowing signal processing and DL operatio…#6485
use __asyncify in fd_read, allowing signal processing and DL operatio…#6485
Conversation
…ns to happen while waiting for data
There was a problem hiding this comment.
Pull request overview
Updates WASIX fd_read to use the signal/DL-operation-aware asyncify path so that blocking reads can be interrupted (EINTR) and dynamic linking work can continue while waiting for input, addressing reported hangs and missed signal handling.
Changes:
- Switches
fd_read’s file/socket/pipe read paths from__asyncify_lightto__asyncify. - Adds an iovec extraction helper to release the
MemoryViewborrow prior to asyncify. - Pumps pending dynamic-link operations while
__asyncifywork is pending (inSignalPoller).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| lib/wasix/src/syscalls/wasi/fd_read.rs | Refactors fd_read to run under __asyncify and restructures iovec handling to avoid holding a MemoryView borrow across asyncify. |
| lib/wasix/src/syscalls/mod.rs | Ensures pending dynamic-link operations are processed while __asyncify is polling pending work. |
Co-authored-by: Copilot <copilot@github.com>
48cc729 to
02f13df
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates WASIX fd_read to use the signal/DL-operation aware asyncify path while blocked, aiming to prevent deadlocks during dynamic library operations and allow signal processing to interrupt blocking reads (resolving #6472 and #6426).
Changes:
- Switch
fd_readblocking paths (file/socket/pipe) to use__asyncifyand refactor iovec handling to avoid holding theMemoryViewborrow across asyncify. - Improve
__asyncifypolling to also drive pending link operations and avoid returningEINTRfor wakeup-only signals. - Add a regression test module (
stdin-dlopen-race) plus a Rust harness helper to run wasm with a custom stdin that never EOFs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/wasix/src/syscalls/wasi/fd_read.rs | Refactors fd_read to use __asyncify and introduces raw-pointer iovec extraction to enable exclusive ctx during asyncify. |
| lib/wasix/src/syscalls/mod.rs | Ensures asyncify polling drives pending link operations and refines signal handling to avoid spurious EINTR on wakeups. |
| lib/wasix/tests/wasm_tests/mod.rs | Adds run_wasm_with_stdin helper for tests that need a non-EOF stdin source. |
| lib/wasix/tests/wasm_tests/fd_tests.rs | Adds a regression test ensuring a blocking stdin read doesn’t deadlock dlopen. |
| lib/wasix/tests/wasm_tests/fd_tests/stdin-dlopen-race/main.c | New wasm guest program reproducing the stdin-read vs dlopen deadlock scenario. |
| lib/wasix/tests/wasm_tests/fd_tests/stdin-dlopen-race/side.c | Minimal shared library for the dlopen regression test. |
| lib/wasix/tests/wasm_tests/fd_tests/stdin-dlopen-race/build.sh | Build script for compiling the new regression test artifacts. |
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
|
I'm a bit concerned on this one, doing a asyncify into each read might introduce a lot of slowdown. Do you think that will be the case @Arshia001 ? |
…ns to happen while waiting for data
This change should resolve both #6472 and #6426.
Description