Skip to content

Fuzzer: Log exported globals#8466

Merged
kripken merged 38 commits intoWebAssembly:mainfrom
kripken:export.moar
Mar 17, 2026
Merged

Fuzzer: Log exported globals#8466
kripken merged 38 commits intoWebAssembly:mainfrom
kripken:export.moar

Conversation

@kripken
Copy link
Member

@kripken kripken commented Mar 13, 2026

We already exported globals in the fuzzer, but did not do anything with
them. This logs out their values, at the same time that we log out the
values returned from calling exported functions (and using the same
reordering etc.).

@kripken kripken requested a review from tlively March 13, 2026 23:15
@kripken
Copy link
Member Author

kripken commented Mar 13, 2026

Looks like this messes with the auto-update script for the lit test... hmm. Otherwise though this should be ready.

try {
actualValue = global.value;
} catch (e) {
if (e.message.startsWith('get WebAssembly.Global.value')) {
Copy link
Member

Choose a reason for hiding this comment

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

  1. Can we check the type of the error rather than the message? Error messages are not standardized and may differ between implementations.

  2. Maybe we should print something else to distinguish this case from an exported global actually containing null.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. I think it's just a generic RuntimeError, so the text is really all we have to go on...
  2. Hmm, but we'd need to print some value in other fuzzer places too. I don't think this is ambiguous - this happens only for the illegal types. So if the type is v128, we know 'null' means "i can't print this" etc.

Copy link
Member

Choose a reason for hiding this comment

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

  1. There aren't any other errors that could happen here, right? Maybe we can just detect the presence of any error at all.

  2. What if the exported global holds a null anyref? Wouldn't that print null as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. At minimum there could be a VM bug that causes some other kind of error, and we would want to differentiate that. But also maybe the spec has more..? It just seems better to be precise.
  2. Yes, a null anyref will print null, but the type + the value is unambiguous. If the type is illegal, it will print null. We could also put a string here "illegal value" or such?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, "illegal value" or "failed conversion" or something like that sgtm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +506 to +508
// Log the global's value. (We use "calling" here to match the output
// for calls, which simplifies the fuzzer.)
std::cout << "[fuzz-exec] calling " << exp->name << "\n";
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove "calling" everywhere as a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any idea for what to replace it with? We need something to differentiate it from other things. I don't have a good idea myself...

Copy link
Member

Choose a reason for hiding this comment

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

maybe "export" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, yeah, maybe just "export" is good. My brain was stuck looking for a verb 😄 Will do in a followup.

@kripken
Copy link
Member Author

kripken commented Mar 16, 2026

I worked around the auto-updater test issue with a tiny manual test. We really don't need any more here.

@kripken kripken merged commit 192dcc3 into WebAssembly:main Mar 17, 2026
16 checks passed
@kripken kripken deleted the export.moar branch March 17, 2026 20:56
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