Title: [130335] trunk/Source/WebCore
Revision
130335
Author
jsb...@chromium.org
Date
2012-10-03 15:41:57 -0700 (Wed, 03 Oct 2012)

Log Message

IndexedDB: Memory leak when deleting object stores with indexes
https://bugs.webkit.org/show_bug.cgi?id=98292

Reviewed by Tony Chang.

Reference cycles between IDBObjectStore and IDBIndex instances are explicitly
broken when the transaction completes (and the spec allows traversal to fail).
Deleted stores need to have the reference cycle broken too.

Caught by running valgrind over: storage/indexeddb/keypath-basics.html

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::objectStoreDeleted): Add store to set.
(WebCore::IDBTransaction::dispatchEvent): Notify stores in set.
* Modules/indexeddb/IDBTransaction.h: Add set of deleted stores.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130334 => 130335)


--- trunk/Source/WebCore/ChangeLog	2012-10-03 22:41:28 UTC (rev 130334)
+++ trunk/Source/WebCore/ChangeLog	2012-10-03 22:41:57 UTC (rev 130335)
@@ -1,3 +1,21 @@
+2012-10-03  Joshua Bell  <jsb...@chromium.org>
+
+        IndexedDB: Memory leak when deleting object stores with indexes
+        https://bugs.webkit.org/show_bug.cgi?id=98292
+
+        Reviewed by Tony Chang.
+
+        Reference cycles between IDBObjectStore and IDBIndex instances are explicitly
+        broken when the transaction completes (and the spec allows traversal to fail).
+        Deleted stores need to have the reference cycle broken too.
+
+        Caught by running valgrind over: storage/indexeddb/keypath-basics.html
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::objectStoreDeleted): Add store to set.
+        (WebCore::IDBTransaction::dispatchEvent): Notify stores in set.
+        * Modules/indexeddb/IDBTransaction.h: Add set of deleted stores.
+
 2012-10-03  Adam Barth  <aba...@webkit.org>
 
         CSSNamespace.h is empty and should be deleted

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (130334 => 130335)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2012-10-03 22:41:28 UTC (rev 130334)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp	2012-10-03 22:41:57 UTC (rev 130335)
@@ -186,6 +186,7 @@
         m_objectStoreMap.remove(name);
         objectStore->markDeleted();
         m_objectStoreCleanupMap.set(objectStore, objectStore->metadata());
+        m_deletedObjectStores.add(objectStore);
     }
 }
 
@@ -386,6 +387,9 @@
     for (IDBObjectStoreMap::iterator it = m_objectStoreMap.begin(); it != m_objectStoreMap.end(); ++it)
         it->second->transactionFinished();
     m_objectStoreMap.clear();
+    for (IDBObjectStoreSet::iterator it = m_deletedObjectStores.begin(); it != m_deletedObjectStores.end(); ++it)
+        (*it)->transactionFinished();
+    m_deletedObjectStores.clear();
 
     Vector<RefPtr<EventTarget> > targets;
     targets.append(this);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h (130334 => 130335)


--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2012-10-03 22:41:28 UTC (rev 130334)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h	2012-10-03 22:41:57 UTC (rev 130335)
@@ -158,6 +158,9 @@
     typedef HashMap<String, RefPtr<IDBObjectStore> > IDBObjectStoreMap;
     IDBObjectStoreMap m_objectStoreMap;
 
+    typedef HashSet<RefPtr<IDBObjectStore> > IDBObjectStoreSet;
+    IDBObjectStoreSet m_deletedObjectStores;
+
     typedef HashMap<RefPtr<IDBObjectStore>, IDBObjectStoreMetadata> IDBObjectStoreMetadataMap;
     IDBObjectStoreMetadataMap m_objectStoreCleanupMap;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to