From: Meng Zhuo Date: Mon, 29 Mar 2021 07:10:50 +0000 (+0800) Subject: runtime: init plan9 hashkey by time X-Git-Tag: go1.17beta1~933 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a95454b6f31a982f064d262987199fba19f085e9;p=gostls13.git 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 Run-TryBot: Meng Zhuo TryBot-Result: Go Bot Reviewed-by: Richard Miller Reviewed-by: Keith Randall --- diff --git a/src/runtime/os_plan9.go b/src/runtime/os_plan9.go index 77665f461a..4d428346f0 100644 --- a/src/runtime/os_plan9.go +++ b/src/runtime/os_plan9.go @@ -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) {