-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lazy_static triggers AddressSanitizer errors #87
Comments
# Cargo.toml
[package]
name = "lazy_static_asan"
version = "0.0.0"
[dependencies]
lazy_static = "0.2.4"
libfuzzer-sys = {git = "https://github.com/rust-fuzz/libfuzzer-sys.git"}
[[bin]]
name = "read_lazy_static"
path = "read_lazy_static.rs" // read_lazy_static.rs
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
#[macro_use]
extern crate lazy_static;
lazy_static! {
static ref FOO: usize = 100;
}
fuzz_target!(|_data| {
*FOO;
});
|
@Manishearth has anyone reported the zero-sized issue upstream to LLVM? |
We would need a minimized test case in form of LLVM-IR or C if we want to report it upstream. |
I'm mildly comfortable with LLVM IR; but always in very constrained environments like microcontrollers. Any suggestions on how to take a piece of IR and and run it through ASan? |
Interestingly, running the fuzzer with optimizations on ( |
No idea, sorry. I guess you’d start by finding a minimal rust program which results in the issue when fuzzed/sanitised. Taking LLVM-IR of that and running it through |
Minimal is the tricky part. I can get the IR corresponding to the example here compiled with via the fuzzer options (so it's pre-instrumented), but that wants to link against the Rust standard library (and the fuzzer dylib). As-is, that's ~300k of LLVM IR, which isn't really minimal. |
@shepmaster maybe you can use bugpoint? |
FWIW, in my program that just hit this, running fuzzing the --release build indeed avoids the problem. |
@cmr perhaps! I've only used bugpoint to debug issues earlier in the LLVM pipeline (transforming LLVM IR to machine code) so that having an actual runnable program was never a concern :-) The other issue is that I'm guessing part of the error occurs due to code in the standard library (lazy_static uses atomics and Any idea if the LLVM folk would accept a testcase that is "please link against Rust's stdlib"? |
Unlikely. |
In BurntSushi/rust-snappy#5, it looks like the error is coming from
Lazy::get()
.This possibly has the same root cause as #81, but I don't know enough about how
lazy_static
works to be able to say for sure.The text was updated successfully, but these errors were encountered: