From c4219439eb9348b954dddb951178b48687dc97b4 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Tue, 11 Aug 2026 11:41:25 -0700 Subject: [PATCH] runtime: make arrays and struct field hashes order dependent --- src/runtime/hashmap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index ba864db30..56405dd10 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -807,13 +807,13 @@ func hashmapInterfaceHash(itf interface{}, seed uintptr) uint32 { case reflectlite.Array: var hash uint32 for i := 0; i < x.Len(); i++ { - hash ^= hashmapInterfaceHash(valueInterfaceUnsafe(x.Index(i)), seed) + hash = (hash * 31) ^ hashmapInterfaceHash(valueInterfaceUnsafe(x.Index(i)), seed) } return hash case reflectlite.Struct: var hash uint32 for i := 0; i < x.NumField(); i++ { - hash ^= hashmapInterfaceHash(valueInterfaceUnsafe(x.Field(i)), seed) + hash = (hash * 31) ^ hashmapInterfaceHash(valueInterfaceUnsafe(x.Field(i)), seed) } return hash default: