Skip to content

instance type declaration size is out of bounds #1104

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

Closed
MangoPeachGrape opened this issue Dec 13, 2024 · 6 comments · Fixed by bytecodealliance/wasm-tools#2087
Closed

instance type declaration size is out of bounds #1104

MangoPeachGrape opened this issue Dec 13, 2024 · 6 comments · Fixed by bytecodealliance/wasm-tools#2087

Comments

@MangoPeachGrape
Copy link

Apologies if this isn't the correct place to report this.

I'm running into linking issues in rust after increasing the number of functions in the wit file.

I run wit-bindgen rust . to generate rust bindings from a wit file. That is then compiled in a static lib crate, which succeeds, but linking fails for a binary that is linked against the static library. Compiling the whole workspace with cargo b -r --target wasm32-wasip2.

error: linking with `wasm-component-ld` failed: exit code: 1
note: error: failed to parse core wasm for componentization
          Caused by:
              0: decoding custom section component-type:wit-bindgen:0.36.0:x:xx:xxx:encoded world
              1: instance type declaration size is out of bounds (at offset 0x8b)

The issue seems to start happening when there is around 45k functions. 44k functions worked fine, 45.5k didn't work, with everything else being the same.

Additional information that might matter:

  • The wit file currently has <20k types (resources, records, enums combined)
  • The produced .rs from wit-bindgen is ~60mb
  • The produced .rlib with the output of wit-bindgen is ~200mb
  • rustc 1.85.0-nightly (4d669fb34 2024-12-08)

Let me know if anything else is needed to identify the issue.
Thanks in advance!

@alexcrichton
Copy link
Member

Thanks for the report! Can you share a binary or two here perhaps? The limit here is hardcoded at this location and is pretty arbitrary and should be fine to increase.

@MangoPeachGrape
Copy link
Author

I cannot share the original wit file, but this test wit file seems to reproduce the same issue: testcase.txt (github doesn't allow .wit files?)

If anything else is needed for reproduction, please let me know.
Thanks for helping!

@MangoPeachGrape
Copy link
Author

Tested again with wit-bindgen-cli 0.39.0 and rustc 1.87.0-nightly (ce36a966c 2025-02-17), still running into the same issue.

@alexcrichton Is there anything I could help you with regarding this issue?
Thanks for your time!

@alexcrichton
Copy link
Member

I mostly just haven't had time and/or a chance to investigate this. The location I linked I think is still reasonable to increase, but you'll need to get things working locally to use custom builds of the various tools in play. For example you'd need to build a custom wasm-component-ld which uses your changes in wit-parser and then configure rustc to use that custom linker instead of the default. Once that's all done it should be possible to confirm a fix.

@MangoPeachGrape
Copy link
Author

Thanks for the comment!

After getting a local build running, increasing the MAX_WASM_TYPE_SIZE to 10_000_000 didn't seem to fix the issue, but increasing MAX_WASM_INSTANCE_TYPE_DECLS to 1_000_000 worked!

Is this one something that can be increased?

@alexcrichton
Copy link
Member

Yeah that seems reasonable to me to increase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants