-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
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 |
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.
Is this a bug in the official wasm interpreter?
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.
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.
wasm-spec-interpreter
wasm-spec-interpreter
Subscribe to Label Actioncc @fitzgen
This issue or pull request has been labeled: "fuzzing"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
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.
LGTM!
EDIT: I may not have right/write repository access?
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.