You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The binary format for WebAssembly defines function locals as a counts of a type to define contiguous sets of typed indices. The s-expression text format for WebAssembly, however, does not have an anlogue of this form and requires that each local is defined individually with its type. For example where the binary format says "I have 5 i32 locals" the text format has to say (local i32 i32 i32 i32 i32).
I work on a binary-to-text printer called wasmprinter in Rust and this printer is additionally fuzzed. Fuzzing historically has brought up that "I have 4 billion i32 locals" is a valid wasm module to print but takes gigabytes more space to print than it does to hold the binary format in memory. For this reason I've matched our validator's limits where the printer will print up to 50k locals before returning an error.
This typically works fine but recent I was working with a wasm module that was failing to validate because it had too many locals in a function. I wanted to print the module to scan over and see if I could see what was going on, but I ended up being unable to print the module due to this restriction as well. While I ended up fixing my issue by debugging via other means, this is what leads me to this issue's feature request.
It would be nice to have textual syntax in the s-expression format for "there are N locals of type T" to mirror the capability of the binary format. This wouldn't have to be used by text printers and the current format could still be used, but if a function says it has 4 million locals it would be helpful to print one item instead of four million items.
The text was updated successfully, but these errors were encountered:
The binary format for WebAssembly defines function locals as a counts of a type to define contiguous sets of typed indices. The s-expression text format for WebAssembly, however, does not have an anlogue of this form and requires that each local is defined individually with its type. For example where the binary format says "I have 5
i32
locals" the text format has to say(local i32 i32 i32 i32 i32)
.I work on a binary-to-text printer called
wasmprinter
in Rust and this printer is additionally fuzzed. Fuzzing historically has brought up that "I have 4 billioni32
locals" is a valid wasm module to print but takes gigabytes more space to print than it does to hold the binary format in memory. For this reason I've matched our validator's limits where the printer will print up to 50k locals before returning an error.This typically works fine but recent I was working with a wasm module that was failing to validate because it had too many locals in a function. I wanted to print the module to scan over and see if I could see what was going on, but I ended up being unable to print the module due to this restriction as well. While I ended up fixing my issue by debugging via other means, this is what leads me to this issue's feature request.
It would be nice to have textual syntax in the s-expression format for "there are N locals of type T" to mirror the capability of the binary format. This wouldn't have to be used by text printers and the current format could still be used, but if a function says it has 4 million locals it would be helpful to print one item instead of four million items.
The text was updated successfully, but these errors were encountered: