From 871c7d16bfc980701f38e1b4ead3bfbdeca01307 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Wed, 16 Feb 2011 11:52:31 -0500 Subject: [PATCH] More diagnostics for bug 626768 - It seems likely that creating a new XPCJSRuntime is failing, but we don't know why or when. Abort in the most obvious failure location to help diagnose the problem. r=bent a=myself --- js/src/xpconnect/src/nsXPConnect.cpp | 27 ++++++++++++--------------- js/src/xpconnect/src/xpcjsruntime.cpp | 11 ++++++++++- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/js/src/xpconnect/src/nsXPConnect.cpp b/js/src/xpconnect/src/nsXPConnect.cpp index 7fcdf6aacbde..eea9783b6002 100644 --- a/js/src/xpconnect/src/nsXPConnect.cpp +++ b/js/src/xpconnect/src/nsXPConnect.cpp @@ -167,22 +167,19 @@ nsXPConnect::GetXPConnect() if(!gSelf) return nsnull; - if(!gSelf->mRuntime || - !gSelf->mInterfaceInfoManager) - { - // ctor failed to create an acceptable instance - delete gSelf; - gSelf = nsnull; + if (!gSelf->mRuntime) { + NS_RUNTIMEABORT("Couldn't create XPCJSRuntime."); } - else - { - // Initial extra ref to keep the singleton alive - // balanced by explicit call to ReleaseXPConnectSingleton() - NS_ADDREF(gSelf); - if (NS_FAILED(NS_SetGlobalThreadObserver(gSelf))) { - NS_RELEASE(gSelf); - // Fall through to returning null - } + if (!gSelf->mInterfaceInfoManager) { + NS_RUNTIMEABORT("Couldn't get global interface info manager."); + } + + // Initial extra ref to keep the singleton alive + // balanced by explicit call to ReleaseXPConnectSingleton() + NS_ADDREF(gSelf); + if (NS_FAILED(NS_SetGlobalThreadObserver(gSelf))) { + NS_RELEASE(gSelf); + // Fall through to returning null } } return gSelf; diff --git a/js/src/xpconnect/src/xpcjsruntime.cpp b/js/src/xpconnect/src/xpcjsruntime.cpp index 6c6f1841df4c..3e9e664791e6 100644 --- a/js/src/xpconnect/src/xpcjsruntime.cpp +++ b/js/src/xpconnect/src/xpcjsruntime.cpp @@ -1354,7 +1354,9 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) mStrIDs[0] = JSID_VOID; mJSRuntime = JS_NewRuntime(32L * 1024L * 1024L); // pref ? - if(mJSRuntime) + if (!mJSRuntime) + NS_RUNTIMEABORT("JS_NewRuntime failed."); + { // Unconstrain the runtime's threshold on nominal heap size, to avoid // triggering GC too often if operating continuously near an arbitrary @@ -1371,6 +1373,8 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) xpc::WrapperFactory::Rewrap, xpc::WrapperFactory::PrepareForWrapping); mWatchdogWakeup = JS_NEW_CONDVAR(mJSRuntime->gcLock); + if (!mWatchdogWakeup) + NS_RUNTIMEABORT("JS_NEW_CONDVAR failed."); mJSRuntime->setActivityCallback(ActivityCallback, this); @@ -1400,6 +1404,8 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_UNJOINABLE_THREAD, 0); + if (!mWatchdogThread) + NS_RUNTIMEABORT("PR_CreateThread failed!"); } } @@ -1427,6 +1433,9 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect) { return self; } + + NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize."); + delete self; return nsnull; }