Skip to content

Handle extended const segment offsets in the fuzzer - #6382

Merged
tlively merged 3 commits into
mainfrom
fuzzer-fix-segment-offsets
Mar 7, 2024
Merged

Handle extended const segment offsets in the fuzzer#6382
tlively merged 3 commits into
mainfrom
fuzzer-fix-segment-offsets

Conversation

@tlively

Copy link
Copy Markdown
Member

The fuzzer already had logic to remove all references to non-imported globals
from global initializers and data segment offsets, but it was missing for
element segment offsets. Add it, and also add a missing check line for the new
test that uncovered this bug as initial fuzzer input.

@tlively
tlively requested a review from kripkenMarch 7, 2024 02:35
@tlively

tlively commented Mar 7, 2024

Copy link
Copy Markdown
MemberAuthor

@tlivelytlively mentioned this pull request Mar 7, 2024
// If the offset is a global that was imported (which is ok) but no
// longer is (not ok) we need to change that.
if (auto* offset = segment->offset->dynCast<GlobalGet>()) {
if (!wasm.getGlobal(offset->name)->imported()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did the check for ->imported() go away? I think we only need to zero it out of there is a global.get that is not imported.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Hmm, I see that finalizeMemory does do this check, but with a note that imported globals are never encountered. Indeed, setupGlobals removes all imports. I guess I can follow finalizeMemory's lead here.

@kripkenkripken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Another option might be to assert on not seeing an import there - lgtm either way.

@tlively

Copy link
Copy Markdown
MemberAuthor

Oh yes, assertions make much more sense. Will change both cases.

Base automatically changed from eh-fuzzer-fix to mainMarch 7, 2024 16:20
The fuzzer already had logic to remove all references to non-imported globals
from global initializers and data segment offsets, but it was missing for
element segment offsets. Add it, and also add a missing check line for the new
test that uncovered this bug as initial fuzzer input.
@tlively
tlivelyforce-pushed the fuzzer-fix-segment-offsets branch from ad7c8d3 to 979b615CompareMarch 7, 2024 16:23
@tlively
tlively merged commit adca3a1 into mainMar 7, 2024
@tlively
tlively deleted the fuzzer-fix-segment-offsets branch March 7, 2024 16:57
@tlively

Copy link
Copy Markdown
MemberAuthor

Merge activity

@gkdngkdn mentioned this pull request Aug 31, 2024
Sign up for freeto 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

@tlively@kripken