bug 1358151: temporary workaround for rust race condition r=ted
authorCarl Corcoran <carlco@gmail.com>
Sat, 06 May 2017 14:05:09 +0200
changeset 357236 3bc93cae8482f672720ca636e3dee5a65aabdcb3
parent 357235 ece97e873769c5892bf720ca12a2fbc29956526a
child 357237 38346bf36faaff4fa4d99ba88d66475f8a18ac57
push id31788
push userkwierso@gmail.com
push dateTue, 09 May 2017 20:48:49 +0000
treeherdermozilla-central@2b6f6881a24a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1358151
milestone55.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 1358151: temporary workaround for rust race condition r=ted MozReview-Commit-ID: KiPArBKMSu1
toolkit/library/rust/shared/lib.rs
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/library/rust/shared/lib.rs
+++ b/toolkit/library/rust/shared/lib.rs
@@ -14,16 +14,26 @@ extern crate webrender_bindings;
 #[cfg(feature = "cubeb_pulse_rust")]
 extern crate cubeb_pulse;
 
 use std::boxed::Box;
 use std::ffi::CStr;
 use std::os::raw::c_char;
 use std::panic;
 
+
+
+// This workaround is fixed in Rust 1.19. For details, see bug 1358151.
+thread_local!(static UNUSED_THREAD_LOCAL: () = ());
+#[no_mangle]
+pub extern "C" fn rust_init_please_remove_this_after_updating_rust_1_19() {
+    UNUSED_THREAD_LOCAL.with(|_| ());
+}
+
+
 /// Used to implement `nsIDebug2::RustPanic` for testing purposes.
 #[no_mangle]
 pub extern "C" fn intentional_panic(message: *const c_char) {
     panic!("{}", unsafe { CStr::from_ptr(message) }.to_string_lossy());
 }
 
 /// Contains the panic message, if set.
 static mut PANIC_REASON: Option<(*const str, usize)> = None;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -219,16 +219,22 @@
 #include "SandboxBroker.h"
 #include "SandboxPermissions.h"
 #endif
 #endif
 
 extern uint32_t gRestartMode;
 extern void InstallSignalHandlers(const char *ProgramName);
 
+// This workaround is fixed in Rust 1.19. For details, see bug 1358151.
+// Implementation in toolkit/library/rust/shared/lib.rs
+extern "C" {
+  void rust_init_please_remove_this_after_updating_rust_1_19();
+}
+
 #define FILE_COMPATIBILITY_INFO NS_LITERAL_CSTRING("compatibility.ini")
 #define FILE_INVALIDATE_CACHES NS_LITERAL_CSTRING(".purgecaches")
 
 int    gArgc;
 char **gArgv;
 
 static const char gToolkitVersion[] = NS_STRINGIFY(GRE_MILESTONE);
 static const char gToolkitBuildID[] = NS_STRINGIFY(MOZ_BUILDID);
@@ -3109,16 +3115,19 @@ public:
  */
 int
 XREMain::XRE_mainInit(bool* aExitFlag)
 {
   if (!aExitFlag)
     return 1;
   *aExitFlag = false;
 
+  // This workaround is fixed in Rust 1.19. For details, see bug 1358151.
+  rust_init_please_remove_this_after_updating_rust_1_19();
+
   atexit(UnexpectedExit);
   auto expectedShutdown = mozilla::MakeScopeExit([&] {
     MozExpectedExit();
   });
 
   StartupTimeline::Record(StartupTimeline::MAIN);
 
   if (PR_GetEnv("MOZ_CHAOSMODE")) {