-
Notifications
You must be signed in to change notification settings - Fork 758
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
Conversation
Actually tests pass but the fuzzer fails, so I've missed something... |
The old code had a second bug - it didn't check for name collisions in the new segment it added. Fixed. |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Co-authored-by: Heejin Ahn <[email protected]>
The DataSegment was manually added to
.dataSegments
, but we need to add itusing
addDataSegment
so the maps are updated andgetDataSegment(name)
works.
Ideally
.dataSegments
would be private, but a lot of code finds it useful toiterate 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.