wasip1-adapter: expired absolute REALTIME timeout returns EOVERFLOW
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
- #15459 của @kutluhaneth46 — đã đóng, không merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 74/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
- operating-systems
Hướng nghiên cứu
The bug is in poll_oneoff in crates/wasi-preview1-component-adapter/src/lib.rs (around lines 2183-2214), where the absolute REALTIME timestamp is subtracted from now without saturation. Start by compiling the issue's C reproducer to a wasm32-wasip1 module, adapting it with wasm-tools, and running it under wasmtime to see the EOVERFLOW result. Done when an already-expired absolute REALTIME subscription returns errno 0 with one successful event, and the future-absolute and relative cases still behave as before.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment
- Wasmtime v50.0.1 (
c307ec81de02852d815e9849f7c89d955c03c30d), x86_64 Linux wasi_snapshot_preview1.command.wasmshipped with v50.0.1- The same
poll_oneoffimplementation is present on currentmain(fb792bf7a143801c22c0ba5b16fe2c6085a8598b) atcrates/wasi-preview1-component-adapter/src/lib.rs:2183-2214.
Summary and root cause
An already-expired absolute CLOCKID_REALTIME subscription returns EOVERFLOW through the WASIp1 adapter instead of completing immediately. Future absolute and relative REALTIME subscriptions work normally.
In poll_oneoff, the adapter subtracts now.seconds from the unsigned datetime.seconds without saturation. For an expired timestamp this wraps, and the subsequent checked conversion to nanoseconds fails. The resulting error is surfaced as EOVERFLOW.
Minimal reproducer
#include <wasi/api.h>
#include <stdio.h>
#include <string.h>
static void poll_clock(__wasi_timestamp_t timeout, int absolute) {
__wasi_subscription_t s;
__wasi_event_t event = {0};
__wasi_size_t count = 99;
memset(&s, 0, sizeof(s));
s.u.tag = __WASI_EVENTTYPE_CLOCK;
s.u.u.clock.id = __WASI_CLOCKID_REALTIME;
s.u.u.clock.timeout = timeout;
if (absolute)
s.u.u.clock.flags = __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME;
__wasi_errno_t e = __wasi_poll_oneoff(&s, &event, 1, &count);
printf("absolute=%d errno=%u count=%lu event_error=%u\n",
absolute, e, (unsigned long)count, event.error);
}
int main(void) {
__wasi_timestamp_t timestamp = 0;
__wasi_errno_t e = __wasi_clock_time_get(__WASI_CLOCKID_REALTIME, 1, ×tamp);
if (e != __WASI_ERRNO_SUCCESS)
return 2;
poll_clock(1, 1);
poll_clock(timestamp + 10000000ULL, 1);
poll_clock(1000000ULL, 0);
return 0;
}
"$WASI_SDK_PATH/bin/clang" --target=wasm32-wasip1 -O1 poll_realtime.c -o poll_realtime.p1.wasm
wasm-tools component new poll_realtime.p1.wasm \
--adapt wasi_snapshot_preview1=wasi_snapshot_preview1.command.wasm \
-o poll_realtime.adapter.wasm
wasmtime run -S preview2=y -S inherit-env=n poll_realtime.p1.wasm
wasmtime run -S preview2=y -S inherit-env=n poll_realtime.adapter.wasm
Actual output
Direct WASIp1:
absolute=1 errno=0 count=1 event_error=0
absolute=1 errno=0 count=1 event_error=0
absolute=0 errno=0 count=1 event_error=0
Adapter P2:
absolute=1 errno=61 count=0 event_error=0
absolute=1 errno=0 count=1 event_error=0
absolute=0 errno=0 count=1 event_error=0
Both results were stable across three runs. The first row uses timestamp 1; the second uses an absolute timestamp 10 ms in the future; the third uses a 1 ms relative timeout.
Expected output
The expired absolute timeout should complete immediately with errno=0 and one successful event, as it does with Direct WASIp1.
Suggested fix
Use a saturating conversion from the absolute wall-clock timestamp to a relative duration. Compare the complete (seconds, nanoseconds) pair with now before subtracting, so a timestamp already expired within the current second also produces zero. Avoid unsigned subtraction before checking whether the timestamp has expired.
- 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