Bug 1200740 - Import blacklist for ASan on Windows to avoid instrumenting selected sandbox functions and files. r?glandium draft
authorTing-Yu Chou <janus926@gmail.com>
Thu, 10 Nov 2016 09:18:55 +0800
changeset 437015 ebbdb079e4698ee00f6408d0196a51284a47d1f9
parent 435666 783356f1476eafd8e4d6fa5f3919cf6167e84f8d
child 536519 71804cca5e278e41ca58b04cf00a25ea00fa8b0b
push id35285
push userbmo:janus926@gmail.com
push dateThu, 10 Nov 2016 07:31:57 +0000
reviewersglandium
bugs1200740
milestone52.0a1
Bug 1200740 - Import blacklist for ASan on Windows to avoid instrumenting selected sandbox functions and files. r?glandium MozReview-Commit-ID: DJJuD0dyyKz
build/autoconf/sanitize.m4
build/sanitizers/asan_blacklist_win.txt
--- a/build/autoconf/sanitize.m4
+++ b/build/autoconf/sanitize.m4
@@ -21,16 +21,21 @@ if test -n "$MOZ_ASAN"; then
           MOZ_CLANG_RT_ASAN_LIB=clang_rt.asan_dynamic-i386.dll
         fi
         # We use MOZ_PATH_PROG in order to get a Windows style path.
         MOZ_PATH_PROG(MOZ_CLANG_RT_ASAN_LIB_PATH, $MOZ_CLANG_RT_ASAN_LIB)
         if test -z "$MOZ_CLANG_RT_ASAN_LIB_PATH"; then
             AC_MSG_ERROR([Couldn't find $MOZ_CLANG_RT_ASAN_LIB.  It should be available in the same location as clang-cl.])
         fi
         AC_SUBST(MOZ_CLANG_RT_ASAN_LIB_PATH)
+        # Suppressing errors in recompiled code.
+        if test "$OS_ARCH" = "WINNT"; then
+            CFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CFLAGS"
+            CXXFLAGS="-fsanitize-blacklist=$_topsrcdir/build/sanitizers/asan_blacklist_win.txt $CXXFLAGS"
+        fi
     fi
     CFLAGS="-fsanitize=address $CFLAGS"
     CXXFLAGS="-fsanitize=address $CXXFLAGS"
     if test -z "$CLANG_CL"; then
         LDFLAGS="-fsanitize=address $LDFLAGS"
     fi
     AC_DEFINE(MOZ_ASAN)
     MOZ_PATH_PROG(LLVM_SYMBOLIZER, llvm-symbolizer)
new file mode 100644
--- /dev/null
+++ b/build/sanitizers/asan_blacklist_win.txt
@@ -0,0 +1,26 @@
+# This is originally copied from Chromium tools/memory/asan/blacklist_win.txt.
+# The rules in this file are only applied at compile time. If you can modify the
+# source in question, consider function attributes to disable instrumentation.
+
+# Bug 1200740 - ASan crash due to child process function interceptions
+# Sandbox executes some of its code before the ASan RTL gets initialized and
+# maps shadow memory.  As a result, instrmented code tries to access unavailable
+# shadow memory and faults.
+fun:*TargetNtSetInformationThread@20
+fun:*TargetNtOpenThreadToken@20
+fun:*TargetNtOpenThreadTokenEx@24
+fun:*TargetNtMapViewOfSection@44
+fun:*AutoProtectMemory*sandbox*
+fun:*EatResolverThunk*sandbox*
+fun:*InterceptionAgent*sandbox*
+fun:*ResolverThunk*sandbox*
+fun:*Target*SandboxFactory*sandbox*
+fun:*ProcessState*sandbox*
+src:*pe_image.h
+src:*pe_image.cc
+src:*resolver_32.cc
+src:*filesystem_interception.cc
+src:*process_thread_interception.cc
+src:*registry_interception.cc
+src:*sandbox_nt_util.cc
+src:*sync_interception.cc