Bug 1021124 - Bail out of InterruptCallback if we're too early in startup. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Thu, 05 Jun 2014 12:29:42 -0700
changeset 186875 7792ac87eb27c950519e95d9aacd2675957c1d3a
parent 186874 8635607dedea28daa0cad89bcb09fbc492035289
child 186876 b1e0a1050d9b8afb8916608b04417ae290ba7794
push id44455
push userbobbyholley@gmail.com
push dateThu, 05 Jun 2014 19:29:53 +0000
treeherdermozilla-inbound@7792ac87eb27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1021124
milestone32.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 1021124 - Bail out of InterruptCallback if we're too early in startup. r=bz
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1381,16 +1381,21 @@ XPCJSRuntime::InterruptCallback(JSContex
 
     // If this is the first time the interrupt callback has fired since we last
     // returned to the event loop, mark the checkpoint.
     if (self->mSlowScriptCheckpoint.IsNull()) {
         self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();
         return true;
     }
 
+    // Sometimes we get called back during XPConnect initialization, before Gecko
+    // has finished bootstrapping. Avoid crashing in nsContentUtils below.
+    if (!nsContentUtils::IsInitialized())
+        return true;
+
     // This is at least the second interrupt callback we've received since
     // returning to the event loop. See how long it's been, and what the limit
     // is.
     TimeDuration duration = TimeStamp::NowLoRes() - self->mSlowScriptCheckpoint;
     bool chrome = nsContentUtils::IsCallerChrome();
     const char *prefName = chrome ? "dom.max_chrome_script_run_time"
                                   : "dom.max_script_run_time";
     int32_t limit = Preferences::GetInt(prefName, chrome ? 20 : 10);