Skip to content
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

The binary rules got violated #350

Closed
dannypsnl opened this issue Nov 14, 2024 · 3 comments · Fixed by #352
Closed

The binary rules got violated #350

dannypsnl opened this issue Nov 14, 2024 · 3 comments · Fixed by #352

Comments

@dannypsnl
Copy link

I found an example (https://github.com/sunfishcode/hello-wasi-http) that violates import/export name rules

importname' ::= 0x00 len:<u32> in:<importname>                       => in  (if len = |in|)
exportname' ::= 0x00 len:<u32> en:<exportname>                       => en  (if len = |en|)

The problem part is pointed out as below:

0x1a | 01 13 77 61 | [instance 0] ComponentImport { name: ComponentImportName("wasi:io/[email protected]"), ty: Instance(0) }

0x215de2 | 00 1c 69 6d | [type 0] ComponentImport { name: ComponentImportName("import-type-incoming-request"), ty: Type(SubResource) }

At 0x1a it uses old encoding, meanwhile, at 0x215de2 it uses the rule as document.


Tools version

  • cargo-component-component 0.18.0
  • wit-bindgen-rt = { version = "0.35.0", features = ["bitflags"] }
@sunfishcode
Copy link
Member

This is related to the binary format change in WebAssembly/component-model#263. It appears something is still writing out old-style component import section entries that start with 0x01.

sunfishcode added a commit to sunfishcode/cargo-component that referenced this issue Nov 15, 2024
Update to the latest wit-bindgen, wasm-tools, warg, and
wasi-preview1-component-adapter-provider crates.

In particular, this updates to the wasm-encoder that always uses a
leading zero byte, following WebAssembly/component-model#263.

Fixes bytecodealliance#350.
@sunfishcode
Copy link
Member

It appears cargo-component 0.18 is using an older version of wasm-encoder. I've now submitted #352 to fix this.

@calvinrp
Copy link
Collaborator

Released 0.19 with the fix

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.

3 participants