Bug 503638 OOM crash [@ PL_DHashTableOperate | _MD_CURRENT_THREAD] in nsCycleCollector
authortimeless@mozdev.org
Sun, 28 Feb 2010 11:23:59 +0100
changeset 38789 3874a469cf09eec52542b8ddd64b3869b3811863
parent 38788 16e2bf477e1be0a38744507392cab27985ca28f8
child 38790 8fdae602e9b05b9f947f0ec93cc33099bc865b2b
child 38793 7b97c72399a0d6d2e26bb19a14b8c02c5bf268e2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs503638
milestone1.9.3a2pre
Bug 503638 OOM crash [@ PL_DHashTableOperate | _MD_CURRENT_THREAD] in nsCycleCollector r=dbaron
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -1372,16 +1372,17 @@ private:
 #ifdef DEBUG_CC
     nsCString mNextEdgeName;
 #endif
 
 public:
     GCGraphBuilder(GCGraph &aGraph,
                    nsCycleCollectionLanguageRuntime **aRuntimes);
     ~GCGraphBuilder();
+    bool Initialized();
 
     PRUint32 Count() const { return mPtrToNodeMap.entryCount; }
 
 #ifdef DEBUG_CC
     PtrInfo* AddNode(void *s, nsCycleCollectionParticipant *aParticipant,
                      PRUint32 aLangID);
 #else
     PtrInfo* AddNode(void *s, nsCycleCollectionParticipant *aParticipant);
@@ -1425,16 +1426,22 @@ GCGraphBuilder::GCGraphBuilder(GCGraph &
 }
 
 GCGraphBuilder::~GCGraphBuilder()
 {
     if (mPtrToNodeMap.ops)
         PL_DHashTableFinish(&mPtrToNodeMap);
 }
 
+bool
+GCGraphBuilder::Initialized()
+{
+    return !!mPtrToNodeMap.ops;
+}
+
 PtrInfo*
 GCGraphBuilder::AddNode(void *s, nsCycleCollectionParticipant *aParticipant
                         IF_DEBUG_CC_PARAM(PRUint32 aLangID)
                        )
 {
     PtrToNodeEntry *e = static_cast<PtrToNodeEntry*>(PL_DHashTableOperate(&mPtrToNodeMap, s, PL_DHASH_ADD));
     if (!e)
         return nsnull;
@@ -2576,16 +2583,18 @@ nsCycleCollector::Collect(PRUint32 aTryC
 
 PRBool
 nsCycleCollector::BeginCollection()
 {
     if (mParams.mDoNothing)
         return PR_FALSE;
 
     GCGraphBuilder builder(mGraph, mRuntimes);
+    if (!builder.Initialized())
+        return PR_FALSE;
 
 #ifdef COLLECT_TIME_DEBUG
     PRTime now = PR_Now();
 #endif
     for (PRUint32 i = 0; i <= nsIProgrammingLanguage::MAX; ++i) {
         if (mRuntimes[i])
             mRuntimes[i]->BeginCycleCollection(builder);
     }