bug 1358151: temporary workaround for rust race condition
MozReview-Commit-ID: KiPArBKMSu1
--- 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")) {