Skip to content

Error on single items WIT can't express instead of panicking - #2814

Closed
sansmoraxz wants to merge 7 commits into
bytecodealliance:mainfrom
sansmoraxz:wit-decode/2-items
Closed

sansmoraxz wants to merge 7 commits into
bytecodealliance:mainfrom
sansmoraxz:wit-decode/2-items

Conversation

@sansmoraxz

Copy link
Copy Markdown
Contributor

Followup on #2813

Decoding panicked with generic messages on components with items WIT has no form for, like imported function type, function or type named like a:b/c, a method of a resource from another interface, or a component-type section that isn't one world. These now throw "cannot represent this component in WIT" errors.

Decoding read each section into a buffer sized up front by the length
the input gives for it. A 14-byte input claiming a 4 GiB section made it
allocate 4 GiB, which aborts the process where that fails. The buffer
now grows with what is actually read.
@sansmoraxz
sansmoraxz requested a review from a team as a code owner November 10, 2026 11:15
@sansmoraxz
sansmoraxz requested review from pchickey and removed request for a team November 10, 2026 11:15
Checking whether a function's result contains a `borrow` recursed once
per alias, so parsing WIT with a long enough chain like `type t1 = t0;
type t2 = t1; ...` overflowed the stack and aborted the process. The
chain is now walked in a loop.
WIT types are value types and resources. Decoding panicked on a
component that imports a component, instance or function type, or has
an instance exporting one, and now returns an error.
Only interfaces have names like `a:b/c` in WIT. Decoding panicked on a
function imported under such a name, and now returns an error.
Only interfaces have names like `a:b/c` in WIT. Decoding accepted a type
imported or exported under such a name and printed `type a:b/c = ...`,
which doesn't parse.
WIT puts a resource's constructor, methods and static functions in the
interface that defines it. Decoding panicked on an interface with
`[method]r.f` where `r` is only a `use` of another interface's resource,
and now returns an error.
A core module's `component-type` custom section holds a component type
with no imports and one world as its only export, as `wit-component`
writes it. Decoding panicked on one with imports, with other than one
export, or exporting something that isn't a world, and now returns an
error.
@sansmoraxz

Copy link
Copy Markdown
Contributor Author

will recreate after first PR merges.

@sansmoraxz sansmoraxz closed this Nov 10, 2026
@sansmoraxz sansmoraxz changed the title Wit decode/2 items Error on single items WIT can't express instead of panicking Nov 10, 2026
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 this pull request may close these issues.

1 participant