WebKit Bugzilla
Attachment 362196 Details for
Bug 194709
: IndexedDB: IDBDatabase and IDBTransaction are leaked in layout tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194709-20190215175936.patch (text/plain), 9.65 KB, created by
Sihui Liu
on 2019-02-15 17:59:37 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Sihui Liu
Created:
2019-02-15 17:59:37 PST
Size:
9.65 KB
patch
obsolete
>Subversion Revision: 241453 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 22adac6207dfa3690eae59a963fa1db62847e746..15cebdf0c332713adb4e063319235cd26e52f3be 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2019-02-15 Sihui Liu <sihui_liu@apple.com> >+ >+ IndexedDB: leak IDBDatabase and IDBTransacstion in layout tests >+ https://bugs.webkit.org/show_bug.cgi?id=194709 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ When connection to IDB server is closed, IDBTransaction would abort without notifying IDBDatabase, so >+ IDBDatabase didn't clear its reference to IDBTransaction which created a reference cycle. >+ >+ Also IDBTransaction didn't clear its reference to IDBRequest in this case and it led to another reference cycle >+ between IDBOpenDBRequest and IDBTransaction. >+ >+ Test: storage/indexeddb/IDBObject-leak.html >+ >+ * Modules/indexeddb/IDBDatabase.cpp: >+ (WebCore::IDBDatabase::connectionToServerLost): >+ * Modules/indexeddb/IDBTransaction.cpp: >+ (WebCore::IDBTransaction::IDBTransaction): >+ (WebCore::IDBTransaction::~IDBTransaction): >+ (WebCore::IDBTransaction::finishedDispatchEventForRequest): >+ (WebCore::IDBTransaction::connectionClosedFromServer): >+ * Modules/indexeddb/IDBTransaction.h: >+ * testing/Internals.cpp: >+ (WebCore::Internals::numberOfIDBTransactions const): >+ * testing/Internals.h: >+ * testing/Internals.idl: >+ > 2019-02-13 John Wilander <wilander@apple.com> > > Store Ad Click Attribution requests in the network process >diff --git a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >index 1847439190a8b79bef706432fd2f9d7556907365..0a095725fd2fbd324b957118924149eba26364e7 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp >@@ -264,7 +264,8 @@ void IDBDatabase::connectionToServerLost(const IDBError& error) > m_closePending = true; > m_closedInServer = true; > >- for (auto& transaction : m_activeTransactions.values()) >+ auto transactions = copyToVector(m_activeTransactions.values()); >+ for (auto& transaction : transactions) > transaction->connectionClosedFromServer(error); > > auto errorEvent = Event::create(m_eventNames.errorEvent, Event::CanBubble::Yes, Event::IsCancelable::No); >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >index 2e965e97d2909ec0c70f3f8741a188ff6c549b2f..0c2caeb6470ef6dce2d51263072895fa8e04f878 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp >@@ -79,6 +79,9 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& > , m_currentlyCompletingRequest(request) > > { >+ auto addResult = allIDBTransactions().add(this); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ > LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data()); > ASSERT(&m_database->originThread() == &Thread::current()); > >@@ -106,6 +109,14 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo& > IDBTransaction::~IDBTransaction() > { > ASSERT(&m_database->originThread() == &Thread::current()); >+ ASSERT(allIDBTransactions().contains(this)); >+ allIDBTransactions().remove(this); >+} >+ >+HashSet<IDBTransaction*>& IDBTransaction::allIDBTransactions() >+{ >+ static NeverDestroyed<HashSet<IDBTransaction*>> transactions; >+ return transactions; > } > > IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy() >@@ -484,6 +495,7 @@ void IDBTransaction::completeCursorRequest(IDBRequest& request, const IDBResultD > > void IDBTransaction::finishedDispatchEventForRequest(IDBRequest& request) > { >+ WTFLogAlways("sihuil: [%p]IDBTransaction::finishedDispatchEventForRequest", this); > if (isFinishedOrFinishing()) > return; > >@@ -1434,7 +1446,8 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > { > LOG(IndexedDB, "IDBTransaction::connectionClosedFromServer - %s", error.message().utf8().data()); > >- m_state = IndexedDB::TransactionState::Aborting; >+ m_database->willAbortTransaction(*this); >+ transitionedToFinishing(IndexedDB::TransactionState::Aborting); > > abortInProgressOperations(error); > >@@ -1445,6 +1458,7 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > ASSERT(m_transactionOperationsInProgressQueue.first() == operation.get()); > operation->doComplete(IDBResultData::error(operation->identifier(), error)); > } >+ m_currentlyCompletingRequest = nullptr; > > connectionProxy().forgetActiveOperations(operations); > >@@ -1454,6 +1468,7 @@ void IDBTransaction::connectionClosedFromServer(const IDBError& error) > > m_idbError = error; > m_domError = error.toDOMException(); >+ m_database->didAbortTransaction(*this); > fireOnAbort(); > } > >diff --git a/Source/WebCore/Modules/indexeddb/IDBTransaction.h b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >index 722f12c84a787dc1a32a33bc5d236f0cecdc4f04..edd15e6c10efcd084513057460df26550876d646 100644 >--- a/Source/WebCore/Modules/indexeddb/IDBTransaction.h >+++ b/Source/WebCore/Modules/indexeddb/IDBTransaction.h >@@ -152,6 +152,8 @@ public: > > void visitReferencedObjectStores(JSC::SlotVisitor&) const; > >+ WEBCORE_EXPORT static HashSet<IDBTransaction*>& allIDBTransactions(); >+ > private: > IDBTransaction(IDBDatabase&, const IDBTransactionInfo&, IDBOpenDBRequest*); > >diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp >index 729e9cf248986bc6c7af714402373c153b28080c..f6c50b5782b25e0c1af5a45c8e6fcb4cdb29dcb4 100644 >--- a/Source/WebCore/testing/Internals.cpp >+++ b/Source/WebCore/testing/Internals.cpp >@@ -93,6 +93,8 @@ > #include "HistoryController.h" > #include "HistoryItem.h" > #include "HitTestResult.h" >+#include "IDBRequest.h" >+#include "IDBTransaction.h" > #include "InspectorClient.h" > #include "InspectorController.h" > #include "InspectorFrontendClientLocal.h" >@@ -2383,6 +2385,11 @@ ExceptionOr<unsigned> Internals::countFindMatches(const String& text, const Vect > return document->page()->countFindMatches(text, parsedOptions.releaseReturnValue(), 1000); > } > >+unsigned Internals::numberOfIDBTransactions() const >+{ >+ return IDBTransaction::allIDBTransactions().size(); >+} >+ > unsigned Internals::numberOfLiveNodes() const > { > unsigned nodeCount = 0; >diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h >index 1151ef238c497357caa7d21f79cdf399b156b640..fa2d47e5bd1869a37b10699abbe4214eb74a2c47 100644 >--- a/Source/WebCore/testing/Internals.h >+++ b/Source/WebCore/testing/Internals.h >@@ -378,6 +378,8 @@ public: > ExceptionOr<void> insertAuthorCSS(const String&) const; > ExceptionOr<void> insertUserCSS(const String&) const; > >+ unsigned numberOfIDBTransactions() const; >+ > unsigned numberOfLiveNodes() const; > unsigned numberOfLiveDocuments() const; > unsigned referencingNodeCount(const Document&) const; >diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl >index f56ad64e6e480a19d8c3706c236cdcb338ba73bd..ed2b4298b1ddeeeea28f91a460743518197ff6ce 100644 >--- a/Source/WebCore/testing/Internals.idl >+++ b/Source/WebCore/testing/Internals.idl >@@ -405,6 +405,8 @@ enum CompositingPolicy { > void beginSimulatedMemoryPressure(); > void endSimulatedMemoryPressure(); > >+ unsigned long numberOfIDBTransactions(); >+ > unsigned long numberOfLiveNodes(); > unsigned long numberOfLiveDocuments(); > unsigned long referencingNodeCount(Document document); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 5b043279ca759f9f5d4773871d9c2099da99ad47..fbfe9524e289a1fa9c35b481ad4ab92014ef3c59 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2019-02-15 Sihui Liu <sihui_liu@apple.com> >+ >+ IndexedDB: leak IDBDatabase and IDBTransacstion in layout tests >+ https://bugs.webkit.org/show_bug.cgi?id=194709 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * storage/indexeddb/IDBObject-leak.html: Added. >+ > 2019-02-13 John Wilander <wilander@apple.com> > > Store Ad Click Attribution requests in the network process >diff --git a/LayoutTests/storage/indexeddb/IDBObject-leak.html b/LayoutTests/storage/indexeddb/IDBObject-leak.html >new file mode 100644 >index 0000000000000000000000000000000000000000..5507b82bf7806719224bedcb3e92e3bc6655c49e >--- /dev/null >+++ b/LayoutTests/storage/indexeddb/IDBObject-leak.html >@@ -0,0 +1,38 @@ >+<!DOCTYPE html> >+<script src="../../resources/js-test.js"></script> >+<script src="resources/shared.js"></script> >+<script> >+description('This test verifies that IDBTransaction objects are freed.'); >+ >+function test() { >+ if (!window.internals || !internals.numberOfIDBTransactions) { >+ testFailed('This test requires access to the Internals object'); >+ finishJSTest(); >+ return; >+ } >+ >+ if (sessionStorage.doneFirstLoad) { >+ gc(); >+ shouldBeEqualToNumber("internals.numberOfIDBTransactions()", 0); >+ finishJSTest(); >+ return; >+ } >+ >+ var dbname = setDBNameFromPath() + Date(); >+ var request = window.indexedDB.open(dbname); >+ request.onupgradeneeded = function(evt) { >+ sessionStorage.doneFirstLoad = true; >+ if (window.testRunner) { >+ testRunner.waitUntilDone(); >+ testRunner.terminateNetworkProcess(); >+ } else { >+ testFailed('This test requires access to the TestRunner object'); >+ } >+ setTimeout((()=> { >+ location.reload(); >+ }), 0); >+ } >+} >+ >+test(); >+</script>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194709
:
362122
|
362196
|
362300
|
362332
|
362346
|
362353
|
362356
|
362504
|
362509
|
362516
|
362517
|
362773