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

[19.0.0] Fix a panic using tables with the wrong type #8284

Merged

Conversation

alexcrichton
Copy link
Member

This is a backport of #8283 to the 19.0.0 release branch.

This commit fixes an accidental issue introduced in bytecodealliance#8018 where using an
element segment which had been dropped with an `externref` table would
cause a panic. The panic happened due to an assertion that tables are
being used with the right type of item and that was being mismatched.
The underlying issue was that dropped element segments are modeled as an
empty element segment but the empty element segment was using the
"functions" encoding as opposed to the "expressions" encoding. This
meant that code later assumed that due to the use of functions the table
must be a table-of-functions, but this was not correct for
externref-based tables.

The fix in this commit is to instead model the encoding as an
"expressions" list which means that the table type is dispatched on to
call the appropriate initializer.

There is no memory safety issue with this mistake as the assertion was
specifically targetted at preventing memory safety. This does, however,
enable any WebAssembly module to panic a host.

Closes bytecodealliance#8281
@alexcrichton alexcrichton requested a review from a team as a code owner April 2, 2024 16:02
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team April 2, 2024 16:02
@alexcrichton alexcrichton enabled auto-merge (squash) April 2, 2024 16:28
@alexcrichton alexcrichton merged commit 24f7f40 into bytecodealliance:release-19.0.0 Apr 2, 2024
42 checks passed
@alexcrichton alexcrichton deleted the fix-table-panic branch April 2, 2024 16:32
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.

2 participants