RemoveUnusedModuleElements drops an active elem segment whose items are global.get, so call_indirect traps
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Start in src/passes/RemoveUnusedModuleElements.cpp, especially Analyzer::prepare() and notePossibleFunc; the issue identifies the RefFunc-only check and the missing global.get handling. Read the existing pass tests for element segments and add a regression case based on the supplied WAT module. Done means the segment and referenced global are retained as needed, and optimized execution still returns 42 instead of trapping.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
An active element segment whose item is global.get (the "Initializing a table with imported funcref global" case in the spec's elem.wast) is removed by --remove-unused-module-elements and at -O1 and above. The table slot stays null and call_indirect traps.
;; b2.wat
(module
(type $f (func (result i32)))
(import "env" "g" (global $g funcref))
(table 1 funcref)
(elem (i32.const 0) funcref (global.get $g))
(func (export "call") (result i32)
(call_indirect (type $f) (i32.const 0))))
wasm-opt b2.wat --enable-reference-types --remove-unused-module-elements -S -o - prints:
(module
(type $f (func (result i32)))
(table $0 1 funcref)
(export "call" (func $0))
(func $0 (result i32)
(call_indirect $0 (type $f)
(i32.const 0)
)
)
)
The segment and the import are gone. Instantiated in Node.js 26.13.0 with env.g set to a function returning 42:
unoptimized: call() = 42
--remove-unused-module-elements: RuntimeError: function signature mismatch
-O1: RuntimeError: unreachable
The same happens when $g is a defined global initialized with ref.func (with --enable-gc).
Tested with wasm-opt version_133; on main (95a214dc48) the pass differs from version_133 only by the NFC renames in #9286/#9288.
In src/passes/RemoveUnusedModuleElements.cpp, notePossibleFunc in Analyzer::prepare() only looks at item->dynCast<RefFunc>(), so a segment with global.get items never gets into FlatTableInfo::typeElems and is considered unused.
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Credit: https://ucsbplse.github.io/
- Lingua principale
- WebAssembly
- Stelle
- 8.7k
- Fork
- 905
- Merge medio
- 1g 23h
- PR unite (30g)
- 86
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di WebAssembly/binaryen
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
WebAssembly/binaryen#9135 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 76/100
WebAssembly/binaryen#9018 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
WebAssembly/binaryen#9365 ·
I maintainer di solito rispondono entro 1 giorno
-
Add a pass to relax nullabilities of definitionsForse già presa @stevenfontanella l’ha presa 2 giorni fa. Aperta
WebAssembly/binaryen#9352 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
WebAssembly/binaryen#9307 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di WebAssembly/binaryen
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
tree-sitter/tree-sitter-cpp#381 ·
-
[P2] Interpreter: Array.prototype.findLastIndex starts at the wrong index for long array-likesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
new issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
llvm/llvm-project#240065 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
CanadaHonk/porffor#452 ·