Check for too many arguments to convertJsFunctionToWasm signature by hoodmane · Pull Request #16653 · emscripten-core/emscripten (original) (raw)
Yeah so the type section generated is invalid. If I generate a valid wasm file with a 123-argument function and run wasm-objdump --debug
on it I see something like:
BeginModule(version: 1)
BeginTypeSection(128)
OnTypeCount(1)
OnFuncType(index: 0, params: [i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32], results: [i32])
EndTypeSection
If I run wasm-objdump --debug
on the wasm generated by convertJsFunctionToWasm
for 122 argument function I see:
BeginModule(version: 1)
BeginTypeSection(127)
OnTypeCount(1)
OnFuncType(index: 0, params: [i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32], results: [i32])
EndTypeSection
If I try it on the 123 argument output I get:
BeginModule(version: 1)
BeginTypeSection(128)
OnTypeCount(96)
000000d: error: unexpected type form (got -0x5)
Note that it thinks there are 96 = 0x60 types. 0x60 is the prefix of a function type.
https://webassembly.github.io/spec/core/binary/types.html#function-types