Commits

Blake Kaplan  committed efab2ed

Bug 584551 - Do things that require entering a request on the old compartment before entering a request on the new one. r=igor a=blocking-beta3

  • Participants
  • Parent commits 3e2124f
  • Branches GECKO20b3_20100804_RELBRANCH

Comments (0)

Files changed (1)

File js/src/xpconnect/src/xpccallcontext.cpp

             return;
     }
 
-    // Get into the request as early as we can to avoid problems with scanning
-    // callcontexts on other threads from within the gc callbacks.
-
-    NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
-                 "Don't call JS_BeginRequest unless the caller is native.");
-    if(callBeginRequest)
-        JS_BeginRequest(mJSContext);
-
     if(topJSContext != mJSContext)
     {
         if(NS_FAILED(stack->Push(mJSContext)))
         mContextPopRequired = JS_TRUE;
     }
 
+    // Get into the request as early as we can to avoid problems with scanning
+    // callcontexts on other threads from within the gc callbacks.
+
+    NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
+                 "Don't call JS_BeginRequest unless the caller is native.");
+    if(callBeginRequest)
+        JS_BeginRequest(mJSContext);
+
     mXPCContext = XPCContext::GetXPCContext(mJSContext);
     mPrevCallerLanguage = mXPCContext->SetCallingLangType(mCallerLanguage);
 
         shouldReleaseXPC = mPrevCallContext == nsnull;
     }
 
+    // NB: Needs to happen before the context stack pop.
+    if(mJSContext && mCallerLanguage == NATIVE_CALLER)
+        JS_EndRequest(mJSContext);
+
     if(mContextPopRequired)
     {
         XPCJSContextStack* stack = mThreadData->GetJSContextStack();
 
     if(mJSContext)
     {
-        if(mCallerLanguage == NATIVE_CALLER)
-            JS_EndRequest(mJSContext);
-        
         if(mDestroyJSContextInDestructor)
         {
 #ifdef DEBUG_xpc_hacker