WebAssembly / WASI

WebAssembly System Interface
Other
4.72k stars 240 forks source link

failed to parse export section, effective type size too large #518

Closed Finfalter closed 1 year ago

Finfalter commented 1 year ago

A custom generator generates functions (in Rust) in order to put them in a WASI module. All functions must be visible from the outside and, thus, shall be exported. In order to do so, the Rust code is accompanied by a corresponding .wit file. The code is built by

cargo wasi build --release

Given the number of exported functions exceeds a certain threshold (~20,000), I get the following error:

error: failed to process wasm at ../my_module.rustc.wasm

Caused by:
    failed to parse export section

Caused by:
    effective type size too large (at offset 911791)`

Is there a limit for type size? What is the limit? Can I increase it?

pchickey commented 1 year ago

Implementations end up limiting type sizes, and the sizes of many other tree-shaped ast nodes, to limit the amount of resources (memory, time) consumed when parsing and validating a binary, which is potentially malicious input.

This issue is specific to an implementation and belongs in bytecodealliance/wasm-tools, can you please refile it there?

Finfalter commented 1 year ago

I did. Thank you very much for your feedback!