57 releases (17 breaking)

new 0.113.1 Nov 5, 2024
0.112.3 Nov 5, 2024
0.110.1 Jul 22, 2024
0.106.0 Mar 20, 2024
0.98.1 Jul 24, 2023

#161 in WebAssembly

Download history 51445/week @ 2024-07-16 47762/week @ 2024-07-23 48152/week @ 2024-07-30 45433/week @ 2024-08-06 45554/week @ 2024-08-13 46896/week @ 2024-08-20 45245/week @ 2024-08-27 48833/week @ 2024-09-03 48579/week @ 2024-09-10 48735/week @ 2024-09-17 54515/week @ 2024-09-24 48683/week @ 2024-10-01 51858/week @ 2024-10-08 56384/week @ 2024-10-15 62301/week @ 2024-10-22 59770/week @ 2024-10-29

240,734 downloads per month
Used in 213 crates (8 directly)

Apache-2.0 WITH LLVM-exception

11KB
112 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 (requires the fuzz feature, enabled by default)
  • 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

no_std support

This crate compiles in no_std environments, although both the fuzz or chaos features have a dependency on std. This means that on no_std you can't use arbitrary to initialize [ControlPlane] and can't enable chaos mode, although the rest of the usual [ControlPlane] API is available.

Dependencies

~27KB