Bug 862404 - Make nsCxPusher MOZ_CRASH if there's no stack. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Wed, 24 Apr 2013 13:02:47 -0700
changeset 129793 fa0fd4f8992bb8f9b2f962dfaee16a4b86306e1a
parent 129792 34cc4f6ad4a27282e63607a78b2f84c5f06ebfb4
child 129794 10bdfbe0195b06b281745c35adc0b7d70f066bb7
push id27010
push userbobbyholley@gmail.com
push dateWed, 24 Apr 2013 20:03:16 +0000
treeherdermozilla-inbound@fa0fd4f8992b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs862404
milestone23.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 862404 - Make nsCxPusher MOZ_CRASH if there's no stack. r=gabor
content/base/src/nsContentUtils.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3142,17 +3142,19 @@ nsCxPusher::Push(JSContext *cx)
   DoPush(cx);
 }
 
 void
 nsCxPusher::DoPush(JSContext* cx)
 {
   nsIThreadJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
   if (!stack) {
-    return;
+    // If someone tries to push a cx when we don't have the relevant state,
+    // it's probably safest to just crash.
+    MOZ_CRASH();
   }
 
   if (cx && IsContextOnStack(stack, cx)) {
     // If the context is on the stack, that means that a script
     // is running at the moment in the context.
     mScriptIsRunning = true;
   }
 
@@ -3173,17 +3175,18 @@ nsCxPusher::PushNull()
 {
   DoPush(nullptr);
 }
 
 void
 nsCxPusher::Pop()
 {
   nsIThreadJSContextStack* stack = nsContentUtils::ThreadJSContextStack();
-  if (!mPushedSomething || !stack) {
+  MOZ_ASSERT(stack);
+  if (!mPushedSomething) {
     mScx = nullptr;
     mPushedSomething = false;
 
     NS_ASSERTION(!mScriptIsRunning, "Huh, this can't be happening, "
                  "mScriptIsRunning can't be set here!");
 
     return;
   }