bytecodealliance / bytecodealliance/wit-bindgen

too many locals: locals exceed maximum when running component new

Aperta
#622 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
gen-rust
Lingua principale
Rust
Stelle
1.5k
Fork
288
Merge medio
6h 32m
PR unite (30g)
19

Descrizione

I'm trying to convert a component but I run into an error when running the following command:
```sh
wasm-tools component new target/wasm32-wasi/debug/fundamental_analyzer_template.wasm -o fundament-component.wasm --adapt wasi_snapshot_preview1.reactor.wasm
```

The error is as follows:
```
error: failed to encode a component from module

Caused by:
0: failed to validate component output
1: too many locals: locals exceed maximum (at offset 0x764c)
```

The error is caused thrown at this line https://github.com/bytecodealliance/wasm-tools/blob/188de0fd412dd01dd41bf91c897935934282c13d/crates/wasmparser/src/validator/operators.rs#L287 and is caused by the `MAX_WASM_FUNCTION_LOCALS` which is set to `50000`.

When I increase the `MAX_WASM_FUNCTION_LOCALS` constant the problem goes away, but it doesn't seem right that I have more than `50000` local functions.

The wasm file is generated based on this wit definition: https://github.com/jeroenvervaeke/wit-issue-reproducer/blob/master/wit/fundaments_analyzer.wit

The full reproducer can be found here: https://github.com/jeroenvervaeke/wit-issue-reproducer
These are the commands to run to if you want to reproduce the issue locally: https://github.com/jeroenvervaeke/wit-issue-reproducer/blob/master/build-component.sh

Do you think this is an issue with the generated WIT code, or is it expected that this many local functions are generated?
If it's expected that so many local functions are generated, should `MAX_WASM_FUNCTION_LOCALS` be increased?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Riproduci il fallimento usando i comandi in build-component.sh e la definizione WIT in wit/fundaments_analyzer.wit. Leggi il codice del validatore wasmparser indicato in crates/wasmparser/src/validator/operators.rs intorno a MAX_WASM_FUNCTION_LOCALS, quindi determina se la causa è il modulo generato o il limite del validatore. Il lavoro è completato quando la conversione del componente del reproducer ha esito positivo oppure il comportamento previsto del limite è documentato con una direzione di correzione confermata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust, wasm
Ambito
compilers, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.