Fuzzer: DAE generates invalid code
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 47/100
Rechercherichtung
Start with src/passes/DeadArgumentElimination.cpp and the dae-optimizing pass; reproduce the validator failure using the reduced WAT and command in the issue. Trace how callers are tracked when call_ref becomes a direct call, and check whether the enclosing expression is re-finalized after return-type refinement. Done means the reduced case validates after the pass and relevant tests pass.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Run from the latest main bee0b57. Reduced WAT:
(module
(rec
(type $0 (sub (shared (func (result (ref null $1))))))
(type $1 (sub (shared (array f32))))
(type $2 (sub $0 (shared (func (result (ref null $1))))))
(type $3 (sub (struct)))
(type $4 (func (param (ref null $2)) (result f64)))
(type $5 (func (result (ref $6))))
(type $6 (shared (func (param (ref $3)) (result v128))))
(type $7 (func))
)
(elem declare func $1 $2)
(func $1 (type $6) (param $0 (ref $3)) (result v128)
(unreachable)
)
(func $2 (type $5) (result (ref $6))
(unreachable)
)
(func $3 (type $5) (result (ref $6))
(local $10 i32)
(select (result (ref $6))
(call_ref $5
(ref.func $2)
)
(ref.func $1)
(stringview_wtf16.get_codeunit
(string.const "\e2\82\ac")
(block (result i32)
(local.set $10
(i32.const 1)
)
(local.get $10)
)
)
)
)
(func $4 (type $7)
(drop
(call $3)
)
)
)
Command:
BINARYEN_PASS_DEBUG=1 bin/wasm-opt -all --closed-world --dae-optimizing fuzzed.wat
Output:
[wasm-validator error in function 3] stale type found in 3 on 0x561b46e160d8
(marked as (ref $func.0), should be (ref (exact $func.0)))
, on
(select (result (ref (exact $6)))
(call $2)
(ref.func $1)
(stringview_wtf16.get_codeunit
(string.const "\e2\82\ac")
(i32.const 1)
)
)
Fatal: Last pass (dae-optimizing) broke validation.
Replacing the call_ref with a direct call $2 makes the bug go away.
AI-generated hypothesis
In DeadArgumentElimination.cpp:
callersis computed once, from directCalls only. Initially$3reaches$2only viacall_ref, socallers[$2] = {}.- Iteration 1:
$4drops$3's result, soremoveReturnValue($3)runs and$3goes intoworthOptimizing.optimizeAfterInliningthen rewritescall_ref (ref.func $2)intocall $2. - Iteration 2:
$2now has a seen direct call, sorefineReturnTypes($2)refines its result to(ref (shared nofunc))and updates theCall's type.refinedCallersis populated from the stalecallers[$2], which is empty, so$3is neverReFinalized. The enclosingselectkeeps(ref $6)while its LUB is now(ref (exact $6)).
The comment above callers says over-approximating it is safe; this is an under-approximation, since new direct callers appear mid-pass via devirtualization.
- Vorherrschende Sprache
- WebAssembly
- Sterne
- 8.7k
- Forks
- 897
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 103
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus WebAssembly/binaryen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
WebAssembly/binaryen#9135 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 76/100
WebAssembly/binaryen#9018 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
WebAssembly/binaryen#9260 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
WebAssembly/binaryen#9257 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
WebAssembly/binaryen#9249 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in WebAssembly/binaryen
Ähnliche Issues
-
bug priority: P2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug grammar sev-0
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
-
crash lld:MachO
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
llvm/llvm-project#233265 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag