Bug 1529125 - Add IOInterposerInit to xpc shell tests; r=froydnj
authorGreg Tatum <gtatum@mozilla.com>
Tue, 26 Feb 2019 15:27:20 +0000
changeset 461728 1bc807fb4c895d326aafc4a5bc5c9239c093b432
parent 461727 d2dc3e5300c01da642064140435b9881b13deb22
child 461729 fdd37ef2117ba74c8eb64eaaaa8e9d4d59bce0f7
push id35627
push useropoprus@mozilla.com
push dateThu, 28 Feb 2019 21:44:07 +0000
treeherdermozilla-central@db533ea3d561 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1529125
milestone67.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 1529125 - Add IOInterposerInit to xpc shell tests; r=froydnj Add an RAII guarded initialization for the IO interposer to the initialization process for xpc shell tests. This ensures that whenever an xpcshell tests uses the IOInterposer, that it will correctly catch all registered threads, and will not miss any. Differential Revision: https://phabricator.services.mozilla.com/D20736
js/xpconnect/src/XPCShellImpl.cpp
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -9,16 +9,17 @@
 #include "jsfriendapi.h"
 #include "js/CharacterEncoding.h"
 #include "js/CompilationAndEvaluation.h"
 #include "js/ContextOptions.h"
 #include "js/Printf.h"
 #include "js/PropertySpec.h"
 #include "mozilla/ChaosMode.h"
 #include "mozilla/dom/ScriptSettings.h"
+#include "mozilla/IOInterposer.h"
 #include "mozilla/Preferences.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsExceptionHandler.h"
 #include "nsIServiceManager.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsIDirectoryService.h"
@@ -1070,16 +1071,20 @@ int XRE_XPCShellMain(int argc, char** ar
   gErrFile = stderr;
   gOutFile = stdout;
   gInFile = stdin;
 
   NS_LogInit();
 
   mozilla::LogModule::Init(argc, argv);
 
+  // This guard ensures that all threads that attempt to register themselves
+  // with the IOInterposer will be properly tracked.
+  mozilla::IOInterposerInit ioInterposerGuard;
+
 #ifdef MOZ_GECKO_PROFILER
   char aLocal;
   profiler_init(&aLocal);
 #endif
 
 #ifdef MOZ_ASAN_REPORTER
   PR_SetEnv("MOZ_DISABLE_ASAN_REPORTER=1");
 #endif