Skip to content

Commit

Permalink
Merge branch 'release-branch.go1.22' of https://go.googlesource.com/go
Browse files Browse the repository at this point in the history
…into bradfitz/1.22.3

Go 1.22.3
  • Loading branch information
bradfitz committed May 7, 2024
2 parents 48d7185 + adbfb67 commit 467a489
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 23 deletions.
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
go1.22.2
time 2024-03-29T15:27:02Z
go1.22.3
time 2024-05-01T19:49:47Z
4 changes: 4 additions & 0 deletions src/cmd/asm/internal/asm/testdata/ppc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// Hex constant 0xFFFFFFFE00000001
MOVD $-8589934591, R5 // 38a0ffff or 0602000038a00001

// For #66955. Verify this opcode turns into a load and assembles.
MOVD $-6795364578871345152, R5 // 3ca00000e8a50000 or 04100000e4a00000

MOVD 8(R3), R4 // e8830008
MOVD (R3)(R4), R5 // 7ca4182a
MOVD (R3)(R0), R5 // 7ca0182a
Expand Down Expand Up @@ -90,6 +93,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVHBR (R3)(R4), R5 // 7ca41e2c
MOVHBR (R3)(R0), R5 // 7ca01e2c
MOVHBR (R3), R5 // 7ca01e2c
OR $0, R0, R0
MOVD $foo+4009806848(FP), R5 // 3ca1ef0138a5cc40 or 0600ef0038a1cc40
MOVD $foo(SB), R5 // 3ca0000038a50000 or 0610000038a00000

Expand Down
3 changes: 3 additions & 0 deletions src/cmd/compile/internal/noder/unified.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ func lookupMethod(pkg *types.Pkg, symName string) (*ir.Func, error) {
if name.Alias() {
return nil, fmt.Errorf("type sym %v refers to alias", typ)
}
if name.Type().IsInterface() {
return nil, fmt.Errorf("type sym %v refers to interface type", typ)
}

for _, m := range name.Type().Methods() {
if m.Sym == meth {
Expand Down
19 changes: 15 additions & 4 deletions src/cmd/go/internal/work/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ var validCompilerFlagsWithNextArg = []string{
"-x",
}

var invalidLinkerFlags = []*lazyregexp.Regexp{
// On macOS this means the linker loads and executes the next argument.
// Have to exclude separately because -lfoo is allowed in general.
re(`-lto_library`),
}

var validLinkerFlags = []*lazyregexp.Regexp{
re(`-F([^@\-].*)`),
re(`-l([^@\-].*)`),
Expand Down Expand Up @@ -235,12 +241,12 @@ var validLinkerFlagsWithNextArg = []string{

func checkCompilerFlags(name, source string, list []string) error {
checkOverrides := true
return checkFlags(name, source, list, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides)
return checkFlags(name, source, list, nil, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides)
}

func checkLinkerFlags(name, source string, list []string) error {
checkOverrides := true
return checkFlags(name, source, list, validLinkerFlags, validLinkerFlagsWithNextArg, checkOverrides)
return checkFlags(name, source, list, invalidLinkerFlags, validLinkerFlags, validLinkerFlagsWithNextArg, checkOverrides)
}

// checkCompilerFlagsForInternalLink returns an error if 'list'
Expand All @@ -249,7 +255,7 @@ func checkLinkerFlags(name, source string, list []string) error {
// external linker).
func checkCompilerFlagsForInternalLink(name, source string, list []string) error {
checkOverrides := false
if err := checkFlags(name, source, list, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides); err != nil {
if err := checkFlags(name, source, list, nil, validCompilerFlags, validCompilerFlagsWithNextArg, checkOverrides); err != nil {
return err
}
// Currently the only flag on the allow list that causes problems
Expand All @@ -262,7 +268,7 @@ func checkCompilerFlagsForInternalLink(name, source string, list []string) error
return nil
}

func checkFlags(name, source string, list []string, valid []*lazyregexp.Regexp, validNext []string, checkOverrides bool) error {
func checkFlags(name, source string, list []string, invalid, valid []*lazyregexp.Regexp, validNext []string, checkOverrides bool) error {
// Let users override rules with $CGO_CFLAGS_ALLOW, $CGO_CFLAGS_DISALLOW, etc.
var (
allow *regexp.Regexp
Expand Down Expand Up @@ -294,6 +300,11 @@ Args:
if allow != nil && allow.FindString(arg) == arg {
continue Args
}
for _, re := range invalid {
if re.FindString(arg) == arg { // must be complete match
goto Bad
}
}
for _, re := range valid {
if re.FindString(arg) == arg { // must be complete match
continue Args
Expand Down
17 changes: 17 additions & 0 deletions src/cmd/go/testdata/script/darwin_lto_library_ldflag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[!GOOS:darwin] skip
[!cgo] skip

! go build
stderr 'invalid flag in #cgo LDFLAGS: -lto_library'

-- go.mod --
module ldflag

-- main.go --
package main

// #cgo CFLAGS: -flto
// #cgo LDFLAGS: -lto_library bad.dylib
import "C"

func main() {}
2 changes: 0 additions & 2 deletions src/cmd/internal/moddeps/moddeps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
// See issues 36852, 41409, and 43687.
// (Also see golang.org/issue/27348.)
func TestAllDependencies(t *testing.T) {
t.Skip("TODO(#65051): 1.22.2 contains unreleased changes from vendored modules")

goBin := testenv.GoToolPath(t)

// Ensure that all packages imported within GOROOT
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/internal/obj/ppc64/obj9.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func progedit(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) {
// Is this a shifted 16b constant? If so, rewrite it to avoid a creating and loading a constant.
val := p.From.Offset
shift := bits.TrailingZeros64(uint64(val))
mask := 0xFFFF << shift
if val&int64(mask) == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
mask := int64(0xFFFF) << shift
if val&mask == val || (val>>(shift+16) == -1 && (val>>shift)<<shift == val) {
// Rewrite this value into MOVD $const>>shift, Rto; SLD $shift, Rto
q := obj.Appendp(p, c.newprog)
q.As = ASLD
Expand Down
2 changes: 1 addition & 1 deletion src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
golang.org/x/crypto v0.16.1-0.20231129163542-152cdb1503eb
golang.org/x/net v0.19.1-0.20240327214321-ae3c50b55fdf
golang.org/x/net v0.19.1-0.20240412193750-db050b07227e
)

require (
Expand Down
4 changes: 2 additions & 2 deletions src/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
golang.org/x/crypto v0.16.1-0.20231129163542-152cdb1503eb h1:1ceSY7sk6sJuiDREHpfyrqDnDljsLfEP2GuTClhBBfI=
golang.org/x/crypto v0.16.1-0.20231129163542-152cdb1503eb/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/net v0.19.1-0.20240327214321-ae3c50b55fdf h1:zcMReZfxLPmppTre5oSNPSOgoTRtOplx+QV25LkyAto=
golang.org/x/net v0.19.1-0.20240327214321-ae3c50b55fdf/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.19.1-0.20240412193750-db050b07227e h1:oDnvqaqHo3ho8OChMtkQbQAyp9eqnm3J7JRtt0+Cabc=
golang.org/x/net v0.19.1-0.20240412193750-db050b07227e/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
Expand Down
4 changes: 3 additions & 1 deletion src/net/dnsclient_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ func extractExtendedRCode(p dnsmessage.Parser, hdr dnsmessage.Header) dnsmessage
if ahdr.Type == dnsmessage.TypeOPT {
return ahdr.ExtendedRCode(hdr.RCode)
}
p.SkipAdditional()
if err := p.SkipAdditional(); err != nil {
return hdr.RCode
}
}
}

Expand Down
22 changes: 15 additions & 7 deletions src/net/http/h2_bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/runtime/alg.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func alginit() {
return
}
for i := range hashkey {
hashkey[i] = uintptr(rand()) | 1 // make sure these numbers are odd
hashkey[i] = uintptr(bootstrapRand()) | 1 // make sure these numbers are odd
}
}

Expand Down
80 changes: 80 additions & 0 deletions src/runtime/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
"fmt"
"internal/abi"
"internal/goarch"
"internal/testenv"
"math"
"os"
"reflect"
"runtime"
"sort"
Expand Down Expand Up @@ -1464,3 +1466,81 @@ func TestMapValues(t *testing.T) {
}
}
}

func computeHash() uintptr {
var v struct{}
return runtime.MemHash(unsafe.Pointer(&v), 0, unsafe.Sizeof(v))
}

func subprocessHash(t *testing.T, env string) uintptr {
t.Helper()

cmd := testenv.CleanCmdEnv(testenv.Command(t, os.Args[0], "-test.run=^TestMemHashGlobalSeed$"))
cmd.Env = append(cmd.Env, "GO_TEST_SUBPROCESS_HASH=1")
if env != "" {
cmd.Env = append(cmd.Env, env)
}

out, err := cmd.Output()
if err != nil {
t.Fatalf("cmd.Output got err %v want nil", err)
}

s := strings.TrimSpace(string(out))
h, err := strconv.ParseUint(s, 10, 64)
if err != nil {
t.Fatalf("Parse output %q got err %v want nil", s, err)
}
return uintptr(h)
}

// memhash has unique per-process seeds, so hashes should differ across
// processes.
//
// Regression test for https://go.dev/issue/66885.
func TestMemHashGlobalSeed(t *testing.T) {
if os.Getenv("GO_TEST_SUBPROCESS_HASH") != "" {
fmt.Println(computeHash())
os.Exit(0)
return
}

testenv.MustHaveExec(t)

// aeshash and memhashFallback use separate per-process seeds, so test
// both.
t.Run("aes", func(t *testing.T) {
if !*runtime.UseAeshash {
t.Skip("No AES")
}

h1 := subprocessHash(t, "")
t.Logf("%d", h1)
h2 := subprocessHash(t, "")
t.Logf("%d", h2)
h3 := subprocessHash(t, "")
t.Logf("%d", h3)

if h1 == h2 && h2 == h3 {
t.Errorf("got duplicate hash %d want unique", h1)
}
})

t.Run("noaes", func(t *testing.T) {
env := ""
if *runtime.UseAeshash {
env = "GODEBUG=cpu.aes=off"
}

h1 := subprocessHash(t, env)
t.Logf("%d", h1)
h2 := subprocessHash(t, env)
t.Logf("%d", h2)
h3 := subprocessHash(t, env)
t.Logf("%d", h3)

if h1 == h2 && h2 == h3 {
t.Errorf("got duplicate hash %d want unique", h1)
}
})
}
2 changes: 1 addition & 1 deletion src/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ golang.org/x/crypto/cryptobyte/asn1
golang.org/x/crypto/hkdf
golang.org/x/crypto/internal/alias
golang.org/x/crypto/internal/poly1305
# golang.org/x/net v0.19.1-0.20240327214321-ae3c50b55fdf
# golang.org/x/net v0.19.1-0.20240412193750-db050b07227e
## explicit; go 1.18
golang.org/x/net/dns/dnsmessage
golang.org/x/net/http/httpguts
Expand Down

0 comments on commit 467a489

Please sign in to comment.