Ignore:
Timestamp:
Jul 24, 2008, 11:40:38 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-24 Geoffrey Garen <[email protected]>

Reviewed by Maciej Stachowiak.


Fixed a strict aliasing violation, which caused hash tables with floating
point keys not to find items that were indeed in the tables
(intermittently, and only in release builds, of course).


SunSpider reports no change.


This bug doesn't seem to affect any existing code, but it causes obvious
crashes in some new code I'm working on.

  • wtf/HashFunctions.h: (WTF::FloatHash::hash): Use a union when punning between a float / double and an unsigned (bucket of bits). With strict aliasing enabled, unions are the only safe way to do this kind of type punning.
  • wtf/HashTable.h: When rehashing, ASSERT that the item we just added to the table is indeed in the table. In the buggy case described above, this ASSERT fires.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/HashTable.h

    r34891 r35334  
    678678            KeyType enteredKey = Extractor::extract(*entry);
    679679            expand();
    680             return std::make_pair(find(enteredKey), true);
     680            pair<iterator, bool> p = std::make_pair(find(enteredKey), true);
     681            ASSERT(p.first != end());
     682            return p;
    681683        }
    682684       
     
    721723            KeyType enteredKey = Extractor::extract(*entry);
    722724            expand();
    723             return std::make_pair(find(enteredKey), true);
     725            pair<iterator, bool> p = std::make_pair(find(enteredKey), true);
     726            ASSERT(p.first != end());
     727            return p;
    724728        }
    725729
Note: See TracChangeset for help on using the changeset viewer.