Comments (3)
I think I've solved in my case by reworking the types I'm using to not be mutually recursive.
from fuzzcheck-rs.
It's possible, but it is pushing of the limits of what is currently possible, and I don't know what the quality of the resulting mutators will be (maybe they're fine, I just haven't tested it).
You can try to write something like:
make_mutator! {
name: AMutator,
recursive: true,
default: false,
type:
struct MutuallyRecursiveA {
b: Vec<MutuallyRecursiveB>,
#[field_mutator(<Vec<u64> as DefaultMutator>::Mutator = { <Vec<u64>>::default_mutator() })]
data: Vec<u64>,
}
}
make_mutator! {
name: BMutator,
recursive: true,
default: true,
type:
struct MutuallyRecursiveB {
#[field_mutator(
OptionMutator<MutuallyRecursiveA, AMutator<VecMutator<MutuallyRecursiveB, RecurToMutator<BMutator>>>>
) = {
OptionMutator::new(AMutator::new(
VecMutator::new(self_.into(), 0..=usize::MAX),
<Vec<u64>>::default_mutator(),
))
}]
a: Option<MutuallyRecursiveA>,
#[field_mutator(<bool as DefaultMutator>::Mutator = { <bool>::default_mutator() })]
data: bool
}
}
It is not a perfect solution: MutuallyRecursiveA
has no default mutator, only MutuallyRecursiveB
does.
You could however, repeat the snippet above twice except that A
and B
are switched, giving different names to the mutators. The idea is that for each mutually recursive type, you have a “default mutator” and a “mutator to be used only as a submutator to the other type’s default mutator”.
That's not fundamentally necessary though, and I could improve the procedural macro to make it possible to define these mutually recursive mutators using only one make_mutator!
per type. I would need to think about those generic bounds a bit more (again! lol).
Note though that due to a questionable design decision (because of superfluous generic bound, again!) , even the code I posted above doesn't actually work. So you have to construct BMutator
with:
let mutator = RecursiveMutator::new(|self_| {
BMutator::new(
OptionMutator::new(AMutator::new(
VecMutator::new(self_.into(), 0..=usize::MAX),
<Vec<u64>>::default_mutator(),
)),
bool::default_mutator(),
)
});
I'll try and fix that and post the progress in this issue. It may be a LONG time before mutually-recursive types are easy to work with though.
from fuzzcheck-rs.
Thank you so much!
from fuzzcheck-rs.
Related Issues (20)
- Crash while trying to read LLVM covmap HOT 12
- Using `#[field_mutator(...)]` attribute with `DefaultMutator` derive macro. HOT 6
- View line coverage HOT 8
- Errors running fuzzcheck HOT 6
- Error minifying an input HOT 7
- Update fuzzcheck to new Coverage Mapping format version HOT 1
- Documentation typo HOT 1
- Avoid constructing a specific variant of an enum when using `DefaultMutator` HOT 6
- Linking failure HOT 1
- Minify crashes while fuzz works HOT 6
- Fuzzcheck can't run on NixOS HOT 2
- AddressSanitizer complains when stopping fuzzer w/ CTRL+C HOT 4
- Error "the mutator used by the fuzz test does not evaluate the complexity of the test cases consistently" HOT 4
- Recurrence of recursive mutator bug HOT 6
- "A crash was detected, but the fuzzer cannot recover the crashing input." HOT 5
- Missing `UsizeWithinRangeMutator`?
- error: unsupported operation: can't call foreign function `sigaltstack` on OS `linux` HOT 1
- failed to parse LLVM covmap: InvalidVersion(6) HOT 2
- Windows Support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuzzcheck-rs.