Title: [205836] trunk/Source/WTF
Revision
205836
Author
[email protected]
Date
2016-09-12 16:08:49 -0700 (Mon, 12 Sep 2016)

Log Message

[WTF] HashTable's rehash is not compatible to Ref<T> and ASan
https://bugs.webkit.org/show_bug.cgi?id=161763

Reviewed by Darin Adler.

Destructors of HashTable's empty values need to be called while ones of deleted values don't.

* wtf/HashTable.h:
(WTF::KeyTraits>::deallocateTable):
* wtf/Ref.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (205835 => 205836)


--- trunk/Source/WTF/ChangeLog	2016-09-12 23:03:09 UTC (rev 205835)
+++ trunk/Source/WTF/ChangeLog	2016-09-12 23:08:49 UTC (rev 205836)
@@ -1,3 +1,16 @@
+2016-09-12  Yusuke Suzuki  <[email protected]>
+
+        [WTF] HashTable's rehash is not compatible to Ref<T> and ASan
+        https://bugs.webkit.org/show_bug.cgi?id=161763
+
+        Reviewed by Darin Adler.
+
+        Destructors of HashTable's empty values need to be called while ones of deleted values don't.
+
+        * wtf/HashTable.h:
+        (WTF::KeyTraits>::deallocateTable):
+        * wtf/Ref.h:
+
 2016-09-12  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Reduce uses of CGFonts in favor of CTFonts

Modified: trunk/Source/WTF/wtf/HashTable.h (205835 => 205836)


--- trunk/Source/WTF/wtf/HashTable.h	2016-09-12 23:03:09 UTC (rev 205835)
+++ trunk/Source/WTF/wtf/HashTable.h	2016-09-12 23:08:49 UTC (rev 205836)
@@ -1153,7 +1153,7 @@
     void HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::deallocateTable(ValueType* table, unsigned size)
     {
         for (unsigned i = 0; i < size; ++i) {
-            if (!isEmptyOrDeletedBucket(table[i]))
+            if (!isDeletedBucket(table[i]))
                 table[i].~ValueType();
         }
         fastFree(table);
@@ -1197,11 +1197,17 @@
 
         Value* newEntry = nullptr;
         for (unsigned i = 0; i != oldTableSize; ++i) {
-            if (isEmptyOrDeletedBucket(oldTable[i])) {
+            if (isDeletedBucket(oldTable[i])) {
                 ASSERT(std::addressof(oldTable[i]) != entry);
                 continue;
             }
 
+            if (isEmptyBucket(oldTable[i])) {
+                ASSERT(std::addressof(oldTable[i]) != entry);
+                oldTable[i].~ValueType();
+                continue;
+            }
+
             Value* reinsertedEntry = reinsert(WTFMove(oldTable[i]));
             oldTable[i].~ValueType();
             if (std::addressof(oldTable[i]) == entry) {

Modified: trunk/Source/WTF/wtf/Ref.h (205835 => 205836)


--- trunk/Source/WTF/wtf/Ref.h	2016-09-12 23:03:09 UTC (rev 205835)
+++ trunk/Source/WTF/wtf/Ref.h	2016-09-12 23:08:49 UTC (rev 205836)
@@ -114,7 +114,7 @@
         return *this;
     }
 
-    // Hash table deleted/empty values, which are only constructed and never copied or destroyed.
+    // Hash table deleted values, which are only constructed and never copied or destroyed.
     Ref(HashTableDeletedValueType) : m_ptr(hashTableDeletedValue()) { }
     bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
     static T* hashTableDeletedValue() { return reinterpret_cast<T*>(-1); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to