rust-fuzz / honggfuzz-rs

Fuzz your Rust code with Google-developed Honggfuzz !
https://crates.io/crates/honggfuzz
Apache License 2.0
448 stars 40 forks source link

Address sanitizer(ASAN) flag doesn't seem to work #45

Closed StevenJiang1110 closed 3 years ago

StevenJiang1110 commented 3 years ago

I want to use honggfuzz-rs to fuzz some unsafe code, however, the ASAN doesn't seem to work. For example, I use the code just from the example directory, and replace the code in main.rs with

#[macro_use] extern crate honggfuzz;

fn main() {
    loop {
        fuzz!(|data: &[u8]| {
            // use after free bug
            let xs = vec![0, 1, 2, 3];
            let y = xs.as_ptr();
            drop(xs);
            let z = unsafe { *y };
        });
    }
}

I fuzz the project with

RUSTFLAGS="-Z sanitizer=address" cargo hfuzz run example

However, the fuzzer can not detect the bug(Theres should be only one path). There's one warning message from honggfuzz. 截屏2020-12-16 下午7 09 08 I hope you can check if this can work properly. Thanks a lot.

PaulGrandperrin commented 3 years ago

Hi, It's surprising but it's expected I would say:

if you want to force the bug to happen, you can override the optimization level:

RUSTFLAGS="-Z sanitizer=address -C opt-level=0 " cargo hfuzz run example