Skip to content

connglli/Reify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

241 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reify

Reify is a random program generator based on semantic reification. It generates C functions and programs free of undefined behaviors (UBs), making it suitable for testing C compilers and, potentially, other language virtual machines. Using Reify, 59 bugs have been discovered and reported in GCC and LLVM.

Currently, Reify supports only i32 and i32 arrays. We are extending it to support additional primitive and aggregate types. We are also experimenting with generating Java bytecode and eBPF bytecode. Even in their early stages, these experimental attempts have already revealed one JIT compiler bug in OpenJ9 and two bugs in Linux's eBPF runtime.

🚀 Quick Start

Install dependencies and start fuzzing C compilers with a single command similar to:

apt install libz3-dev libz-dev && \
make -j8 all && \
python scripts/fuzz.py -j 8 'gcc -O3 -fno-tree-slsr -fno-tree-ch'

🎇 Random Programs

Reify is capable of generating leaf functions that does not call other functions and whole programs composed of multiple functions.

Leaf Function Generation

Use the following script to generate 512 leaf functions:

python scripts/fgen.py --allops --injubs --sexp --main --output generated --limit 512

The output directory (given by the --output option) includes the following sub-directories:

  • functions: Generated functions in C (not compilable).
  • mappings: Input-output mappings of the generated functions, ensuring UB-free execution and terminating
  • sexpressions:S expressions of the generated functions, which can be used as seeds for generating whole programs. Require --sexp.
  • programs: Generated programs corresponding to the functions (compilable). Require --main.
  • Others.

Or use the following command to generate an individual leaf function:

timeout 3s ./build/bin/fgen -A -U -m -S --output generated --sno 0 $(uuidgen)

Note that generating leaf functions may (1) take a long time due to complicated constraints or (2) fail due to unsatisfiable constraints. This is why the above command is prefixed with timeout 3s.

Experimental: Leaf functions can be generated from existing control flow graphs (CFGs). This feature is experimental.

First install Clang:

apt install clang

Then extract 512 CFGs from other programs such as those generated by Csmith or YARPGen:

python scripts/ggen.py -l /path/to/clang -L 512 -g csmith --csmith /path/to/csmith /path/to/csmith_db.jsonl

Finally integrate the generated CFG database into leaf function generation:

python scripts/fgen.py ... --extra '--unstable-graphdb /path/to/csmith_db.jsonl' ...

Whole Program Generation

Use the following command to generate 512 whole programs based on a set of leaf functions previously generated (given by the --input option), in particular, their S expressions:

./build/bin/pgen --input generated --limit 512 $(uuidgen)

The generated programs are placed in the programs subdirectory of --input.

🔎 Fuzzing Compilers

GCC and Clang/LLVM can be tested with one command with scripts/fuzz.py. Start fuzzing with:

python scripts/fuzz.py -o fuzzdir -j 10 -s 0 'gcc -O3 -fno-tree-slsr -fno-tree-ch'
  • -o fuzzdir: Output directory
  • -j 10: Run 10 jobs in parallel
  • -s 0: Seed for random number generator

Fuzzing Compilers with Creal

Creal can be integrated into testing process. Install Csmith, CompCert, Creal, and optionally YARPGen. Then use:

python scripts/fuzz.py -o fuzzdir -s 0 -j 10 \
  --creal /path/to/Creal \
  --csmith /path/to/Csmith \
  --ccomp /path/to/CompCert \
  'gcc -O3 -fno-tree-slsr -fno-tree-ch'

Experimental: Fuzzing JVM

Use the following command to fuzz a Java virtual machine:

./scripts/fuzz_jvm.sh --nproc 8 --java-home /path/to/java/home

This process adapted leaf function generation to generate Java bytecode. An individual Java class can also be generated via --unstable-javaclass with build/bin/fgen can be used to generate :

timeout 3s ./build/bin/fgen ... --unstable-javaclass ...

The generated Java class is placed inside the javaclasses subdirectory.

🐞 Bug Showcases

Navigate to bugs.

✏️ Citing Us

If you found this work helpful, please consider citing our work:

@inproceedings{reify,
  title={Semantic Reification: A New Paradigm for Random Program Generation},
  author={Kavya Chopra and Cong Li and Thodoris Sotiropoulos and Zhendong Su},
  year={2026},
  booktitle={Proceedings of the 2026 ACM SIGPLAN Conference on Programming Language Design and Implementation},
  series={PLDI '26},
  doi={10.1145/3808268},
}

🧾 License

MIT License

Copyright (c) 2025

Kavya Chopra (chopra.kavya04@gmail.com)
Cong Li (cong.li@inf.ethz.ch)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

About

Reify: Program generation based on semantic reification, specifically symbolic function reification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors