Changeset 128220 in webkit
- Timestamp:
- Sep 11, 2012, 1:14:51 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r128217 r128220 1 2012-09-11 James Robinson <jamesr@chromium.org> 2 3 Unreviewed, rolling out r128212. 4 http://trac.webkit.org/changeset/128212 5 https://bugs.webkit.org/show_bug.cgi?id=96037 6 7 Assertion fails on linux 64 8 9 * Modules/indexeddb/IDBLevelDBCoding.cpp: 10 (WebCore::IDBLevelDBCoding::extractEncodedIDBKey): 11 (WebCore::IDBLevelDBCoding::compareEncodedIDBKeys): 12 (IDBLevelDBCoding): 13 (WebCore::IDBLevelDBCoding::compare): 14 1 15 2012-09-11 Joshua Bell <jsbell@chromium.org> 2 16 -
trunk/Source/WebCore/Modules/indexeddb/IDBLevelDBCoding.cpp
r128212 r128220 506 506 } 507 507 508 const char* extractEncodedIDBKey(const char* start, const char* limit, Vector<char>* result = 0) 509 { 508 const char* extractEncodedIDBKey(const char* start, const char* limit, Vector<char>* result) 509 { 510 ASSERT(result); 510 511 const char* p = start; 511 512 if (p >= limit) … … 517 518 case IDBKeyNullTypeByte: 518 519 case IDBKeyMinKeyTypeByte: 519 break; 520 *result = encodeByte(type); 521 return p; 520 522 case IDBKeyArrayTypeByte: { 521 523 int64_t length; … … 525 527 if (length < 0) 526 528 return 0; 529 result->clear(); 530 result->append(start, p - start); 527 531 while (length--) { 528 p = extractEncodedIDBKey(p, limit); 532 Vector<char> subkey; 533 p = extractEncodedIDBKey(p, limit, &subkey); 529 534 if (!p) 530 535 return 0; 536 result->append(subkey); 531 537 } 532 break;538 return p; 533 539 } 534 540 case IDBKeyStringTypeByte: { … … 539 545 if (p + length * 2 > limit) 540 546 return 0; 541 p += length * 2; 542 break; 547 result->clear(); 548 result->append(start, p - start + length * 2); 549 return p + length * 2; 543 550 } 544 551 case IDBKeyDateTypeByte: … … 546 553 if (p + sizeof(double) > limit) 547 554 return 0; 548 p += sizeof(double);549 break;550 }551 552 if (result) {553 ASSERT(p);554 ASSERT(p <= limit);555 555 result->clear(); 556 result->append(start, p - start); 557 } 558 559 return p; 556 result->append(start, 1 + sizeof(double)); 557 return p + sizeof(double); 558 } 559 ASSERT_NOT_REACHED(); 560 return 0; 560 561 } 561 562 … … 581 582 } 582 583 583 int compareEncodedIDBKeys(const char*& p trA, const char* limitA, const char*& ptrB, const char* limitB)584 { 585 ASSERT(&p trA != &ptrB);586 ASSERT(p trA< limitA);587 ASSERT( ptrB< limitB);588 unsigned char typeA = *p trA++;589 unsigned char typeB = * ptrB++;584 int compareEncodedIDBKeys(const char*& p, const char* limitA, const char*& q, const char* limitB) 585 { 586 ASSERT(&p != &q); 587 ASSERT(p < limitA); 588 ASSERT(q < limitB); 589 unsigned char typeA = *p++; 590 unsigned char typeB = *q++; 590 591 591 592 if (int x = IDBKey::compareTypes(keyTypeByteToKeyType(typeA), keyTypeByteToKeyType(typeB))) … … 599 600 case IDBKeyArrayTypeByte: { 600 601 int64_t lengthA, lengthB; 601 p trA = decodeVarInt(ptrA, limitA, lengthA);602 if (!p trA)603 return 0; 604 ptrB = decodeVarInt(ptrB, limitB, lengthB);605 if (! ptrB)602 p = decodeVarInt(p, limitA, lengthA); 603 if (!p) 604 return 0; 605 q = decodeVarInt(q, limitB, lengthB); 606 if (!q) 606 607 return 0; 607 608 if (lengthA < 0 || lengthB < 0) 608 609 return 0; 609 610 for (int64_t i = 0; i < lengthA && i < lengthB; ++i) { 610 if (int cmp = compareEncodedIDBKeys(p trA, limitA, ptrB, limitB))611 if (int cmp = compareEncodedIDBKeys(p, limitA, q, limitB)) 611 612 return cmp; 612 613 } … … 618 619 } 619 620 case IDBKeyStringTypeByte: 620 return compareEncodedStringsWithLength(p trA, limitA, ptrB, limitB);621 return compareEncodedStringsWithLength(p, limitA, q, limitB); 621 622 case IDBKeyDateTypeByte: 622 623 case IDBKeyNumberTypeByte: { 623 624 double d, e; 624 p trA = decodeDouble(ptrA, limitA, &d);625 ASSERT(p trA);626 ptrB = decodeDouble(ptrB, limitB, &e);627 ASSERT( ptrB);625 p = decodeDouble(p, limitA, &d); 626 ASSERT(p); 627 q = decodeDouble(q, limitB, &e); 628 ASSERT(q); 628 629 if (d < e) 629 630 return -1; … … 643 644 ASSERT(keyB.size() >= 1); 644 645 645 const char* p trA= keyA.data();646 const char* limitA = p trA+ keyA.size();647 const char* ptrB= keyB.data();648 const char* limitB = ptrB+ keyB.size();649 650 return compareEncodedIDBKeys(p trA, limitA, ptrB, limitB);646 const char* p = keyA.data(); 647 const char* limitA = p + keyA.size(); 648 const char* q = keyB.data(); 649 const char* limitB = q + keyB.size(); 650 651 return compareEncodedIDBKeys(p, limitA, q, limitB); 651 652 } 652 653 … … 720 721 721 722 namespace { 722 723 723 template<typename KeyType> 724 int compare(const LevelDBSlice& a, const LevelDBSlice& b, bool ignoreDuplicates = false)724 int decodeAndCompare(const LevelDBSlice& a, const LevelDBSlice& b) 725 725 { 726 726 KeyType keyA; … … 734 734 return keyA.compare(keyB); 735 735 } 736 737 template<>738 int compare<ExistsEntryKey>(const LevelDBSlice& a, const LevelDBSlice& b, bool ignoreDuplicates)739 {740 KeyPrefix prefixA;741 KeyPrefix prefixB;742 const char* ptrA = KeyPrefix::decode(a.begin(), a.end(), &prefixA);743 const char* ptrB = KeyPrefix::decode(b.begin(), b.end(), &prefixB);744 ASSERT(ptrA);745 ASSERT(ptrB);746 ASSERT(prefixA.m_databaseId);747 ASSERT(prefixA.m_objectStoreId);748 ASSERT(prefixA.m_indexId == ExistsEntryKey::SpecialIndexNumber);749 ASSERT(prefixB.m_databaseId);750 ASSERT(prefixB.m_objectStoreId);751 ASSERT(prefixB.m_indexId == ExistsEntryKey::SpecialIndexNumber);752 ASSERT(ptrA != a.end());753 ASSERT(ptrB != b.end());754 // Prefixes are not compared - it is assumed this was already done.755 ASSERT(!prefixA.compare(prefixB));756 757 return compareEncodedIDBKeys(ptrA, a.end(), ptrB, b.end());758 }759 760 template<>761 int compare<ObjectStoreDataKey>(const LevelDBSlice& a, const LevelDBSlice& b, bool ignoreDuplicates)762 {763 KeyPrefix prefixA;764 KeyPrefix prefixB;765 const char* ptrA = KeyPrefix::decode(a.begin(), a.end(), &prefixA);766 const char* ptrB = KeyPrefix::decode(b.begin(), b.end(), &prefixB);767 ASSERT(ptrA);768 ASSERT(ptrB);769 ASSERT(prefixA.m_databaseId);770 ASSERT(prefixA.m_objectStoreId);771 ASSERT(prefixA.m_indexId == ObjectStoreDataKey::SpecialIndexNumber);772 ASSERT(prefixB.m_databaseId);773 ASSERT(prefixB.m_objectStoreId);774 ASSERT(prefixB.m_indexId == ObjectStoreDataKey::SpecialIndexNumber);775 ASSERT(ptrA != a.end());776 ASSERT(ptrB != b.end());777 // Prefixes are not compared - it is assumed this was already done.778 ASSERT(!prefixA.compare(prefixB));779 780 return compareEncodedIDBKeys(ptrA, a.end(), ptrB, b.end());781 }782 783 template<>784 int compare<IndexDataKey>(const LevelDBSlice& a, const LevelDBSlice& b, bool ignoreDuplicates)785 {786 KeyPrefix prefixA;787 KeyPrefix prefixB;788 const char* ptrA = KeyPrefix::decode(a.begin(), a.end(), &prefixA);789 const char* ptrB = KeyPrefix::decode(b.begin(), b.end(), &prefixB);790 ASSERT(ptrA);791 ASSERT(ptrB);792 ASSERT(prefixA.m_databaseId);793 ASSERT(prefixA.m_objectStoreId);794 ASSERT(prefixA.m_indexId >= MinimumIndexId);795 ASSERT(prefixB.m_databaseId);796 ASSERT(prefixB.m_objectStoreId);797 ASSERT(prefixB.m_indexId >= MinimumIndexId);798 ASSERT(ptrA != a.end());799 ASSERT(ptrB != b.end());800 // Prefixes are not compared - it is assumed this was already done.801 ASSERT(!prefixA.compare(prefixB));802 803 // index key804 if (int x = compareEncodedIDBKeys(ptrA, a.end(), ptrB, b.end()))805 return x;806 if (ignoreDuplicates)807 return 0;808 809 // sequence number [optional]810 int64_t sequenceNumberA = -1;811 int64_t sequenceNumberB = -1;812 if (ptrA != a.end())813 ptrA = decodeVarInt(ptrA, a.end(), sequenceNumberA);814 if (ptrB != b.end())815 ptrB = decodeVarInt(ptrB, b.end(), sequenceNumberB);816 817 // primar key [optional]818 if (!ptrA || !ptrB)819 return 0;820 if (ptrA == a.end() && ptrB == b.end())821 return 0;822 if (ptrA == a.end())823 return -1;824 if (ptrB == b.end())825 return 1;826 827 if (int x = compareEncodedIDBKeys(ptrA, a.end(), ptrB, b.end()))828 return x;829 830 return compareInts(sequenceNumberA, sequenceNumberB);831 }832 833 736 } 834 737 … … 864 767 return 0; 865 768 if (typeByteA == DatabaseFreeListTypeByte) 866 return compare<DatabaseFreeListKey>(a, b);769 return decodeAndCompare<DatabaseFreeListKey>(a, b); 867 770 if (typeByteA == DatabaseNameTypeByte) 868 return compare<DatabaseNameKey>(a, b);771 return decodeAndCompare<DatabaseNameKey>(a, b); 869 772 } 870 773 … … 883 786 884 787 if (typeByteA == ObjectStoreMetaDataTypeByte) 885 return compare<ObjectStoreMetaDataKey>(a, b);788 return decodeAndCompare<ObjectStoreMetaDataKey>(a, b); 886 789 if (typeByteA == IndexMetaDataTypeByte) 887 return compare<IndexMetaDataKey>(a, b);790 return decodeAndCompare<IndexMetaDataKey>(a, b); 888 791 if (typeByteA == ObjectStoreFreeListTypeByte) 889 return compare<ObjectStoreFreeListKey>(a, b);792 return decodeAndCompare<ObjectStoreFreeListKey>(a, b); 890 793 if (typeByteA == IndexFreeListTypeByte) 891 return compare<IndexFreeListKey>(a, b);794 return decodeAndCompare<IndexFreeListKey>(a, b); 892 795 if (typeByteA == ObjectStoreNamesTypeByte) 893 return compare<ObjectStoreNamesKey>(a, b);796 return decodeAndCompare<ObjectStoreNamesKey>(a, b); 894 797 if (typeByteA == IndexNamesKeyTypeByte) 895 return compare<IndexNamesKey>(a, b); 896 798 return decodeAndCompare<IndexNamesKey>(a, b); 799 800 return 0; 897 801 ASSERT_NOT_REACHED(); 898 return 0;899 802 } 900 803 … … 907 810 return 1; // FIXME: This case of non-existing user keys should not have to be handled this way. 908 811 909 return compare<ObjectStoreDataKey>(a, b);812 return decodeAndCompare<ObjectStoreDataKey>(a, b); 910 813 } 911 814 if (prefixA.type() == KeyPrefix::ExistsEntry) { … … 917 820 return 1; // FIXME: This case of non-existing user keys should not have to be handled this way. 918 821 919 return compare<ExistsEntryKey>(a, b);822 return decodeAndCompare<ExistsEntryKey>(a, b); 920 823 } 921 824 if (prefixA.type() == KeyPrefix::IndexData) { … … 927 830 return 1; // FIXME: This case of non-existing user keys should not have to be handled this way. 928 831 832 IndexDataKey indexDataKeyA; 833 IndexDataKey indexDataKeyB; 834 835 ptrA = IndexDataKey::decode(a.begin(), endA, &indexDataKeyA); 836 ptrB = IndexDataKey::decode(b.begin(), endB, &indexDataKeyB); 837 ASSERT(ptrA); 838 ASSERT(ptrB); 839 929 840 bool ignoreDuplicates = indexKeys; 930 return compare<IndexDataKey>(a, b, ignoreDuplicates);841 return indexDataKeyA.compare(indexDataKeyB, ignoreDuplicates); 931 842 } 932 843
Note:
See TracChangeset
for help on using the changeset viewer.