-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functions with extermely long names can cause wasm-bindgen to fail to locate the main function #3362
Comments
Huh, that's strange. The limit on function name lengths in But I'm not sure why it's getting silently ignored. |
Fixes rustwasm#3362 In some cases, the name section can fail to be parsed because one of the names is too long, which then causes the main function to not be detected because we don't know what any functions' names are. However, `main` is also exported with the name `main`, so we can look for an export named `main` instead to avoid relying on the name section.
so |
Fixes #3362 In some cases, the name section can fail to be parsed because one of the names is too long, which then causes the main function to not be detected because we don't know what any functions' names are. However, `main` is also exported with the name `main`, so we can look for an export named `main` instead to avoid relying on the name section.
Describe the Bug
When a WASM module contains a function with an extremely long mangled name (>100_000 characters, as can be generated by rust-lang/rust#109363)
wasmparser
will choke on thenames
custom section. This means that at thewalrus
/wasm-bindgen
layer any functions in the module after the problematically named function will not have names assigned. This is particularly deleterious ifmain
is late, as it meanswasm-bindgen
won't emit themain
glue (__wbindgen_start
and friends).Steps to Reproduce
core::drop_in_place
symbol size for builder-pattern structures that chain closures rust-lang/rust#109363, or clone https://github.com/bobtwinkles/wasm-bindgen-bug/bad
orbaad
and rustc 1.66 - 1.70 (other versions not tested). The module namegood
happens to work but it's up to the orderrustc
chooses to emit the code, I'll chalk this one up to nominative determinism.Expected Behavior
wasm-bindgen
should maybe complain louder that it has failed to load all function names? I'm not really sure what can be done about this at thewasm-bindgen
layer to be honest, I'm mostly just filing this bug here because I'm not sure what layer of the stack is really at fault here and want somewhere to anchor the discussion.Actual Behavior
wasm-bindgen
silently fails to generatemain
glue.Additional Context
I discovered this while working on a Sycamore app, in particular the
sycamore::builder::ElementBuilder
type suffers from the exponential drop glue function symbol size problem mentioned in the Rust bug above.The text was updated successfully, but these errors were encountered: