-
Notifications
You must be signed in to change notification settings - Fork 758
Open
Labels
Description
C-Smith generates C programs for fuzzing C compilers. We should create infrastructure (scripts, etc) for running it against bindgen, that we check into tree. And we should run it against bindgen.
We should look into if C-Smith supports things like controlling the kinds of programs it generates. We don't care about functions' bodies generally, and we care a whole lot about different kinds of type definitions.
magicgoose, sanmai-NL and MehdiSaffar
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
fitzgen commentedon Sep 25, 2017
Note: #1033 added some initial infrastructure for fuzzing
bindgen
with C-Smith, but it appears not to be super useful yet.Additional help tweaking knobs to get C-Smith to exercise
bindgen
a little better would be very welcome!Also, perhaps seeing if running C-Smith for longer periods ends up uncovering anything.
Finally, it might make sense to file issues upstream with C-Smith if we can't tweak knobs to our satisfaction.
Auto merge of #1033 - e00E:csmith-fuzz, r=fitzgen
pepyakin commentedon Sep 25, 2017
I'm wondering will it be useful to run rustc in check-only mode (as in
cargo check
) on bindings generated by the bindgen.fitzgen commentedon Sep 25, 2017
Yes, definitely. In fact, we should run the tests, so that we can assert size and alignment.
e00E commentedon Sep 25, 2017
In what kind of way would types get more complex anyway? In plain C they usually stay fairly simple.
The following command line switched of csmith seemed relevant:
but I did not set them because I would not expect having more "things" is more complex from bindgen's perspective.
e00E commentedon Sep 25, 2017
I just found a file that makes bindgen say
ERROR:bindgen::codegen::struct_layout: Calculated wrong layout for S5, too more 2 bytes
but it does create a full output rust file and does have exit code 0 (I tested other failures earlier which had exit code 1, so currently the script only looks for nonzero exit codes). If that means that bindgen will not always have a non zero exit code on failure then we will need to parse the output of stderr for lines start with
ERROR
, right?input:
output:
e00E commentedon Sep 25, 2017
What is the best way to run the tests in the bindgen output? In a full project I would run
cargo test
but is there a better way?pepyakin commentedon Sep 25, 2017
I'm not sure whether this is best way, but you can try following command
e00E commentedon Sep 25, 2017
Looks like a test fails in the above example as well, so the new logic for checking if bindgen worked correctly would be:
ERROR
(or maybe even anything output to stderr, period)fitzgen commentedon Sep 25, 2017
Just found: #1034
Made a label for all issues we find with C-Smith:
A-csmith
.Also cleaned up the
driver.py
, will send a PR in a second.e00E commentedon Sep 25, 2017
Ah, Im currenty changing it to follow the procedure outlined in my previous post, I will see what you changed.
fitzgen commentedon Sep 25, 2017
Also, an idea: #1036
pepyakin commentedon Oct 2, 2017
I'm wondering if there is a way to collect all known problems found by C-Smith and don't stop fuzzing if found any of them? 🤔
fitzgen commentedon Oct 2, 2017
Not sure... maybe we just need to fix all the issues more quickly ;)