Skip to content

Commit 1921fc0

Browse files
authored
Rollup merge of rust-lang#68282 - tmiasko:sanitizer-example, r=steveklabnik
Instrument C / C++ in MemorySanitizer example Modify the example to instrument C / C++ in addition to Rust, since it will be generally required (e.g., when using libbacktrace for symbolication).
2 parents 5b0caef + 7e3c51d commit 1921fc0

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/doc/unstable-book/src/compiler-flags/sanitizer.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Shadow byte legend (one shadow byte represents 8 application bytes):
170170
## MemorySanitizer
171171
172172
Use of uninitialized memory. Note that we are using `-Zbuild-std` to instrument
173-
standard library, and passing `-msan-track-origins=2` to the LLVM to track
173+
the standard library, and passing `-Zsanitizer-track-origins` to track the
174174
origins of uninitialized memory:
175175
176176
```shell
@@ -185,7 +185,15 @@ fn main() {
185185
}
186186
}
187187

188-
$ env RUSTFLAGS="-Zsanitizer=memory -Cllvm-args=-msan-track-origins=2" cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
188+
$ export \
189+
CC=clang \
190+
CXX=clang++ \
191+
CFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
192+
CXXFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
193+
RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins' \
194+
RUSTDOCFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins'
195+
$ cargo clean
196+
$ cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
189197
==9416==WARNING: MemorySanitizer: use-of-uninitialized-value
190198
#0 0x560c04f7488a in core::fmt::num::imp::fmt_u64::haa293b0b098501ca $RUST/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/src/libcore/fmt/num.rs:202:16
191199
...

0 commit comments

Comments
 (0)