Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/godebug.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ SecP256r1MLKEM768 and SecP384r1MLKEM1024. The default can be reverted using the
[`tlssecpmlkem` setting](/pkg/crypto/tls/#Config.CurvePreferences).

Go 1.26 added a new `tracebacklabels` setting that controls the inclusion of
goroutine labels set through the the `runtime/pprof` package. Setting `tracebacklabels=1`
goroutine labels set through the `runtime/pprof` package. Setting `tracebacklabels=1`
includes these key/value pairs in the goroutine status header of runtime
tracebacks and debug=2 runtime/pprof stack dumps. This format may change in the future.
(see go.dev/issue/76349)
Expand Down
14 changes: 10 additions & 4 deletions src/archive/tar/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,16 @@ func (b *block) setFormat(format Format) {
// signed byte values.
// We compute and return both.
func (b *block) computeChecksum() (unsigned, signed int64) {
for i, c := range b {
if 148 <= i && i < 156 {
c = ' ' // Treat the checksum field itself as all spaces.
}
for _, c := range b[:148] {
unsigned += int64(c)
signed += int64(int8(c))
}
// Treat the checksum field itself (bytes 148 to 155, inclusive)
// as if it were all spaces.
const chksumSpaces = 8 * int64(' ')
unsigned += chksumSpaces
signed += chksumSpaces
for _, c := range b[156:] {
unsigned += int64(c)
signed += int64(int8(c))
}
Expand Down
8 changes: 5 additions & 3 deletions src/archive/tar/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,11 @@ func (tr *Reader) readHeader() (*Header, *block, error) {

// For Format detection, check if block is properly formatted since
// the parser is more liberal than what USTAR actually permits.
notASCII := func(r rune) bool { return r >= 0x80 }
if bytes.IndexFunc(tr.blk[:], notASCII) >= 0 {
hdr.Format = FormatUnknown // Non-ASCII characters in block.
for _, c := range tr.blk[:] {
if c >= 0x80 {
hdr.Format = FormatUnknown // Non-ASCII characters in block.
break
}
}
nul := func(b []byte) bool { return int(b[len(b)-1]) == 0 }
if !(nul(v7.size()) && nul(v7.mode()) && nul(v7.uid()) && nul(v7.gid()) &&
Expand Down
20 changes: 17 additions & 3 deletions src/cmd/compile/internal/amd64/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"cmd/internal/obj"
"cmd/internal/obj/x86"
"internal/abi"
"internal/buildcfg"
)

// ssaMarkMoves marks any MOVXconst ops that need to avoid clobbering flags.
Expand Down Expand Up @@ -944,10 +945,15 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
ssagen.AddAux2(&p.To, v, off)

case ssa.OpAMD64MOVQstoreconst, ssa.OpAMD64MOVLstoreconst, ssa.OpAMD64MOVWstoreconst, ssa.OpAMD64MOVBstoreconst:
p := s.Prog(v.Op.Asm())
p.From.Type = obj.TYPE_CONST
sc := v.AuxValAndOff()
p.From.Offset = sc.Val64()
p := s.Prog(v.Op.Asm())
if sc.Val() == 0 && s.ABI == obj.ABIInternal && buildcfg.GOOS != "plan9" && (v.Op == ssa.OpAMD64MOVQstoreconst || v.Op == ssa.OpAMD64MOVLstoreconst) {
p.From.Type = obj.TYPE_REG
p.From.Reg = x86.REG_X15
} else {
p.From.Type = obj.TYPE_CONST
p.From.Offset = sc.Val64()
}
p.To.Type = obj.TYPE_MEM
p.To.Reg = v.Args[0].Reg()
ssagen.AddAux2(&p.To, v, sc.Off64())
Expand Down Expand Up @@ -981,6 +987,14 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
p.From.Type = obj.TYPE_CONST
sc := v.AuxValAndOff()
p.From.Offset = sc.Val64()
if sc.Val() == 0 && s.ABI == obj.ABIInternal && buildcfg.GOOS != "plan9" {
switch v.Op {
case ssa.OpAMD64MOVQstoreconstidx1, ssa.OpAMD64MOVQstoreconstidx8,
ssa.OpAMD64MOVLstoreconstidx1, ssa.OpAMD64MOVLstoreconstidx4:
p.From.Type = obj.TYPE_REG
p.From.Reg = x86.REG_X15
}
}
switch {
case p.As == x86.AADDQ && p.From.Offset == 1:
p.As = x86.AINCQ
Expand Down
1 change: 0 additions & 1 deletion src/cmd/compile/internal/ssa/_gen/AMD64.rules
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,6 @@

// CPUID feature: BMI1.
(AND(Q|L) x (NOT(Q|L) y)) && buildcfg.GOAMD64 >= 3 => (ANDN(Q|L) x y)
(SUB(Q|L) x (AND(Q|L) x y)) && buildcfg.GOAMD64 >= 3 => (ANDN(Q|L) x y)
(AND(Q|L) x (NEG(Q|L) x)) && buildcfg.GOAMD64 >= 3 => (BLSI(Q|L) x)
(XOR(Q|L) x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (BLSMSK(Q|L) x)
(AND(Q|L) <t> x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (Select0 <t> (BLSR(Q|L) x))
Expand Down
50 changes: 0 additions & 50 deletions src/cmd/compile/internal/ssa/rewriteAMD64.go

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

36 changes: 36 additions & 0 deletions src/cmd/go/internal/modcmd/why.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"cmd/go/internal/base"
"cmd/go/internal/imports"
"cmd/go/internal/modload"

"golang.org/x/mod/module"
)

var cmdWhy = &base.Command{
Expand Down Expand Up @@ -82,7 +84,11 @@ func runWhy(ctx context.Context, cmd *base.Command, args []string) {
if strings.Contains(arg, "@") {
base.Fatalf("go: %s: 'go mod why' requires a module path, not a version query", arg)
}
if err := checkModulePathPattern(arg); err != nil {
base.Errorf("go mod why: %v", err)
}
}
base.ExitIfErrors()

mods, err := modload.ListModules(moduleLoader, ctx, args, 0, "")
if err != nil {
Expand Down Expand Up @@ -142,3 +148,33 @@ func runWhy(ctx context.Context, cmd *base.Command, args []string) {
}
}
}

func checkModulePathPattern(pattern string) error {
parts := strings.Split(pattern, "...")
if len(parts) == 1 {
return modulePathError(pattern, module.CheckImportPath(pattern))
}

// Add placeholders for the wildcards adjoining each literal part so that
// separators at wildcard boundaries form complete paths during validation.
if err := module.CheckImportPath(parts[0] + "x"); err != nil {
return modulePathError(pattern, err)
}
for i, part := range parts[1:] {
if i < len(parts)-2 {
part += "x"
}
if err := module.CheckFilePath("x" + part); err != nil {
return modulePathError(pattern, err)
}
}
return nil
}

func modulePathError(path string, err error) error {
if pathErr, ok := err.(*module.InvalidPathError); ok {
pathErr.Kind = "module"
pathErr.Path = path
}
return err
}
27 changes: 27 additions & 0 deletions src/cmd/go/testdata/script/mod_why.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
env GO111MODULE=on

# 'go mod why -m' should reject malformed module paths before loading
# the module graph.
! go mod why -m golang.org/x/text/
stderr '^go mod why: malformed module path "golang.org/x/text/": trailing slash$'

# Module patterns should validate the literal path around each wildcard.
! go mod why -m golang.org//x/...
stderr '^go mod why: malformed module path "golang.org//x/...": double slash$'
! go mod why -m golang.org/...//.../text
stderr '^go mod why: malformed module path "golang.org/...//.../text": double slash$'

[short] skip

# Populate go.sum.
Expand All @@ -17,6 +29,14 @@ cmp stdout why-language.txt
go mod why -m golang.org...
cmp stdout why-text-module.txt

# Module patterns may contain multiple wildcards.
go mod why -m golang...org/.../te...
cmp stdout why-text-module.txt

# Module paths that are valid only when replaced should be accepted.
go mod why -m mymodule/nested
cmp stdout why-replaced-module.txt

# why a package used only in tests?
go mod why rsc.io/testonly
cmp stdout why-testonly.txt
Expand Down Expand Up @@ -56,6 +76,10 @@ cmp go.mod go.mod.orig
-- go.mod --
module mymodule
require rsc.io/quote v1.5.2
replace mymodule/nested => ./nested

-- nested/go.mod --
module mymodule/nested

-- x/x.go --
package x
Expand Down Expand Up @@ -90,6 +114,9 @@ mymodule/y.test
rsc.io/quote
rsc.io/sampler
golang.org/x/text/language
-- why-replaced-module.txt --
# mymodule/nested
(main module does not need module mymodule/nested)
-- why-testonly.txt --
# rsc.io/testonly
mymodule/y
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/fallocate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build darwin || freebsd || linux || (netbsd && go1.25)
//go:build darwin || freebsd || linux || netbsd

package ld

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/outbuf_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build freebsd || (netbsd && go1.25)
//go:build freebsd || netbsd

package ld

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/link/internal/ld/outbuf_nofallocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !darwin && !freebsd && !linux && !(netbsd && go1.25)
//go:build !darwin && !freebsd && !linux && !netbsd

package ld

Expand Down
8 changes: 5 additions & 3 deletions src/embed/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,14 @@ func (f *openFile) Read(b []byte) (int, error) {

func (f *openFile) Seek(offset int64, whence int) (int64, error) {
switch whence {
case 0:
case io.SeekStart:
// offset += 0
case 1:
case io.SeekCurrent:
offset += f.offset
case 2:
case io.SeekEnd:
offset += int64(len(f.f.data))
default:
return 0, &fs.PathError{Op: "seek", Path: f.f.name, Err: fs.ErrInvalid}
}
if offset < 0 || offset > int64(len(f.f.data)) {
return 0, &fs.PathError{Op: "seek", Path: f.f.name, Err: fs.ErrInvalid}
Expand Down
11 changes: 11 additions & 0 deletions src/embed/internal/embedtest/embed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package embedtest

import (
"embed"
"errors"
"io"
"io/fs"
"reflect"
"slices"
"testing"
Expand Down Expand Up @@ -220,6 +222,15 @@ func TestOffset(t *testing.T) {
t.Fatal("Seek:", off)
}

// Use Seek with an invalid whence.
_, err = seeker.Seek(0, io.SeekEnd+5)
if err == nil {
t.Fatal("Seek: expected error for invalid whence")
}
if !errors.Is(err, fs.ErrInvalid) {
t.Fatalf("Seek: expected fs.ErrInvalid, got %v", err)
}

// Use ReadAt to read the entire file, ignoring the offset.
at := file.(io.ReaderAt)
got = make([]byte, len(want))
Expand Down
16 changes: 4 additions & 12 deletions src/runtime/chan.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,10 @@ func chansend1(c *hchan, elem unsafe.Pointer) {
chansend(c, elem, true, sys.GetCallerPC())
}

/*
* generic single channel send/recv
* If block is not nil,
* then the protocol will not
* sleep but return if it could
* not complete.
*
* sleep can wake up with g.param == nil
* when a channel involved in the sleep has
* been closed. it is easiest to loop and re-run
* the operation; we'll see that it's now closed.
*/
// chansend sends the element pointed to by ep on channel c.
// A send on a closed channel panics.
// If block == false and the send cannot proceed immediately, it returns false.
// Otherwise, it waits as needed for the send to complete and returns true.
func chansend(c *hchan, ep unsafe.Pointer, block bool, callerpc uintptr) bool {
if c == nil {
if !block {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ return

### Description

The the lock for the struct svm has already been locked when calling
The lock for the struct svm has already been locked when calling
`svm.hotRemoveVHDsAtStart()`.

## Moby/4951
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/unsafepoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestUnsafePoint(t *testing.T) {
if parts[3] == "CMPL" {
startedWB = true
}
if parts[3] == "MOVQ" && parts[4] == "$0x0," {
if parts[3] == "MOVQ" && (parts[4] == "$0x0," || parts[4] == "X15,") {
doneWB = true
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/codegen/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func outOfBoundsConv(i32 *[2]int32, u32 *[2]uint32, i64 *[2]int64, u64 *[2]uint6
u32[0] = uint32(two41())
// on arm64, this uses an explicit <0 comparison, so it constant folds.
// on amd64, this uses an explicit <0 comparison, so it constant folds.
// amd64: "MOVL [$]0,"
// amd64: "MOVL X15,"
u32[1] = uint32(minus1())
// arm64: "FCVTZSD"
// amd64: "CVTTSD2SQ"
Expand All @@ -356,7 +356,7 @@ func outOfBoundsConv(i32 *[2]int32, u32 *[2]uint32, i64 *[2]int64, u64 *[2]uint6
u64[0] = uint64(two81())
// arm64: "FCVTZUD"
// on amd64, this uses an explicit <0 comparison, so it constant folds.
// amd64: "MOVQ [$]0,"
// amd64: "MOVQ X15,"
u64[1] = uint64(minus1())
}

Expand Down
Loading
Loading