Closed
Description
golang.org/x/sys/cpu does not allow CPU feature detection to be overridden, unlike internal/cpu. This results in surprising behavior while debugging software that do not use internal/cpu but the external golang.org/x/sys/cpu package.
@martisch already mentioned this difference in #32102 (comment).
The use case was forcing qtls in https://github.com/lucas-clemente/quic-go to use ChaCha20-Poly1305 instead of AES128-GCM in TLS 1.3 for debugging purposes.
What version of Go are you using (go version
)?
$ go version go version go1.12.9 linux/amd64
Does this issue reproduce with the latest release?
Yes, reproduced with golang/sys@5fe476d.
What did you do?
Create detect.go:
package main
import (
"golang.org/x/sys/cpu"
)
func main() {
print("cpu.X86.HasAES: ", cpu.X86.HasAES, "\n")
}
Run with:
./detect
GODEBUG=cpu.all=off ./detect
# demonstrate that GODEBUG is interpreted
GODEBUG=cpu.allx=off ./detect
What did you expect to see?
cpu.X86.HasAES: true
cpu.X86.HasAES: false
GODEBUG: unknown cpu feature "allx"
cpu.X86.HasAES: true
What did you see instead?
cpu.X86.HasAES: true
cpu.X86.HasAES: true
GODEBUG: unknown cpu feature "allx"
cpu.X86.HasAES: true