37 releases (11 breaking)

new 0.107.0 Apr 22, 2024
0.106.0 Mar 20, 2024
0.105.4 Apr 11, 2024
0.103.0 Dec 20, 2023
0.98.1 Jul 24, 2023

#262 in Testing

Download history 23168/week @ 2024-01-01 30174/week @ 2024-01-08 37353/week @ 2024-01-15 36086/week @ 2024-01-22 37665/week @ 2024-01-29 40526/week @ 2024-02-05 35838/week @ 2024-02-12 39422/week @ 2024-02-19 44364/week @ 2024-02-26 45881/week @ 2024-03-04 46471/week @ 2024-03-11 52788/week @ 2024-03-18 43427/week @ 2024-03-25 51184/week @ 2024-04-01 47679/week @ 2024-04-08 48375/week @ 2024-04-15

193,804 downloads per month
Used in 139 crates (7 directly)

Apache-2.0 WITH LLVM-exception

10KB
107 lines

This crate contains the control plane for "chaos mode". It can be used to inject pseudo-random perturbations into specific sections in the code while fuzzing. Its compilation is feature-gated to prevent any performance impact on release builds.


lib.rs:

Cranelift Control

This is the home of the control plane of chaos mode, a compilation feature intended to be turned on for certain fuzz targets. When the feature is turned off, as is normally the case, [ControlPlane] will be a zero-sized type and optimized away.

While the feature is turned on, the struct [ControlPlane] provides functionality to tap into pseudo-randomness at specific locations in the code. It may be used for targeted fuzzing of compiler internals, e.g. manipulate heuristic optimizations, clobber undefined register bits etc.

There are two ways to acquire a [ControlPlane]:

  • arbitrary for the real deal
  • default for an "empty" control plane which always returns default values

Fuel Limit

Controls the number of mutations or optimizations that the compiler will perform before stopping.

When a perturbation introduced by chaos mode triggers a bug, it may not be immediately clear which of the introduced perturbations was the trigger. The fuel limit can then be used to binary-search for the trigger. It limits the number of perturbations introduced by the control plane. The fuel limit will typically be set with a command line argument passed to a fuzz target. For example:

cargo fuzz run --features chaos $TARGET -- --fuel=16

Dependencies

~92KB