Bug 1620326 - Add a separate TSan suppression list for the updater. r=froydnj
authorChristian Holler <choller@mozilla.com>
Thu, 26 Mar 2020 21:19:24 +0000
changeset 520646 3e4ba5c063d6aacae2a098f35d1df0f6baff8b54
parent 520645 952f8154b3b252a864bbf559d9f9a641d6fe3257
child 520647 75da647bf315b6bf2c2f33b4d7a02c8ed84bee93
push id37254
push usernerli@mozilla.com
push dateFri, 27 Mar 2020 04:48:07 +0000
treeherdermozilla-central@2d758b42bd73 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1620326
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1620326 - Add a separate TSan suppression list for the updater. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D67125
mfbt/TsanOptions.h
mfbt/moz.build
mozglue/build/TsanOptions.cpp
toolkit/mozapps/update/updater/TsanOptions.cpp
toolkit/mozapps/update/updater/updater-common.build
new file mode 100644
--- /dev/null
+++ b/mfbt/TsanOptions.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Default options for ThreadSanitizer. */
+
+#ifndef mozilla_TsanOptions_h
+#define mozilla_TsanOptions_h
+
+#include "mozilla/Compiler.h"
+
+#ifndef _MSC_VER  // Not supported by clang-cl yet
+
+//
+// When running with ThreadSanitizer, we need to explicitly set some
+// options specific to our codebase to prevent errors during runtime.
+// To override these, set the TSAN_OPTIONS environment variable.
+//
+// Currently, these are:
+//
+//   abort_on_error=1 - Causes TSan to abort instead of using exit().
+//   halt_on_error=1 - Causes TSan to stop on the first race detected.
+//
+//   report_signal_unsafe=0 - Required to avoid TSan deadlocks when
+//   receiving external signals (e.g. SIGINT manually on console).
+//
+//   allocator_may_return_null=1 - Tell TSan to return NULL when an allocation
+//   fails instead of aborting the program. This allows us to handle failing
+//   allocations the same way we would handle them with a regular allocator and
+//   also uncovers potential bugs that might occur in these situations.
+//
+extern "C" const char* __tsan_default_options() {
+  return "halt_on_error=1:abort_on_error=1:report_signal_unsafe=0"
+         ":allocator_may_return_null=1";
+}
+
+// These are default suppressions for external libraries that probably
+// every application would want to include if it potentially loads external
+// libraries like GTK/X and hence their dependencies.
+#define MOZ_TSAN_DEFAULT_EXTLIB_SUPPRESSIONS     \
+        "called_from_lib:libatk-1\n"             \
+        "called_from_lib:libcairo.so\n"          \
+        "called_from_lib:libcairo-gobject\n"     \
+        "called_from_lib:libgdk-3\n"             \
+        "called_from_lib:libgdk_pixbuf\n"        \
+        "called_from_lib:libgdk-x11\n"           \
+        "called_from_lib:libgio-2\n"             \
+        "called_from_lib:libglib-1\n"            \
+        "called_from_lib:libglib-2\n"            \
+        "called_from_lib:libgobject\n"           \
+        "called_from_lib:libgtk-3\n"             \
+        "called_from_lib:libgtk-x11\n"           \
+        "called_from_lib:libgvfscommon\n"        \
+        "called_from_lib:libgvfsdbus\n"          \
+        "called_from_lib:libibus-1\n"            \
+        "called_from_lib:libogg.so\n"            \
+        "called_from_lib:libpangocairo\n"        \
+        "called_from_lib:libpangoft2\n"          \
+        "called_from_lib:pango-basic-fc\n"       \
+        "called_from_lib:libpixman-1\n"          \
+        "called_from_lib:libpulse.so\n"          \
+        "called_from_lib:libpulsecommon\n"       \
+        "called_from_lib:libsecret-1\n"          \
+        "called_from_lib:libunity-gtk3-parser\n" \
+        "called_from_lib:libvorbis.so\n"         \
+        "called_from_lib:libvorbisfile\n"        \
+        "called_from_lib:libX11.so\n"            \
+        "called_from_lib:libX11-xcb\n"           \
+        "called_from_lib:libXau\n"               \
+        "called_from_lib:libxcb.so\n"            \
+        "called_from_lib:libXcomposite\n"        \
+        "called_from_lib:libXcursor\n"           \
+        "called_from_lib:libXdamage\n"           \
+        "called_from_lib:libXdmcp\n"             \
+        "called_from_lib:libXext\n"              \
+        "called_from_lib:libXfixes\n"            \
+        "called_from_lib:libXi.so\n"             \
+        "called_from_lib:libXrandr\n"            \
+        "called_from_lib:libXrender\n"           \
+        "called_from_lib:libXss\n"
+
+
+#endif  // _MSC_VER
+
+#endif /* mozilla_TsanOptions_h */
--- a/mfbt/moz.build
+++ b/mfbt/moz.build
@@ -137,16 +137,21 @@ if CONFIG['OS_ARCH'] == 'WINNT':
     EXPORTS.mozilla += [
         'WindowsVersion.h',
     ]
 elif CONFIG['OS_ARCH'] == 'Linux':
     EXPORTS.mozilla += [
         'LinuxSignal.h',
     ]
 
+if CONFIG['MOZ_TSAN']:
+    EXPORTS.mozilla += [
+        'TsanOptions.h',
+    ]
+
 UNIFIED_SOURCES += [
     'Assertions.cpp',
     'ChaosMode.cpp',
     'double-conversion/double-conversion/bignum-dtoa.cc',
     'double-conversion/double-conversion/bignum.cc',
     'double-conversion/double-conversion/cached-powers.cc',
     'double-conversion/double-conversion/double-to-string.cc',
     'double-conversion/double-conversion/fast-dtoa.cc',
--- a/mozglue/build/TsanOptions.cpp
+++ b/mozglue/build/TsanOptions.cpp
@@ -1,41 +1,19 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Attributes.h"
+#include "mozilla/TsanOptions.h"
 
 #ifndef _MSC_VER  // Not supported by clang-cl yet
 
 //
-// When running with ThreadSanitizer, we need to explicitly set some
-// options specific to our codebase to prevent errors during runtime.
-// To override these, set the TSAN_OPTIONS environment variable.
-//
-// Currently, these are:
-//
-//   abort_on_error=1 - Causes TSan to abort instead of using exit().
-//   halt_on_error=1 - Causes TSan to stop on the first race detected.
-//
-//   report_signal_unsafe=0 - Required to avoid TSan deadlocks when
-//   receiving external signals (e.g. SIGINT manually on console).
-//
-//   allocator_may_return_null=1 - Tell TSan to return NULL when an allocation
-//   fails instead of aborting the program. This allows us to handle failing
-//   allocations the same way we would handle them with a regular allocator and
-//   also uncovers potential bugs that might occur in these situations.
-//
-extern "C" const char* __tsan_default_options() {
-  return "halt_on_error=1:abort_on_error=1:report_signal_unsafe=0"
-         ":allocator_may_return_null=1";
-}
-
-//
 // When running with ThreadSanitizer, we sometimes need to suppress existing
 // races. However, in any case, it should be either because
 //
 //    1) a bug is on file. In this case, the bug number should always be
 //       included with the suppression.
 //
 // or 2) this is an intentional race. Please be very careful with judging
 //       races as intentional and benign. Races in C++ are undefined behavior
@@ -51,56 +29,17 @@ extern "C" const char* __tsan_default_op
 // a signature for each of the two race stacks. Sometimes, TSan fails to
 // symbolize one of the two traces and this can cause suppressed races to
 // show up intermittently.
 //
 extern "C" const char* __tsan_default_suppressions() {
   return "# Add your suppressions below\n"
 
          // External uninstrumented libraries
-         "called_from_lib:libatk-1\n"
-         "called_from_lib:libcairo.so\n"
-         "called_from_lib:libcairo-gobject\n"
-         "called_from_lib:libgdk-3\n"
-         "called_from_lib:libgdk_pixbuf\n"
-         "called_from_lib:libgdk-x11\n"
-         "called_from_lib:libgio-2\n"
-         "called_from_lib:libglib-1\n"
-         "called_from_lib:libglib-2\n"
-         "called_from_lib:libgobject\n"
-         "called_from_lib:libgtk-3\n"
-         "called_from_lib:libgtk-x11\n"
-         "called_from_lib:libgvfscommon\n"
-         "called_from_lib:libgvfsdbus\n"
-         "called_from_lib:libibus-1\n"
-         "called_from_lib:libogg.so\n"
-         "called_from_lib:libpangocairo\n"
-         "called_from_lib:libpangoft2\n"
-         "called_from_lib:pango-basic-fc\n"
-         "called_from_lib:libpixman-1\n"
-         "called_from_lib:libpulse.so\n"
-         "called_from_lib:libpulsecommon\n"
-         "called_from_lib:libsecret-1\n"
-         "called_from_lib:libunity-gtk3-parser\n"
-         "called_from_lib:libvorbis.so\n"
-         "called_from_lib:libvorbisfile\n"
-         "called_from_lib:libX11.so\n"
-         "called_from_lib:libX11-xcb\n"
-         "called_from_lib:libXau\n"
-         "called_from_lib:libxcb.so\n"
-         "called_from_lib:libXcomposite\n"
-         "called_from_lib:libXcursor\n"
-         "called_from_lib:libXdamage\n"
-         "called_from_lib:libXdmcp\n"
-         "called_from_lib:libXext\n"
-         "called_from_lib:libXfixes\n"
-         "called_from_lib:libXi.so\n"
-         "called_from_lib:libXrandr\n"
-         "called_from_lib:libXrender\n"
-         "called_from_lib:libXss\n"
+         MOZ_TSAN_DEFAULT_EXTLIB_SUPPRESSIONS
 
          // These libraries are uninstrumented and cause mutex false positives.
          // However, they can be unloaded by GTK early which we cannot avoid.
          "mutex:libGL.so\n"
          "mutex:libGLdispatch\n"
          "mutex:libGLX\n"
 
          // For some reason, the suppressions on libpulse.so
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/update/updater/TsanOptions.cpp
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/Attributes.h"
+#include "mozilla/TsanOptions.h"
+
+#ifndef _MSC_VER  // Not supported by clang-cl yet
+
+// See also mozglue/build/TsanOptions.cpp before modifying this
+extern "C" const char* __tsan_default_suppressions() {
+  return "# Add your suppressions below\n"
+
+         // External uninstrumented libraries
+         MOZ_TSAN_DEFAULT_EXTLIB_SUPPRESSIONS
+
+         // Bug 1623034
+         "race:QuitProgressUI\n"
+         "race:ShowProgressUI\n"
+
+      // End of suppressions.
+      ;  // Please keep this semicolon.
+}
+#endif  // _MSC_VER
--- a/toolkit/mozapps/update/updater/updater-common.build
+++ b/toolkit/mozapps/update/updater/updater-common.build
@@ -73,16 +73,23 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
 
 if have_progressui == 0:
     srcs += [
         'progressui_null.cpp',
     ]
 
 SOURCES += sorted(srcs)
 
+if CONFIG['MOZ_TSAN']:
+    # Since mozglue is not linked to the updater,
+    # we need to include our own TSan suppression list.
+    SOURCES += [
+        'TsanOptions.cpp',
+    ]
+
 DEFINES['NS_NO_XPCOM'] = True
 DisableStlWrapping()
 for var in ('MAR_CHANNEL_ID', 'MOZ_APP_VERSION'):
     DEFINES[var] = '"%s"' % CONFIG[var]
 
 LOCAL_INCLUDES += [
     '/toolkit/mozapps/update/common',
     '/xpcom/base', # for nsVersionComparator.cpp