khagankhan opened PR #10924 from khagankhan:initial-mutatis to bytecodealliance:main:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->This is the initial porting of
table_opsfromarbitrarytomutatis.No new features are added. This is a direct port of the existing implementation using the
arbitrarycrate to themutatisframework.Open to review and feedback.
Initial work towards: bytecodealliance/wasmtime#10327
cc @ospencer @fitzgen
khagankhan requested alexcrichton for a review on PR #10924.
khagankhan requested wasmtime-fuzz-reviewers for a review on PR #10924.
khagankhan edited PR #10924:
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->This is the initial (unofficial) porting of
table_opsfromarbitrarytomutatis.No new features are added. This is a direct port of the existing implementation using the
arbitrarycrate to themutatisframework.Open to review and feedback.
Initial work towards: bytecodealliance/wasmtime#10327
cc @ospencer @fitzgen
fitzgen requested fitzgen for a review on PR #10924.
github-actions[bot] commented on PR #10924:
Subscribe to Label Action
cc @fitzgen
<details>
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 <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
khagankhan updated PR #10924.
khagankhan updated PR #10924.
fitzgen submitted PR review:
This is on the right track!
You can rebase on
mainto get thecargo vetaudits formutatisso that that part of CI stops failing.Also make sure to check that the actual fuzz target that runs this stuff continues to build via
$ cargo fuzz check --no-default-features -s none miscYou probably need to fix some stuff up in there and maybe hook up a custom mutator for libfuzzer, as described here: https://docs.rs/mutatis/latest/mutatis/_guide/fuzzer_integration/index.html
fitzgen created PR review comment:
I think we won't need this helper anymore, given the
fixuphelper function I suggested in private communication.
fitzgen created PR review comment:
Similarly, I think this function body will get cleaned up a ton with the
fixuppass. Additionally, whenever possible we don't want to report mutations that we know will fail so if the ops are empty we shouldn't callc.mutation(...). Putting these things together, I expect this will become something like:if !ops.ops.is_empty() { c.mutation(|ctx| { let i = ctx.rng().gen_index(ops.ops.len()).unwrap(); ops.ops[i] = choose_random_op(); Ok(()) })?; }
fitzgen created PR review comment:
And this can become an arbitrary
insertinstead ofappend(which is a subset of aninsertoperation).
fitzgen created PR review comment:
And rather than generating the max every time, it probably makes sense to do something like
for _ in ctx.rng().gen_index(MAX_OPS).unwrap() { // ... }
fitzgen created PR review comment:
And this can be
TableOps::default()where the default is an empty set of ops, since we will generate new ops just below. There is no need to start with this prologue every time.
fitzgen created PR review comment:
And this can become something like
if !ops.ops.is_empty() { c.mutation(|ctx| { let i = ctx.rng().gen_index(ops.ops.len()).unwrap(); ops.ops.remove(i); Ok(()) })?; }
fitzgen created PR review comment:
This is accidentally
O(n*n)because the helper walks every op in every iteration of this loop. You'll want to have a localstackvariable that is adjusted as ops are generated here.
fitzgen created PR review comment:
Here we would add
Defaultnext toDebug.
fitzgen created PR review comment:
This macro should just be
TableOps::default(), which can simply be derived on the type rather than written out.
fitzgen created PR review comment:
Don't think this needs to be
pubbecause I don't think it is used outside this module.
fitzgen created PR review comment:
Ditto.
fitzgen created PR review comment:
I don't think we should need this, and can simply use an empty
TableOps::default()instead, but if we did want to create this particular sequence in a bunch of places we should just use a function rather than a macro.
fitzgen created PR review comment:
And the
insertmutation would be something likec.mutation(|ctx| { let i = ctx.rng().gen_index(ops.ops.len() + 1).unwrap(); ops.ops.insert(random_op()); Ok(()) })?;
fitzgen created PR review comment:
Because the
TableOpsMutatoris the default, we don't actually need this test; it is redundant withmutate_table_ops_with_default_mutator.
fitzgen created PR review comment:
Reminder for this TODO.
khagankhan submitted PR review.
khagankhan created PR review comment:
Yes! I am working on that and a
fixupmethod results in much cleaner code.
khagankhan submitted PR review.
khagankhan created PR review comment:
Right!!
khagankhan commented on PR #10924:
Thanks, Nick! currently working on it. Will integrate your suggestions in the next commit.
khagankhan edited a comment on PR #10924:
Thanks, @fitzgen! currently working on it. Will integrate your suggestions in the next commit.
khagankhan updated PR #10924.
khagankhan submitted PR review.
khagankhan created PR review comment:
Removed.
khagankhan submitted PR review.
khagankhan created PR review comment:
Added
khagankhan submitted PR review.
khagankhan created PR review comment:
added new methods instead of macros
khagankhan submitted PR review.
khagankhan created PR review comment:
Done
khagankhan submitted PR review.
khagankhan created PR review comment:
Added new empty() method
khagankhan updated PR #10924.
khagankhan updated PR #10924.
khagankhan requested alexcrichton for a review on PR #10924.
khagankhan requested wasmtime-default-reviewers for a review on PR #10924.
khagankhan updated PR #10924.
alexcrichton requested fitzgen for a review on PR #10924.
khagankhan updated PR #10924.
khagankhan updated PR #10924.
fitzgen submitted PR review:
Looks great! Thanks!
fitzgen merged PR #10924.
Last updated: Dec 06 2025 at 06:05 UTC