Redline: concurrent calls on one Instance silently return wrong values
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
- 45/100
Hướng nghiên cứu
The issue is in the Redline backend's machine state, specifically the argsBuffer, callDepth, TRAP_CODE, and pendingException fields which are shared across threads. Start by examining the machine class and the host-call argument passing mechanism. The goal is to implement a thread-owner check on the outermost call to turn silent corruption into an error, as suggested. Look for the compiled calling convention to understand the context pointer.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Calling one native Instance from several threads returns wrong results with no error. The other backends do not do this: bytecode is correct, and the interpreter throws. Redline is the only one that answers quietly and wrongly.
Eight threads, 2000 calls each, on a shared instance of host-import-roundtrip.wat.wasm, whose callTakeI32 must always return -1:
| Backend | Failed calls | Wrong results |
|---|---|---|
| Interpreter | 16000 / 16000 | 0 |
| Bytecode | 0 / 16000 | 0 |
| Redline (jffi) | 5318 / 16000 | 783 |
Every Redline failure is TrapException: call stack exhausted. The 783 wrong results carried no error at all.
Cause
Per-call state lives in the machine, shared by every thread that enters it, rather than per thread.
argsBufferis one buffer per machine, and host-call arguments pass through it, so one thread reads another's argument.takeI32returns what it was handed, which is where the wrong values come from.callDepthis an unsynchronisedint, sooutermostCallis missed,STACK_LIMITis never re-anchored, and the stack guard fires against a stale limit.TRAP_CODEandpendingExceptionare shared too, so one thread can see and clear another's trap.
Instances are not thread-safe in general and this may simply be unsupported usage. It is filed for the failure mode rather than the usage: silent wrong answers instead of an error.
Suggested fix
Cheap, and worth doing on its own: compare-and-set an owner thread on the outermost call and throw if another thread is already inside. One atomic operation per outermost call, and it turns silent corruption into an actionable error, which is what the interpreter already does in effect.
Real: per-thread context and argument buffers, and a per-thread call depth. Bigger, because the context pointer is part of the compiled calling convention.
Note on #201
The watchdog fix does not cause this, but it does make it visible. Before it, the same probe gave 0 to 3 wrong results rather than 783: starting a thread per call serialised callers enough that most trapped before they could race. The data race is older than the watchdog work; what went away is the throttle that was hiding it.
🤖 Generated with Claude Code
- Ngôn ngữ chính
- Java
- Star
- 306
- Fork
- 20
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 35
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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/endive
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
bytecodealliance/endive#203 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
bytecodealliance/endive#202 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
bytecodealliance/endive#201 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Complete the SIMD integrationĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
bytecodealliance/endive#181 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
bytecodealliance/endive#175 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytecodealliance/endive
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Content
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
RunestoneInteractive/rs#1559 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
inu-appcenter/memorIN-backend#298 ·
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 85/100
opendataloader-project/opendataloader-pdf#757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redhat-developer/intellij-quarkus#1626 ·