I64ToI32Lowering: return_call_indirect gets a (func (result unreachable)) type, binary writer hits UNREACHABLE
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 65/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
--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.
- Langage dominant
- WebAssembly
- Étoiles
- 8.7k
- Forks
- 897
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 103
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de WebAssembly/binaryen
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
WebAssembly/binaryen#9135 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 76/100
WebAssembly/binaryen#9018 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
WebAssembly/binaryen#9260 · 5 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 62/100
WebAssembly/binaryen#9257 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
WebAssembly/binaryen#9249 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de WebAssembly/binaryen
Issues similaires
-
bug priority: P2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
arrays asr pass enhancement format I/O low priority
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
Les mainteneurs répondent en général sous 1 jour
-
bug grammar sev-0
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100