runtime: init plan9 hashkey by time

Maphash requires non-zero integer for initial hashkey

Fixes #45090

Change-Id: Ie567f648c19e81cddc8e72a1c64809fbf52df188
Reviewed-on: https://go-review.googlesource.com/c/go/+/303969
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Meng Zhuo 2021-03-29 15:10:50 +08:00
parent 06ad41642c
commit a95454b6f3

View file

@ -325,7 +325,23 @@ func crash() {
//go:nosplit
func getRandomData(r []byte) {
extendRandom(r, 0)
// inspired by wyrand see hash32.go for detail
t := nanotime()
v := getg().m.procid ^ uint64(t)
for len(r) > 0 {
v ^= 0xa0761d6478bd642f
v *= 0xe7037ed1a0b428db
size := 8
if len(r) < 8 {
size = len(r)
}
for i := 0; i < size; i++ {
r[i] = byte(v >> (8 * i))
}
r = r[size:]
v = v>>32 | v<<32
}
}
func initsig(preinit bool) {