runtime: make arrays and struct field hashes order dependent - #5581
Conversation
jakebailey
left a comment
There was a problem hiding this comment.
Was this motivated by something?
(Seems fine of course)
| if x.RawType().Size() <= unsafe.Sizeof(uintptr(0)) { | ||
| // Value fits in pointer, so it's directly stored in the pointer. | ||
| ptr = unsafe.Pointer(&value) |
There was a problem hiding this comment.
Unrelated, but I didn't realize that tinygo still used this method and not staticuint64s etc; this has GC implications since I think this means that number values stored in interfaces are treated as pointers
There was a problem hiding this comment.
Motivated by me reading the hashmap code. I didn't have a particular bug.
Yeah, the interface values sometimes being ints and sometimes being pointers means we can pin stuff. But at long as we don't panic any garbage collector implementations we'll be fine, right?
There was a problem hiding this comment.
It won't panic anything, no, since most everything can do conservative scanning, but I do think it'd be best to avoid that pinning
Tweak the hash to ensure that
[1, 2]has a different hash value from[2, 1]