Skip to content

Conversation

@kripken
Copy link
Member

@kripken kripken commented Oct 30, 2024

Continues the work from #7027 which added throwing from JS, this adds
table get/set operations from JS, to further increase our coverage of
Wasm/JS interactions (the table can be used from both sides).

@kripken kripken requested review from aheejin and tlively October 30, 2024 21:30
Comment on lines +624 to +628
// If a "table" export already exists, skip fuzzing these imports, as the
// current export may not contain a valid table for it.
if (wasm.getExportOrNull("table")) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case can this happen?

Copy link
Member Author

@kripken kripken Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fuzzer can start with inputs from the test suite and elsewhere, and initial content like that can contain a "table" export. Basically, the fuzzer needs to be able to start from any valid wasm file, so we have to handle corner cases like that.


// Table operations.
'table-get': (index) => {
return exports.table.get(index >>> 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for shifting the index by 0? (I googled it and it says it makes it a number, but I don't understand why it is necessary...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the >>> operator is an unsigned operation, so this forces it to be a 32-bit unsigned number. That is the same way that the wasm table.get operation treats the input, so this is done to match that.

@kripken kripken merged commit 1b066cb into WebAssembly:main Oct 31, 2024
13 checks passed
@kripken kripken deleted the fuzz.import.table branch October 31, 2024 20:54
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