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

Fix fuzzer generation of a DataSegment + add validation that would have caught it #6626

Merged
merged 8 commits into from
May 23, 2024

Conversation

kripken
Copy link
Member

@kripken kripken commented May 23, 2024

The DataSegment was manually added to .dataSegments, but we need to add it
using addDataSegment so the maps are updated and getDataSegment(name)
works.

Ideally .dataSegments would be private, but a lot of code finds it useful to
iterate on it, so we've left it accessible.

Also add validation that would have caught this earlier: check that each item in
the item lists can be fetched by name.

The reason this was noticed is that #6620 happened to run into it by pure luck.

@kripken kripken requested a review from aheejin May 23, 2024 18:42
@kripken kripken marked this pull request as draft May 23, 2024 18:47
@kripken
Copy link
Member Author

kripken commented May 23, 2024

Actually tests pass but the fuzzer fails, so I've missed something...

@kripken kripken removed the request for review from aheejin May 23, 2024 18:47
@kripken
Copy link
Member Author

kripken commented May 23, 2024

The old code had a second bug - it didn't check for name collisions in the new segment it added. Fixed.

@kripken kripken marked this pull request as ready for review May 23, 2024 19:00
@kripken kripken requested a review from aheejin May 23, 2024 19:00
Copy link
Member

@aheejin aheejin left a comment

Choose a reason for hiding this comment

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

Yeah it looks like a pain to synchronize the vector and the map... Maybe we should make them private after all and provide iterator methods to access those maps, but that can be done later.

auto num = upTo(USABLE_MEMORY * 2);
for (size_t i = 0; i < num; i++) {
auto value = upTo(512);
wasm.dataSegments[0]->data.push_back(value >= 256 ? 0 : (value & 0xff));
Copy link
Member

Choose a reason for hiding this comment

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

Was this meant to be wasm.dataSegment[i]? It looks it should've been that way if the semantics are the same with the modified code..

Copy link
Member Author

@kripken kripken May 23, 2024

Choose a reason for hiding this comment

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

Hmm, I think it is pushing num chunks of binary data to the first segment here. wasm.dataSegments[i] might not exist - all we know is that [0] exists.

What do you mean by the second sentence?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I was confused.. Nevermind.

@kripken kripken merged commit 9b61eb3 into WebAssembly:main May 23, 2024
13 checks passed
@kripken kripken deleted the valmap branch May 23, 2024 23:06
@gkdn gkdn mentioned this pull request Aug 31, 2024
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