Bug 1317642 Disable WeakPtr thread assertions on MinGW r=froydnj
authorTom Ritter <tom@mozilla.com>
Fri, 13 Jan 2017 13:50:21 -0600
changeset 374971 1bc3ddd4cdc3b3546375cde989845b73c4f89165
parent 374970 5b25f62eff46f1332a62760efba4d04266bfa0fa
child 374972 c6673f7e07d3068a041e7e7fbb02a001b070fdce
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1317642
milestone53.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 1317642 Disable WeakPtr thread assertions on MinGW r=froydnj MinGW has two threading models: win32 API based, which disables std::thread, and POSIX based which enables it but requires an emulation library (winpthreads). Rather than attempting to switch to pthread emulation at this point, we are disabling the std::thread based assertion checking for WeakPtr on MinGW. MozReview-Commit-ID: BmHo70n6AuK
mfbt/WeakPtr.h
--- a/mfbt/WeakPtr.h
+++ b/mfbt/WeakPtr.h
@@ -83,18 +83,29 @@
 // the real object destruction just between when thread A is storing
 // the object pointer locally and is about to add a reference to it.
 //
 // Hence, a non-null weak proxy object is considered to have a single
 // "owning thread".  It means that each query for a weak reference,
 // its dereference, and destruction of the real object must all happen
 // on a single thread.  The following macros implement assertions for
 // checking these conditions.
+//
+// We disable this on MinGW. MinGW has two threading models: win32
+// API based, which disables std::thread; and POSIX based which
+// enables it but requires an emulation library (winpthreads).
+// Rather than attempting to switch to pthread emulation at this point,
+// we are disabling the std::thread based assertion checking.
+//
+// In the future, to enable it we could
+// a. have libgcc/stdc++ support win32 threads natively
+// b. switch to POSIX-based threading in MinGW with pthread emulation
+// c. refactor it to not use std::thread
 
-#if defined(DEBUG) || (defined(NIGHTLY_BUILD) && !defined(MOZ_PROFILING))
+#if !defined(__MINGW32__) && (defined(DEBUG) || (defined(NIGHTLY_BUILD) && !defined(MOZ_PROFILING)))
 
 #include <thread>
 #define MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK \
   std::thread::id _owningThread; \
   bool _empty; // If it was initialized as a placeholder with mPtr = nullptr.
 #define MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK() \
   do { \
     _owningThread = std::this_thread::get_id(); \