-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
MemorySanitizer detects an use of unitialized value in the test runner (rustc --test
)
#39610
Comments
Naively I'd say this is a false positive, but I could be wrong! This stack trace looks familiar, though, as I think I've seen it in terms of valgrind warnings in the past as well. (although I think those may have been false positives as well) |
I'm guessing that we're just using the regular libc? Also, here is much the same thing happening in another project. |
Thanks for the info @dimbleby! Right now I believe the standard library is not compiled with @japaric WDYT about modifying After that I think we could generate a nicer error up front saying "not everything is compiled with the memory sanitizer" than perhaps deferring this to runtime. |
Not sure whether we're at cross purposes, but just to make sure: I wasn't talking about the Rust standard library but the regular C libc - which is, I suppose, where the Having said that, it sounds as though both would need to be instrumented for the memory sanitizer to give reliable results... |
I think this is the root of the problem because if you run the sanitizer using Xargo, to force intrumentation of the whole std facade, then there's no error. @dimbleby I don't think one needs to compile libc with -fsanitize=memory as the sanitizer runtime that we link already instruments most of libc functions (memcpy, memchr, etc.) by overriding those symbols. The example you linked doesn't recompile libc either. We should, though, compile other C libraries that get linked to the final executable with -fsanitize=memory. I think that could be handled with a
We can't ship a
Interesting. I didn't know about that. I'll take a look. Do you know if that also forces the recompilation of functions that are already contained in e.g.
Do you mean making it so that a crate won't compile with |
Excellent point! Although unless we could ship two libstd builds and select between them dynamically 😉 (yeah let's not do that)
Yeah the "recompilation" here is that we build a massive wad of LLVM IR representing the entire world of Rust, we then optimize it all again, and then emit object code again. That re-codegens the entire world, but doesn't "recompile" the entire world (depending on your definition)
Yeah that's what I'm thinking. Unless all libraries are compiled with the right sanitizer then this is basically guaranteed to return false positives and errors, right? |
Is there a way to pass |
What we could do is add targets for sanitized builds. I want to just |
@alexcrichton how hard would it be to add a new target: The memory sanitizer is Linux-only, and probably |
It unfortunately wouldn't be the easiest thing but it also woudln't necessarily be too hard. It's definitely pretty hard to "do on a whim", so we'd want to commit to the design before doing so. |
Triage: not aware of any changes here. |
Unfortunately we can't yet run MemorySanitizer on `cargo test` as there is a known memory bug in rustc's test runner. [1] [1]: rust-lang/rust#39610
Unfortunately we can't yet run MemorySanitizer on `cargo test` as there is a known memory bug in rustc's test runner. [1] [1]: rust-lang/rust#39610
$ rustup toolchain install --force nightly # requires nightly-2020-01-11-x86_64-unknown-linux-gnu or later
$ rustup component add rust-src
$ git clone https://github.com/BurntSushi/ripgrep
$ cd ripgrep
$ export \
CC=clang \
CXX=clang++ \
CFLAGS=-fsanitize=memory \
CXXFLAGS=-fsanitize=memory \
RUSTFLAGS=-Zsanitizer=memory \
RUSTDOCFLAGS=-Zsanitizer=memory
$ cargo +nightly test -Z build-std --workspace --exclude grep-pcre2 --target x86_64-unknown-linux-gnu
...
Running target/x86_64-unknown-linux-gnu/debug/deps/globset-61555583ff5868c8
running 249 tests
test glob::tests::any1 ... ok
test glob::tests::cls10 ... ok
test glob::tests::cls1 ... ok
test glob::tests::any2 ... ok
test glob::tests::cls13 ... ok
test glob::tests::cls14 ... ok
test glob::tests::cls12 ... ok
test glob::tests::cls11 ... ok
test glob::tests::cls15 ... ok
test glob::tests::cls16 ... ok
...
Doc-tests grep-cli
running 8 tests
test src/lib.rs - (line 77) ... ignored
test src/lib.rs - (line 85) ... ignored
test src/decompress.rs - decompress::DecompressionReader (line 291) ... ok
test src/process.rs - process::CommandReader (line 155) ... ok
test src/pattern.rs - pattern::patterns_from_reader (line 142) ... ok
test src/escape.rs - escape::unescape (line 86) ... ok
test src/lib.rs - (line 91) ... ok
test src/escape.rs - escape::escape (line 35) ... ok
test result: ok. 6 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
... |
Okay, looks like we're passing then! Giving this a close unless anyone else can reproduce. |
This is just reproduced in my current build with
|
Did you try with build-std? |
STR
Meta
TODO Sanitizers are not yet in tree. (cf. #38699)
cc @alexcrichton @brson
The text was updated successfully, but these errors were encountered: