Skip to content

too many locals: locals exceed maximum when running component new #622

@jeroenvervaeke

Description

@jeroenvervaeke

I'm trying to convert a component but I run into an error when running the following command:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions