Clojurians
#cljs-dev
<
2017-03-13
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

favila19:03:57

The attempt to put two particular keys into the same hash-map will stackoverflow: http://dev.clojure.org/jira/browse/CLJS-1976

anmonteiro20:03:24

the async fix will be in the next version of Google Closure Compiler

spinningtopsofdoom20:03:03

@favila The two keys hash to the same value.

spinningtopsofdoom20:03:00

I'd guess that the Hash collision node has faulty logic for a transient assoc

favila20:03:58

I don't have the same hash?

spinningtopsofdoom20:03:03

If I try (hash-map (hash bad-key)-1 nil (hash bad-key-2) nil) it works correctly

favila20:03:13

cljs.user=> (hash bad-key-1)
1454955434
cljs.user=> (hash bad-key-2)
-2840011862

favila20:03:01

@spinningtopsofdoom normal assoc fails too

spinningtopsofdoom20:03:03

-2840011862 === 1454955434 when you're using 32 bit ints

favila20:03:06

it is common to both transient and non-transient

favila20:03:13

ah, it is not truncating

favila20:03:25

hashes should really be normalzied to 32bit

favila20:03:53

so maybe it doesn't detect a collision because it's comparing by value

spinningtopsofdoom21:03:37

@favila You are correct It doesn't detect a hash collision because it's comparing by value

spinningtopsofdoom21:03:51

create node compares hashes by ==

favila21:03:55

@spinningtopsofdoom I am preparing a proper patch

favila21:03:15

Replaced that with (zero? (bit-xor hash-a hash-b))

favila21:03:33

but really, it's not good that the record impl of hash is producing > 32 bit vals

favila21:03:18

but who knows who else is doing that

spinningtopsofdoom21:03:55

It's not greater than 32 bit. It's a negative value that falls within a the range of a singed 32 bit int

favila21:03:04

I mean it's using more than 32 bits

favila21:03:09

in particular, hash-imap does not bit-or 0 it's return value

favila21:03:18

nor hash iset

favila21:03:38

hm, nor any of the hash-* fns

favila21:03:01

nm only those two matter. hash-combine truncates

favila21:03:24

which takes care of hash-coll

favila21:03:44

ah, defrecords don't use murmur hashing

favila21:03:55

hash-imap and hash-iset are pre-murmur

favila21:03:04

so that's a possible future enhancement

favila22:03:40

Now that I know the cause, here is a much simpler reproducer: (hash-map #inst "2017-03-13T22:21:08.666-00:00" nil #inst "2015-11-02T19:53:15.706-00:00" nil)

favila22:03:02

That blows the stack

favila23:03:30

Added a patch which forces hash to return 32-bit values