Skip to content

use __asyncify in fd_read, allowing signal processing and DL operatio…#6485

Open
Arshia001 wants to merge 7 commits intomainfrom
fix/process-signals-during-fd-read
Open

use __asyncify in fd_read, allowing signal processing and DL operatio…#6485
Arshia001 wants to merge 7 commits intomainfrom
fix/process-signals-during-fd-read

Conversation

@Arshia001
Copy link
Copy Markdown
Member

…ns to happen while waiting for data

This change should resolve both #6472 and #6426.

Description

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_light to __asyncify.
  • Adds an iovec extraction helper to release the MemoryView borrow prior to asyncify.
  • Pumps pending dynamic-link operations while __asyncify work is pending (in SignalPoller).

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.

Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/src/syscalls/mod.rs Outdated
@marxin marxin requested a review from theduke April 24, 2026 07:50
Co-authored-by: Copilot <copilot@github.com>
@Arshia001 Arshia001 force-pushed the fix/process-signals-during-fd-read branch from 48cc729 to 02f13df Compare April 27, 2026 10:00
@Arshia001 Arshia001 requested a review from Copilot April 27, 2026 10:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_read blocking paths (file/socket/pipe) to use __asyncify and refactor iovec handling to avoid holding the MemoryView borrow across asyncify.
  • Improve __asyncify polling to also drive pending link operations and avoid returning EINTR for 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.

Comment thread lib/wasix/tests/wasm_tests/fd_tests/stdin-dlopen-race/build.sh Outdated
Comment thread lib/wasix/tests/wasm_tests/fd_tests/stdin-dlopen-race/build.sh
Comment thread lib/wasix/tests/wasm_tests/mod.rs
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/src/syscalls/wasi/fd_read.rs Outdated
Comment thread lib/wasix/tests/wasm_tests/fd_tests.rs
Arshia001 and others added 3 commits April 27, 2026 17:28
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@Arshia001 Arshia001 enabled auto-merge (squash) April 28, 2026 14:41
@syrusakbary
Copy link
Copy Markdown
Member

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants