Skip to content

squeek502/zig-checkAllAllocationFailures-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zig-checkAllAllocationFailures-example

Full example code to serve as a companion to An Intro to Zig's checkAllAllocationFailures

Clone this repository and run the following commands (requires latest master version of Zig):

  • zig build test1: Run the initial test code. This should pass.
  • zig build test2: Run the test code transformed to be compatible with checkAllAllocationFailures, but without actually using checkAllAllocationFailures yet. This should pass.
  • zig build test3: Run the test code with checkAllAllocationFailures. This should fail due to a leak during fail index 1/5.
  • zig build test4: Run the test code with checkAllAllocationFailures with the errdefer fixes in place. This should now pass.
  • zig build test4 -Dcheck-allocation-failures=false: Run test4 but without checkAllAllocationFailures. This should pass.
  • zig build caveat: Run a test case that will trigger error.NondeterministicMemoryUsage during checkAllAllocationFailures.
  • zig build fuzz: Build an executable that will work with afl-fuzz. Requires AFL++ to be installed. See Fuzzing Zig Code Using AFL++ for more info.
    • After building, use afl-fuzz -i test/fuzz-inputs -o test/fuzz-outputs -- ./zig-out/bin/fuzz to start fuzz testing. No crashes should be found.

About

Companion code to "An Intro to Zig's checkAllAllocationFailures"

Resources

License

Stars

Watchers

Forks

Languages