Skip to content

x/sys/cpu: respect CPU feature overrides specified in GODEBUG #33963

Closed
@Lekensteyn

Description

@Lekensteyn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions