tobgu / peds

Type safe persistent/immutable data structures for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

interfaceHash reads too far into data

anacrolix opened this issue · comments

interfaceHash calls fmt.Sprintf("%v", x) which can cause it to read into mutable data triggering the race detector. The hashing used by Go's built-in map key types would be more appropriate (for instance pointer types would just use a hash of the pointer value). I tried to implement this using Go's internal interhash, but it just triggers nil deference errors that I couldn't figure out.

Here's how I tried to use interhash: anacrolix@70355c2

The race detector seems happy, and all my tests are passing. I'm not sure why it needed to handle the nil case.

Fantastic, thanks!