I64ToI32Lowering: return_call_indirect gets a (func (result unreachable)) type, binary writer hits UNREACHABLE
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Start with the reproducer, wasm-opt -all input.wat --i64-to-i32-lowering, then read visitGenericCall and visitCallIndirect in src/passes/I64ToI32Lowering.cpp, where the new heap type for a return call gets its results. The issue suggests the fix is to take the results from the lowered curr->heapType.getSignature() instead of the unreachable result. Done means the call keeps (type $t), and both binary and text output round-trip through wasm-opt.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
--i64-to-i32-lowering rewrites the type of a return_call_indirect to (func (result unreachable)), even in a module with no i64 at all, so writing a binary aborts and writing text produces a module that does not parse.
(module (type $t (func)) (table 1 funcref) (func $a (return_call_indirect (type $t) (i32.const 0))))
wasm-opt -all input.wat --i64-to-i32-lowering -o /dev/null
unexpected type
UNREACHABLE executed at src/wasm/wasm-binary.cpp:2104!
#1 wasm::handle_unreachable(char const*, char const*, unsigned int) src/support/utilities.cpp:39
#2 wasm::WasmBinaryWriter::writeType(wasm::Type) src/wasm/wasm-binary.cpp:2104
#3 wasm::WasmBinaryWriter::writeTypes() src/wasm/wasm-binary.cpp:307
#4 wasm::WasmBinaryWriter::write() src/wasm/wasm-binary.cpp:63
#5 wasm::ModuleWriter::writeBinary(wasm::Module&, wasm::BufferWithRandomAccess&) src/wasm/wasm-io.cpp:164
With -S -o out.wat instead, wasm-opt exits 0 and writes this, which the same wasm-opt then rejects with out.wat:3:24: error: expected valtype:
(module
(type $t (func))
(type $1 (func (result unreachable)))
(global $i64toi32_i32$HIGH_BITS (mut i32) (i32.const 0))
(table $0 1 funcref)
(func $a (type $t)
(return_call_indirect $0 (type $1)
(i32.const 0)
)
)
)
I expected the call to keep (type $t): the input is valid (wasm-opt without the pass accepts it), there is nothing to lower, and the pass only rejects return calls with i64 results (with a clean Fatal), so other return calls look meant to be supported.
Found at commit 93d6e9de7e1d99be22a49b8952426906a65df397 and still reproduces at 207bbaec4b30. A release build aborts the same way (SIGABRT) on binary output; with text output it exits 0 and writes the invalid module above. The validator does not report anything before writing.
Looks like visitGenericCall in src/passes/I64ToI32Lowering.cpp passes curr->type as the results when the call does not return i64, and for a return call that is unreachable, so visitCallIndirect builds Signature(Type(params), unreachable) as the new heap type; using the lowered curr->heapType.getSignature().results would avoid it.
Found with an LLM-based testing tool; I used Claude to reduce it and look for the cause.
- Ngôn ngữ chính
- WebAssembly
- Star
- 8.7k
- Fork
- 893
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 95
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 WebAssembly/binaryen
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
WebAssembly/binaryen#9135 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 76/100
WebAssembly/binaryen#9018 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Memory64Lowering: table.get/table.set keep i64 index on lowered table64, output fails validationĐang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 66/100
WebAssembly/binaryen#9245 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
WebAssembly/binaryen#9243 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Closed world optimization of wasm modules that have function types in import/export boundaryĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
WebAssembly/binaryen#9237 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của WebAssembly/binaryen
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Default-import note suggests `import * as process` for velt:process, which does not name the builtinĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
diagnostics good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
category:runtime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày