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

This commit is contained in:
Benjamin Smedberg 2011-02-16 11:52:31 -05:00
Родитель aefebf42e6
Коммит d48741412b
2 изменённых файлов: 22 добавлений и 16 удалений

Просмотреть файл

@ -167,22 +167,19 @@ nsXPConnect::GetXPConnect()
if(!gSelf) if(!gSelf)
return nsnull; return nsnull;
if(!gSelf->mRuntime || if (!gSelf->mRuntime) {
!gSelf->mInterfaceInfoManager) NS_RUNTIMEABORT("Couldn't create XPCJSRuntime.");
{
// ctor failed to create an acceptable instance
delete gSelf;
gSelf = nsnull;
} }
else 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); // Initial extra ref to keep the singleton alive
if (NS_FAILED(NS_SetGlobalThreadObserver(gSelf))) { // balanced by explicit call to ReleaseXPConnectSingleton()
NS_RELEASE(gSelf); NS_ADDREF(gSelf);
// Fall through to returning null if (NS_FAILED(NS_SetGlobalThreadObserver(gSelf))) {
} NS_RELEASE(gSelf);
// Fall through to returning null
} }
} }
return gSelf; return gSelf;

Просмотреть файл

@ -1354,7 +1354,9 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
mStrIDs[0] = JSID_VOID; mStrIDs[0] = JSID_VOID;
mJSRuntime = JS_NewRuntime(32L * 1024L * 1024L); // pref ? 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 // Unconstrain the runtime's threshold on nominal heap size, to avoid
// triggering GC too often if operating continuously near an arbitrary // triggering GC too often if operating continuously near an arbitrary
@ -1371,6 +1373,8 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
xpc::WrapperFactory::Rewrap, xpc::WrapperFactory::Rewrap,
xpc::WrapperFactory::PrepareForWrapping); xpc::WrapperFactory::PrepareForWrapping);
mWatchdogWakeup = JS_NEW_CONDVAR(mJSRuntime->gcLock); mWatchdogWakeup = JS_NEW_CONDVAR(mJSRuntime->gcLock);
if (!mWatchdogWakeup)
NS_RUNTIMEABORT("JS_NEW_CONDVAR failed.");
mJSRuntime->setActivityCallback(ActivityCallback, this); mJSRuntime->setActivityCallback(ActivityCallback, this);
@ -1400,6 +1404,8 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this, mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this,
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
PR_UNJOINABLE_THREAD, 0); PR_UNJOINABLE_THREAD, 0);
if (!mWatchdogThread)
NS_RUNTIMEABORT("PR_CreateThread failed!");
} }
} }
@ -1427,6 +1433,9 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect)
{ {
return self; return self;
} }
NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize.");
delete self; delete self;
return nsnull; return nsnull;
} }