[issue14621] Hash function is not randomized properly

2012-04-20 Thread Vlado Boza
Vlado Boza added the comment: One possible fix: Look for StringHasher in google v8 code (http://code.google.com/p/v8/source/search?q=stringhasher&origq=stringhasher&btnG=Search+Trunk). Main loop looks like this: raw_running_ha

[issue14621] Hash function is not randomized properly

2012-04-19 Thread Vlado Boza
Vlado Boza added the comment: >I tried this script on Linux 32 bits and Linux 64 bits: I didn't see any >>collision. What is your operating system and the version of your >operating >system please? uname -a Linux 3.0.0-17-generic #30-Ubuntu SMP Thu Mar 8 20:45:39 UT

[issue14621] Hash function is not randomized properly

2012-04-19 Thread Vlado Boza
Vlado Boza added the comment: For example take this script (on 32bit): ha = hash("\x00\xcf\x0b\x96\x19") hb = hash("\x00\x6d\x29\x45\x18") if ha == hb: print "collision" And run following: for i in `seq 0 25`; do echo $i; for j in `seq 0 100`; do ./python -

[issue14621] Hash function is not randomized properly

2012-04-19 Thread Vlado Boza
Vlado Boza added the comment: My bad (I checked only function in C++, not result in python). This should work on 32bit: Prefix: anything ending on 0x00 Suffix: anything Strings: "\x00\xcf\x0b\x96\x19", "\x00\x6d\x29\x45\x18" -- __

[issue14621] Hash function is not randomized properly

2012-04-19 Thread Vlado Boza
Vlado Boza added the comment: E.g this strings collide for every prefix ending on 0xcd: 0x27fd5a18, 0x26fe78fa -- ___ Python tracker <http://bugs.python.org/issue14

[issue14621] Hash function is not randomized properly

2012-04-19 Thread Vlado Boza
New submission from Vlado Boza : Fix of this http://bugs.python.org/issue13703 is broken. tl;dr: There only 256 different hash functions (compare it to size of _Py_HashSecret prefix and suffix). And whether keys collide or not depends only on the last 8 bits of prefix. Problem with current