Skip to content

Libfuzzer fails on registering external counters from sancov #135

@defkit

Description

@defkit

I'm trying to register counters from external source

The following fuzz target

#![no_main]

use libfuzzer_sys::fuzz_target;
use sancov::Counters;
static COUNTERS: Counters<1337> = Counters::new();

fn kek1(data: &[u8]) {
    COUNTERS.hash_increment(data);
}

fn kek2(data: &[u8]) {
    COUNTERS.hash_increment(data);
}

fuzz_target!(init: {
        COUNTERS.register();
    }, 
    |data: &[u8]| {
    if data.len() < 10 {
        return;
    }
    if data[0] == 1 {
        if data[1] == 2{
            if data[2] == 3{
                if data[4] == 4 {
                    let _ = data[0] * data[1] * data[2] * data[4];
                }
                else if data[4] == 1 {
                    let _ = kek1(data);
                }
            }
            else if data[2] == 5 && data[4] == 8{
                let _ = kek2(data);
            }
        }
    }
});

Fails with

ERROR: The size of coverage PC tables does not match the
number of instrumented PCs. This might be a compiler bug,
please contact the libFuzzer developers.

It happens because of PrintModuleInfo and does not fail if verbosity is off
cargo +nightly fuzz run fuzz_target_1 --fuzz-dir . -- -verbosity=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions