Skip to content

[threads] Update the fuzzer for shared types #6771

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

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Jul 18, 2024

Update the fuzzer to both handle shared types in initial contents and
create and use new shared types without crashing or producing invalid
modules. Since V8 does not have a complete implementation of
shared-everything-threads yet, disable fuzzing V8 when shared-everything
is enabled. To avoid losing too much coverage of V8, disable
shared-everything in the fuzzer more frequently than other features.

@tlively tlively requested a review from kripken July 18, 2024 13:04

# The shared-everything feature is new and we want to fuzz it, but it
# also currently disables fuzzing V8, so disable it half the time.
if random.random() < 0.5:
Copy link
Member

Choose a reason for hiding this comment

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

Skipping V8 is pretty significant, how about 0.9 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I guess in my local fuzzing I can always comment this out.

Comment on lines +2636 to +2642
static HeapType sharedTrivialStruct = []() {
TypeBuilder builder(1);
builder[0] = Struct{};
builder[0].setShared();
return (*builder.build())[0];
}();
auto ht = share == Shared ? sharedTrivialStruct : trivialStruct;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static HeapType sharedTrivialStruct = []() {
TypeBuilder builder(1);
builder[0] = Struct{};
builder[0].setShared();
return (*builder.build())[0];
}();
auto ht = share == Shared ? sharedTrivialStruct : trivialStruct;
static HeapType makeSharedTrivialStruct = []() {
TypeBuilder builder(1);
builder[0] = Struct{};
builder[0].setShared();
return (*builder.build())[0];
}();
auto ht = share == Shared ? makeSharedTrivialStruct() : trivialStruct;

Copy link
Member

Choose a reason for hiding this comment

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

(also below, if this makes sense)

Copy link
Member Author

Choose a reason for hiding this comment

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

Note the () after the lambda expression making this an IIFE meant to be executed once when the static local is initialized.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I missed the static.

@@ -759,7 +759,8 @@ void Inhabitator::markExternRefsNullable() {
auto children = type.getTypeChildren();
for (size_t i = 0; i < children.size(); ++i) {
auto child = children[i];
if (child.isRef() && child.getHeapType() == HeapType::ext &&
if (child.isRef() && child.getHeapType().isBasic() &&
child.getHeapType().getBasic(Unshared) == HeapType::ext &&
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should have a helper for this common pattern of x.isBasic() && x.getHeapType.getBasic(Unshared) == Y, something like x.isEqualToUnsharedBasic(Y)?

Copy link
Member Author

Choose a reason for hiding this comment

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

How about doing this as a follow-up? It could apply more broadly than just in these files.

Copy link
Member

Choose a reason for hiding this comment

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

sgtm

@@ -759,7 +759,8 @@ void Inhabitator::markExternRefsNullable() {
auto children = type.getTypeChildren();
for (size_t i = 0; i < children.size(); ++i) {
auto child = children[i];
if (child.isRef() && child.getHeapType() == HeapType::ext &&
if (child.isRef() && child.getHeapType().isBasic() &&
child.getHeapType().getBasic(Unshared) == HeapType::ext &&
Copy link
Member

Choose a reason for hiding this comment

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

sgtm

@tlively tlively force-pushed the validate-elem-type-feats branch from 36a96ef to 79dfd9d Compare July 18, 2024 17:57
@tlively tlively force-pushed the threads-shared-fuzzing branch from 0774d77 to 2d87cd1 Compare July 18, 2024 17:57
@tlively tlively force-pushed the validate-elem-type-feats branch from 79dfd9d to 0065859 Compare July 18, 2024 18:56
@tlively tlively force-pushed the threads-shared-fuzzing branch from 2d87cd1 to 35c227f Compare July 18, 2024 18:56
tlively added a commit that referenced this pull request Jul 18, 2024
This abbreviates a common pattern where we first had to check whether a
heap type was basic, then if it was, get its unshared version and
compare it to some expected BasicHeapType.

Suggested in
#6771 (comment).
@tlively tlively force-pushed the validate-elem-type-feats branch from 0065859 to 0b0ce0d Compare July 18, 2024 20:39
@tlively tlively force-pushed the threads-shared-fuzzing branch from 35c227f to a6c1419 Compare July 18, 2024 20:40
tlively added a commit that referenced this pull request Jul 18, 2024
This abbreviates a common pattern where we first had to check whether a
heap type was basic, then if it was, get its unshared version and
compare it to some expected BasicHeapType.

Suggested in
#6771 (comment).
Base automatically changed from validate-elem-type-feats to main July 18, 2024 20:40
tlively added 3 commits July 18, 2024 13:40
Update the fuzzer to both handle shared types in initial contents and
create and use new shared types without crashing or producing invalid
modules. Since V8 does not have a complete implementation of
shared-everything-threads yet, disable fuzzing V8 when shared-everything
is enabled. To avoid losing too much coverage of V8, disable
shared-everything in the fuzzer more frequently than other features.
@tlively tlively force-pushed the threads-shared-fuzzing branch from a6c1419 to ec3bc3e Compare July 18, 2024 20:41
tlively added a commit that referenced this pull request Jul 18, 2024
This abbreviates a common pattern where we first had to check whether a
heap type was basic, then if it was, get its unshared version and
compare it to some expected BasicHeapType.

Suggested in
#6771 (comment).
@tlively tlively merged commit 848a289 into main Jul 18, 2024
13 checks passed
@tlively tlively deleted the threads-shared-fuzzing branch July 18, 2024 20:41
tlively added a commit that referenced this pull request Jul 18, 2024
This abbreviates a common pattern where we first had to check whether a
heap type was basic, then if it was, get its unshared version and
compare it to some expected BasicHeapType.

Suggested in
#6771 (comment).
tlively added a commit that referenced this pull request Jul 18, 2024
This abbreviates a common pattern where we first had to check whether a
heap type was basic, then if it was, get its unshared version and
compare it to some expected BasicHeapType.

Suggested in

#6771 (comment).
@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