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

[fuzz] Fix order of arguments passed in to wasm-spec-interpreter #4672

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

abrown
Copy link
Contributor

@abrown abrown commented Aug 10, 2022

In #4671, the meta-differential fuzz target was finding errors when
running certain Wasm modules (specifically shr_s in that case).
@conrad-watt diagnosed the issue as a missing reversal in the operands
passed to the spec interpreter. This change fixes #4671 and adds an
additional unit test to keep it fixed.

In bytecodealliance#4671, the meta-differential fuzz target was finding errors when
running certain Wasm modules (specifically `shr_s` in that case).
@conrad-watt diagnosed the issue as a missing reversal in the operands
passed to the spec interpreter. This change fixes bytecodealliance#4671 and adds an
additional unit test to keep it fixed.
@@ -55,7 +55,7 @@ let extract_exported_func export = match export with
(** Interpret the first exported function and return the result. Use provided
parameters if they exist, otherwise use default (zeroed) values. *)
let interpret_exn module_bytes opt_params =
let opt_params_ = Option.map (List.map convert_to_wasm) opt_params in
let opt_params_ = Option.map (List.rev_map convert_to_wasm) opt_params in
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a bug in the official wasm interpreter?

Copy link
Contributor

@conrad-watt conrad-watt Aug 10, 2022

Choose a reason for hiding this comment

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

Internally, the interpreter represents the value stack as a list in reverse order, so that popping from the stack is equivalent to taking the head of the list.

My tweaked version of the interpreter exposes an entrypoint function that assumes this reversal has already happened, hence the confusion. When I cut a new version of my interpreter, I can investigate if it makes sense to push the reversal down further, but an advantage of doing it this way is that the rev and map operations can be carried out here simultaneously, which is more efficient.

@abrown abrown changed the title [fuzz] Fix order of operands passed in to wasm-spec-interpreter [fuzz] Fix order of arguments passed in to wasm-spec-interpreter Aug 10, 2022
@github-actions github-actions bot added the fuzzing Issues related to our fuzzing infrastructure label Aug 10, 2022
@github-actions
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "fuzzing"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Contributor

@conrad-watt conrad-watt left a comment

Choose a reason for hiding this comment

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

LGTM!

EDIT: I may not have right/write repository access?

@alexcrichton alexcrichton merged commit 7fa89c4 into bytecodealliance:main Aug 10, 2022
@abrown abrown deleted the fix-4671 branch August 10, 2022 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fuzzing Issues related to our fuzzing infrastructure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fuzz: different results for shr_s
4 participants