3 title: "MSAN, ASAN, & TSAN"
4 linkTitle: "MSAN, ASAN, & TSAN"
9 *Testing Skia with memory, address, and thread santizers.*
11 Compiling Skia with ASAN, UBSAN, or TSAN can be done with the latest version of Clang.
13 - UBSAN works on Linux, Mac, Android, and Windows, though some checks are platform-specific.
14 - ASAN works on Linux, Mac, Android, and Windows.
15 - TSAN works on Linux and Mac.
16 - MSAN works on Linux[1].
18 We find that testing sanitizer builds with libc++ uncovers more issues than
19 with the system-provided C++ standard library, which is usually libstdc++.
20 libc++ proactively hooks into sanitizers to help their analyses.
21 We ship a copy of libc++ with our Linux toolchain in /lib.
23 [1]To compile and run with MSAN, an MSAN-instrumented version of libc++ is needed.
24 It's generally easiest to run one of the following 2 steps to build/download a recent version
25 of Clang and the instrumented libc++, located in /msan.
27 Downloading Clang binaries (Googlers Only)
28 ------------------------------------------
29 This requires gsutil, part of the [gcloud sdk](https://cloud.google.com/sdk/downloads).
31 <!--?prettify lang=sh?-->
33 CLANGDIR="${HOME}/clang"
34 ./bin/sk asset download clang_linux $CLANGDIR
36 Building Clang binaries from scratch (Other users)
37 ---------------------------
39 <!--?prettify lang=sh?-->
41 CLANGDIR="${HOME}/clang"
43 python3 tools/git-sync-deps
44 CC= CXX= infra/bots/assets/clang_linux/create.py -t "$CLANGDIR"
46 Configure and Compile Skia with MSAN
47 ------------------------------------
49 <!--?prettify lang=sh?-->
51 CLANGDIR="${HOME}/clang"
53 cat > out/msan/args.gn <<- EOF
54 cc = "${CLANGDIR}/bin/clang"
55 cxx = "${CLANGDIR}/bin/clang++"
56 extra_cflags = [ "-B${CLANGDIR}/bin" ]
61 "-Wl,-rpath,${CLANGDIR}/msan" ]
63 skia_use_fontconfig = false
65 python3 tools/git-sync-deps
69 Configure and Compile Skia with ASAN
70 ------------------------------------
72 <!--?prettify lang=sh?-->
74 CLANGDIR="${HOME}/clang"
76 cat > out/asan/args.gn <<- EOF
77 cc = "${CLANGDIR}/bin/clang"
78 cxx = "${CLANGDIR}/bin/clang++"
80 extra_ldflags = [ "-fuse-ld=lld", "-Wl,-rpath,${CLANGDIR}/lib" ]
82 python3 tools/git-sync-deps
86 Configure and Compile Skia with TSAN
87 ------------------------------------
89 <!--?prettify lang=sh?-->
91 CLANGDIR="${HOME}/clang"
93 cat > out/tsan/args.gn <<- EOF
94 cc = "${CLANGDIR}/bin/clang"
95 cxx = "${CLANGDIR}/bin/clang++"
98 extra_ldflags = [ "-Wl,-rpath,${CLANGDIR}/lib" ]
100 python3 tools/git-sync-deps