Changeset 141316 in webkit
- Timestamp:
- Jan 30, 2013 2:39:41 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141311 r141316 1 2013-01-30 Alec Flett <alecflett@chromium.org> 2 3 IndexedDB: Avoid crashing when deleting indexes 4 https://bugs.webkit.org/show_bug.cgi?id=108356 5 6 Reviewed by Tony Chang. 7 8 This test works on an edge case around the asynchronous 9 creation/deletion of indexes that used to crash. It doesn't fail/crash even 10 without this patch but was the test condition that uncovered the overall problem 11 before https://bugs.webkit.org/show_bug.cgi?id=107311 changed the timing of 12 some of the events. 13 14 * storage/indexeddb/createIndex-after-failure.html: Added. 15 * storage/indexeddb/resources/createIndex-after-failure.js: Added. 16 (sleep): 17 (prepareDatabase): 18 (deleteIndexAfterGet): 19 * storage/indexeddb/resources/shared.js: 20 (.requests.forEach): 21 (waitForRequests): 22 23 * storage/indexeddb/createIndex-after-failure.html: Added. 24 * storage/indexeddb/resources/createIndex-after-failure.js: Added. 25 (prepareDatabase): 26 (deleteIndexAfterGet): 27 * storage/indexeddb/resources/shared.js: 28 (.requests.forEach): 29 (waitForRequests): 30 1 31 2013-01-30 Philip Rogers <pdr@google.com> 2 32 -
trunk/LayoutTests/storage/indexeddb/resources/shared.js
r137635 r141316 205 205 }; 206 206 } 207 208 function waitForRequests(requests, callback) { 209 var count = requests.length; 210 211 if (!count) { 212 callback(requests); 213 return; 214 } 215 216 requests.forEach(function(req) { 217 req.onsuccess = function() { 218 --count; 219 if (!count) 220 callback(requests); 221 }; 222 req.onerror = unexpectedErrorCallback; 223 }); 224 } -
trunk/Source/WebCore/ChangeLog
r141315 r141316 1 2013-01-30 Alec Flett <alecflett@chromium.org> 2 3 IndexedDB: Avoid crashing when deleting indexes 4 https://bugs.webkit.org/show_bug.cgi?id=108356 5 6 Reviewed by Tony Chang. 7 8 It is reasonable that the backend aborts a transaction before 9 the frontend is aware, depending on the timing of events. This 10 allows the transactionId to be invalid rather than asserting. 11 12 Test: storage/indexeddb/createIndex-after-failure.html 13 14 * Modules/indexeddb/IDBDatabaseBackendImpl.cpp: 15 (WebCore::IDBDatabaseBackendImpl::createObjectStore): 16 (WebCore::IDBDatabaseBackendImpl::deleteObjectStore): 17 (WebCore::IDBDatabaseBackendImpl::createIndex): 18 (WebCore::IDBDatabaseBackendImpl::deleteIndex): 19 (WebCore::IDBDatabaseBackendImpl::get): 20 (WebCore::IDBDatabaseBackendImpl::put): 21 (WebCore::IDBDatabaseBackendImpl::setIndexKeys): 22 (WebCore::IDBDatabaseBackendImpl::setIndexesReady): 23 (WebCore::IDBDatabaseBackendImpl::openCursor): 24 (WebCore::IDBDatabaseBackendImpl::count): 25 (WebCore::IDBDatabaseBackendImpl::deleteRange): 26 (WebCore::IDBDatabaseBackendImpl::clear): 27 1 28 2013-01-30 Kentaro Hara <haraken@chromium.org> 2 29 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp
r141142 r141316 557 557 { 558 558 IDB_TRACE("IDBDatabaseBackendImpl::createObjectStore"); 559 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 560 if (!transaction) 561 return; 562 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); 563 559 564 ASSERT(!m_metadata.objectStores.contains(objectStoreId)); 560 561 ASSERT(m_transactions.contains(transactionId));562 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);563 564 565 IDBObjectStoreMetadata objectStoreMetadata(name, objectStoreId, keyPath, autoIncrement, IDBDatabaseBackendInterface::MinimumIndexId); 565 566 … … 582 583 { 583 584 IDB_TRACE("IDBDatabaseBackendImpl::deleteObjectStore"); 585 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 586 if (!transaction) 587 return; 588 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); 589 584 590 ASSERT(m_metadata.objectStores.contains(objectStoreId)); 585 591 const IDBObjectStoreMetadata& objectStoreMetadata = m_metadata.objectStores.get(objectStoreId); 586 592 587 ASSERT(m_transactions.contains(transactionId));588 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);589 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);590 591 593 transaction->scheduleTask(DeleteObjectStoreOperation::create(m_backingStore, objectStoreMetadata), DeleteObjectStoreAbortOperation::create(this, objectStoreMetadata)); 592 594 removeObjectStore(objectStoreId); … … 596 598 { 597 599 IDB_TRACE("IDBDatabaseBackendImpl::createIndex"); 600 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 601 if (!transaction) 602 return; 603 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); 604 598 605 ASSERT(m_metadata.objectStores.contains(objectStoreId)); 599 606 const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId); … … 602 609 const IDBIndexMetadata indexMetadata(name, indexId, keyPath, unique, multiEntry); 603 610 604 ASSERT(m_transactions.contains(transactionId));605 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);606 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);607 608 611 transaction->scheduleTask(CreateIndexOperation::create(m_backingStore, objectStoreId, indexMetadata), CreateIndexAbortOperation::create(this, objectStoreId, indexId)); 609 612 610 613 addIndex(objectStoreId, indexMetadata, indexId); 611 614 } 612 613 615 614 616 void CreateIndexOperation::perform(IDBTransactionBackendImpl* transaction) … … 631 633 { 632 634 IDB_TRACE("IDBDatabaseBackendImpl::deleteIndex"); 635 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 636 if (!transaction) 637 return; 638 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); 639 633 640 ASSERT(m_metadata.objectStores.contains(objectStoreId)); 634 641 const IDBObjectStoreMetadata objectStore = m_metadata.objectStores.get(objectStoreId); … … 636 643 ASSERT(objectStore.indexes.contains(indexId)); 637 644 const IDBIndexMetadata& indexMetadata = objectStore.indexes.get(indexId); 638 639 ASSERT(m_transactions.contains(transactionId));640 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId);641 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE);642 645 643 646 transaction->scheduleTask(DeleteIndexOperation::create(m_backingStore, objectStoreId, indexId), DeleteIndexAbortOperation::create(this, objectStoreId, indexMetadata)); … … 683 686 { 684 687 IDB_TRACE("IDBDatabaseBackendImpl::get"); 685 ASSERT(m_transactions.contains(transactionId));686 688 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 689 if (!transaction) 690 return; 687 691 688 692 transaction->scheduleTask(GetOperation::create(m_backingStore, m_metadata, objectStoreId, indexId, keyRange, keyOnly ? IDBCursorBackendInterface::KeyOnly : IDBCursorBackendInterface::KeyAndValue, callbacks)); … … 780 784 { 781 785 IDB_TRACE("IDBDatabaseBackendImpl::put"); 782 783 ASSERT(m_transactions.contains(transactionId));784 786 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 787 if (!transaction) 788 return; 785 789 ASSERT(transaction->mode() != IDBTransaction::READ_ONLY); 786 790 … … 863 867 } 864 868 865 866 869 void IDBDatabaseBackendImpl::setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys) 867 870 { 868 871 IDB_TRACE("IDBDatabaseBackendImpl::setIndexKeys"); 869 if (!m_transactions.contains(transactionId))870 return;871 872 872 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 873 if (transaction->isFinished()) 874 return; 873 if (!transaction || transaction->isFinished()) 874 return; 875 ASSERT(transaction->mode() == IDBTransaction::VERSION_CHANGE); 875 876 876 877 RefPtr<IDBKey> primaryKey = prpPrimaryKey; … … 915 916 IDB_TRACE("IDBObjectStoreBackendImpl::setIndexesReady"); 916 917 917 if (!m_transactions.contains(transactionId))918 return;919 920 918 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 921 if ( transaction->isFinished())919 if (!transaction || transaction->isFinished()) 922 920 return; 923 921 … … 936 934 { 937 935 IDB_TRACE("IDBDatabaseBackendImpl::openCursor"); 938 ASSERT(m_transactions.contains(transactionId));939 936 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 937 if (!transaction) 938 return; 940 939 941 940 transaction->scheduleTask(OpenCursorOperation::create(m_backingStore, id(), objectStoreId, indexId, keyRange, direction, keyOnly ? IDBCursorBackendInterface::KeyOnly : IDBCursorBackendInterface::KeyAndValue, taskType, callbacks)); … … 979 978 { 980 979 IDB_TRACE("IDBDatabaseBackendImpl::count"); 981 ASSERT(m_transactions.contains(transactionId));982 980 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 981 if (!transaction) 982 return; 983 983 984 ASSERT(m_metadata.objectStores.contains(objectStoreId)); 984 985 transaction->scheduleTask(CountOperation::create(m_backingStore, id(), objectStoreId, indexId, keyRange, callbacks)); … … 1010 1011 { 1011 1012 IDB_TRACE("IDBDatabaseBackendImpl::deleteRange"); 1012 1013 ASSERT(m_transactions.contains(transactionId));1014 1013 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 1014 if (!transaction) 1015 return; 1015 1016 ASSERT(transaction->mode() != IDBTransaction::READ_ONLY); 1016 1017 … … 1034 1035 { 1035 1036 IDB_TRACE("IDBDatabaseBackendImpl::clear"); 1036 1037 ASSERT(m_transactions.contains(transactionId));1038 1037 IDBTransactionBackendImpl* transaction = m_transactions.get(transactionId); 1038 if (!transaction) 1039 return; 1039 1040 ASSERT(transaction->mode() != IDBTransaction::READ_ONLY); 1040 1041
Note: See TracChangeset
for help on using the changeset viewer.