Title: [238112] trunk
Revision
238112
Author
sihui_...@apple.com
Date
2018-11-12 15:34:29 -0800 (Mon, 12 Nov 2018)

Log Message

imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit.html crashing on iOS device
https://bugs.webkit.org/show_bug.cgi?id=191500

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

* web-platform-tests/IndexedDB/keygenerator-explicit-expected.txt:

Source/WebCore:

When double value is bigger than maximum unsigned int, converting double to unsigned int has
different behaviors on macOS and iOS. On macOS, the result would be 0 while on iOS it would be
maximum unsigned int.

Covered by existing test.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
(WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):

LayoutTests:

The test should not crash now.

* platform/ios-device/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (238111 => 238112)


--- trunk/LayoutTests/ChangeLog	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/LayoutTests/ChangeLog	2018-11-12 23:34:29 UTC (rev 238112)
@@ -1,3 +1,14 @@
+2018-11-12  Sihui Liu  <sihui_...@apple.com>
+
+        imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit.html crashing on iOS device
+        https://bugs.webkit.org/show_bug.cgi?id=191500
+
+        Reviewed by Dean Jackson.
+
+        The test should not crash now.
+
+        * platform/ios-device/TestExpectations:
+
 2018-11-12  Tim Horton  <timothy_hor...@apple.com>
 
         Make it possible to edit images inline

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (238111 => 238112)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-11-12 23:34:29 UTC (rev 238112)
@@ -1,3 +1,12 @@
+2018-11-12  Sihui Liu  <sihui_...@apple.com>
+
+        imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit.html crashing on iOS device
+        https://bugs.webkit.org/show_bug.cgi?id=191500
+
+        Reviewed by Dean Jackson.
+
+        * web-platform-tests/IndexedDB/keygenerator-explicit-expected.txt:
+
 2018-11-12  Youenn Fablet  <you...@apple.com>
 
         Support setting stream ids when adding a transceiver

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit-expected.txt (238111 => 238112)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit-expected.txt	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit-expected.txt	2018-11-12 23:34:29 UTC (rev 238112)
@@ -2,12 +2,12 @@
 PASS Key generator vs. explicit key 53 bits 
 PASS Key generator vs. explicit key greater than 53 bits, less than 64 bits 
 PASS Key generator vs. explicit key greater than 53 bits, less than 64 bits (negative) 
-FAIL Key generator vs. explicit key 63 bits assert_unreached: put should succeed Reached unreachable code
+PASS Key generator vs. explicit key 63 bits 
 PASS Key generator vs. explicit key 63 bits (negative) 
-FAIL Key generator vs. explicit key 64 bits assert_unreached: put should fail Reached unreachable code
+PASS Key generator vs. explicit key 64 bits 
 PASS Key generator vs. explicit key 64 bits (negative) 
-FAIL Key generator vs. explicit key greater than 64 bits, but still finite assert_unreached: put should fail Reached unreachable code
+PASS Key generator vs. explicit key greater than 64 bits, but still finite 
 PASS Key generator vs. explicit key greater than 64 bits, but still finite (negative) 
-FAIL Key generator vs. explicit key equal to Infinity assert_unreached: put should fail Reached unreachable code
+PASS Key generator vs. explicit key equal to Infinity 
 PASS Key generator vs. explicit key equal to -Infinity 
 

Modified: trunk/LayoutTests/platform/ios-device/TestExpectations (238111 => 238112)


--- trunk/LayoutTests/platform/ios-device/TestExpectations	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/LayoutTests/platform/ios-device/TestExpectations	2018-11-12 23:34:29 UTC (rev 238112)
@@ -63,7 +63,6 @@
 imported/blink/storage/indexeddb/blob-delete-objectstore-db.html [ Failure ]
 imported/blink/storage/indexeddb/blob-valid-after-deletion.html [ Failure ]
 imported/blink/storage/indexeddb/blob-valid-before-commit.html [ Failure ]
-imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit.html [ Failure ]
 imported/w3c/web-platform-tests/IndexedDB/keypath-special-identifiers.htm [ Failure ]
 imported/w3c/web-platform-tests/cssom-view/Screen-pixelDepth-Screen-colorDepth001.html [ Failure ]
 imported/w3c/web-platform-tests/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (238111 => 238112)


--- trunk/Source/WebCore/ChangeLog	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/Source/WebCore/ChangeLog	2018-11-12 23:34:29 UTC (rev 238112)
@@ -1,3 +1,20 @@
+2018-11-12  Sihui Liu  <sihui_...@apple.com>
+
+        imported/w3c/web-platform-tests/IndexedDB/keygenerator-explicit.html crashing on iOS device
+        https://bugs.webkit.org/show_bug.cgi?id=191500
+
+        Reviewed by Dean Jackson.
+
+        When double value is bigger than maximum unsigned int, converting double to unsigned int has
+        different behaviors on macOS and iOS. On macOS, the result would be 0 while on iOS it would be
+        maximum unsigned int.
+
+        Covered by existing test.
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::generateKeyNumber):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::maybeUpdateKeyGeneratorNumber):
+
 2018-11-12  Basuke Suzuki  <basuke.suz...@sony.com>
 
         [Curl] Add API Test for Curl cookie backend.

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (238111 => 238112)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2018-11-12 23:18:44 UTC (rev 238111)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2018-11-12 23:34:29 UTC (rev 238112)
@@ -63,6 +63,9 @@
 // Current version of the metadata schema being used in the metadata database.
 static const int currentMetadataVersion = 1;
 
+// The IndexedDatabase spec defines the max key generator value as 2^53.
+static const uint64_t maxGeneratorValue = 0x20000000000000;
+
 static int idbKeyCollate(int aLength, const void* aBuffer, int bLength, const void* bBuffer)
 {
     IDBKeyData a, b;
@@ -2399,9 +2402,6 @@
     ASSERT(m_sqliteDB);
     ASSERT(m_sqliteDB->isOpen());
 
-    // The IndexedDatabase spec defines the max key generator value as 2^53;
-    static uint64_t maxGeneratorValue = 0x20000000000000;
-
     auto* transaction = m_transactions.get(transactionIdentifier);
     if (!transaction || !transaction->inProgress()) {
         LOG_ERROR("Attempt to generate key in database without an in-progress transaction");
@@ -2470,13 +2470,7 @@
     if (newKeyNumber <= currentValue)
         return IDBError { };
 
-    uint64_t newKeyInteger(newKeyNumber);
-    if (newKeyInteger <= uint64_t(newKeyNumber))
-        ++newKeyInteger;
-
-    ASSERT(newKeyInteger > uint64_t(newKeyNumber));
-
-    return uncheckedSetKeyGeneratorValue(objectStoreID, newKeyInteger - 1);
+    return uncheckedSetKeyGeneratorValue(objectStoreID, std::min(newKeyNumber, (double)maxGeneratorValue));
 }
 
 IDBError SQLiteIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& result)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to