wasi-preview1-component-adapter: nonblocking regular-file read returns EAGAIN before host I/O completes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust, wasm
- Lĩnh vực
- backend, operating-systems
Hướng nghiên cứu
Start with the cited crates/wasi/src/p2/filesystem.rs read state and crates/wasi-preview1-component-adapter/src/lib.rs adapter handling and fd_read position update. Reproduce with the standalone C program and Wasmtime commands in the issue, then trace how a regular file’s initial asynchronous read is handled. Done when the first read returns the file byte, the following write preserves the remaining contents, and the relevant tests cover this behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
wasi-preview1-component-adapter: nonblocking regular-file read returns EAGAIN before host I/O completes
Summary
A regular file opened with O_RDWR|O_NONBLOCK immediately returns EAGAIN on its first read. The file position therefore remains zero, and a subsequent write overwrites the first byte. Direct P1 reads 'a' and writes at offset 1.
Confirmed with the standalone C program below, without any custom test driver or trace format. Each lane reproduced the same output 5/5 times in fresh directories on Wasmtime 46.0.0 (Release and Debug), 47.0.2, and 50.0.1. Wasmtime 50.0.1 was the latest upstream release at verification time.
Minimal reproducer (repro.c)
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static void show_file(void) {
char content[17] = {0};
int fd = open("file.txt", O_RDONLY);
ssize_t size = read(fd, content, 16);
printf("file: rv=%zd content=%s\n", size, content);
close(fd);
}
int main(void) {
char byte = 0;
int fd = open("file.txt", O_CREAT | O_TRUNC | O_WRONLY, 0644);
write(fd, "abcdefghijklmnop", 16);
close(fd);
fd = open("file.txt", O_RDWR | O_NONBLOCK);
errno = 0;
ssize_t read_rv = read(fd, &byte, 1);
printf("read: rv=%zd errno=%d (%s) byte=%c\n", read_rv, errno,
strerror(errno), read_rv == 1 ? byte : '?');
errno = 0;
ssize_t write_rv = write(fd, "A", 1);
printf("write: rv=%zd errno=%d (%s)\n", write_rv, errno, strerror(errno));
close(fd);
show_file();
return 0;
}
Exact commands
Run in a new empty directory. The first command downloads the official v50.0.1 command adapter; clang, wasm-tools, and wasmtime must be on the stated paths or adjusted to local installations.
curl -fLO https://github.com/bytecodealliance/wasmtime/releases/download/v50.0.1/wasi_snapshot_preview1.command.wasm
/opt/wasi-sdk/bin/clang --target=wasm32-wasip1 -std=c17 -O2 -Wall -Wextra -Werror repro_rc_nb_read_eagain.c -o repro_p1.wasm
wasm-tools component new repro_p1.wasm --adapt wasi_snapshot_preview1=wasi_snapshot_preview1.command.wasm -o repro_adapter.wasm
wasmtime run --dir . repro_p1.wasm; wasmtime run --dir . repro_adapter.wasm
Expected vs. actual output (Wasmtime 50.0.1)
Direct P1 (expected):
read: rv=1 errno=0 (Success) byte=a
write: rv=1 errno=0 (Success)
file: rv=16 content=aAcdefghijklmnop
Adapter P2 (actual):
read: rv=-1 errno=6 (Resource temporarily unavailable) byte=?
write: rv=1 errno=0 (Success)
file: rv=16 content=Abcdefghijklmnop
Root cause
A host FileInputStream starts in ReadState::Idle. Its nonblocking read starts a blocking task and immediately returns empty Bytes; Waiting also returns empty Bytes (filesystem.rs:116-139). The adapter maps every nonempty request that returns empty bytes to ERRNO_AGAIN (lib.rs:2606-2610). Since no data was returned, fd_read does not advance file.position (lib.rs:1324-1329).
For a regular file, this exposes the initial asynchronous scheduling state as EAGAIN before either file data or a real permission error is available. The same code remains in v50.0.1.
Suggested fix and causal evidence
For regular files, wait for the initial host read to resolve instead of translating Idle/Waiting empty results directly to EAGAIN. A v46 causal patch used this intervention; the EAGAIN and overwrite disappeared 3/3, returned 3/3 after revert. A complete fix also needs the separate cached-input invalidation described in the stale-read issue when testing a subsequent read.
- Ngôn ngữ chính
- Rust
- Star
- 18.9k
- Fork
- 2k
- Merge trung bình
- 1 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 238
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/wasmtime
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bytecodealliance/wasmtime#15536 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bytecodealliance/wasmtime#15455 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wasi-preview1-component-adapter: fd_write does not invalidate cached InputStream, causing stale readsCó thể đã có người làm @dpfens đã nhận 13 ngày trước. Đang mởwasi
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bytecodealliance/wasmtime#15296 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug wasm-proposal:exceptions wasmtime:debugging
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bytecodealliance/wasmtime#14102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wasm-proposal:gc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
bytecodealliance/wasmtime#13808 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytecodealliance/wasmtime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area: plugins bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
clipy-recorder/clipy#1039 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
valkey-io/valkey-glide#7975 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
gofractally/psibase#2379 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Qwen stream parser: a chunk with "error": null is treated as a stream errorCó thể đã có người làm @Beehtrix đã nhận hôm nay. Đang mởarea:models bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
brekkylab/ailoy#681 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày