]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 months agoencoding/json/v2: restrict presence of default options
Joe Tsai [Sat, 11 Oct 2025 18:37:58 +0000 (11:37 -0700)]
encoding/json/v2: restrict presence of default options

Originally, DefaultOptionsV1 and DefaultOptionsV2 represented
the full set of all options with specific ones set to true or false.

However, there are certain options such as WithIndent or WithMarshalers
that are neither v1 or v2 specific.
At some point we removed whitespace related options from the set:
https://github.com/go-json-experiment/json/pull/26

This avoids DefaultOptionsV1 or DefaultOptionsV2 from affecting
any previously set whitespace. However, why are whitespace options
special and thus excluded from the set? What about Marshalers?

As a more principaled way to address this, we restrict
DefaultOptionsV1 and DefaultOptionsV2 to only be the options
where the default setting changes between v1 and v2.
All other options are unpopulated.

This avoids a panic with GetOption(DefaultOptionsV2, WithMarshalers)
since DefaultOptionsV2 previously had the presence bit for
Marshalers set to true, but had no actual value.
Now, the presence bit is set to false, so the value is not consulted.

Fixes #75149

Change-Id: I30b45abd35404578b4135cc3bad1a1a2993cb0cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/710878
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
3 months agogo/types, types2: permit type cycles through type parameter lists
Robert Griesemer [Mon, 13 Oct 2025 19:47:42 +0000 (12:47 -0700)]
go/types, types2: permit type cycles through type parameter lists

Issue #49439 was about a deadlock during type inference inside
a type parameter list of a recursive constraint. As a remedy
we disallowed recursive type parameter lists.

In the meantime we have removed support for type inference for
type arguments to generic types; the Go 1.18 generic release
didn't support it.

As a consequence, the fix for #49439, CL 361922, is probably
not needed anymore: cycles through type parameter lists are ok.

Fixes #68162.
For #49439.

Change-Id: Ie9deb3274914d428e8e45071cee5e68abf8afe9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/711420
Commit-Queue: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>

3 months agostrconv: add tests that Java once mishandled
Russ Cox [Thu, 9 Oct 2025 19:02:23 +0000 (15:02 -0400)]
strconv: add tests that Java once mishandled

Change-Id: I372233d8494665b3300f9a186c883a4254435e1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/710617
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: don't depend on arch-dependent conversions in the compiler
Keith Randall [Mon, 13 Oct 2025 16:39:06 +0000 (09:39 -0700)]
cmd/compile: don't depend on arch-dependent conversions in the compiler

Leave those constant foldings for runtime, similar to how we do it
for NaN generation.

These are the only instances I could find in cmd/compile/..., using

objdump -d ../pkg/tool/darwin_arm64/compile| egrep "(fcvtz|>:)" | grep -B1 fcvt

(There are instances in other places, like runtime and reflect, but I don't
think those places would affect compiler output.)

Change-Id: I4113fe4570115e4765825cf442cb1fde97cf2f27
Reviewed-on: https://go-review.googlesource.com/c/go/+/711281
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agoencoding/json/v2: report EOF for top-level values in UnmarshalDecode
Joe Tsai [Sat, 11 Oct 2025 00:56:04 +0000 (17:56 -0700)]
encoding/json/v2: report EOF for top-level values in UnmarshalDecode

The fully streaming UnmarshalJSONFrom method and UnmarshalFromFunc
introduce an edge case where they can encounter EOF in the stream,
where it should be reported upstream as EOF rather than
ErrUnexpectedEOF or be wrapped within a SemanticError.

This is not possible with other unmarshal methods since the
"json" package would read the appropriate JSON value
before calling the custom method or function.

To avoid custom unmarshal methods from encountering EOF,
check whether the stream is already at EOF for top-level values
before calling the custom method.

Also, when wrapping EOF within a SemanticError, convert it
to ErrUnexpectedEOF to better indicate that this is unexpected.

Fixes #75802

Change-Id: I001396734b7e95b5337f77b71326284974ee730a
Reviewed-on: https://go-review.googlesource.com/c/go/+/710877
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agoall: replace calls to errors.As with errors.AsType
Julien Cretel [Wed, 1 Oct 2025 20:08:18 +0000 (20:08 +0000)]
all: replace calls to errors.As with errors.AsType

This change replaces most occurrences (in code as well as in comments) of
errors.As with errors.AsType. It leaves the errors package and vendored
code untouched.

Change-Id: I3bde73f318a0b408bdb8f5a251494af15a13118a
GitHub-Last-Rev: 8aaaa36a5a12d2a6a90c6d51680464e1a3115139
GitHub-Pull-Request: golang/go#75698
Reviewed-on: https://go-review.googlesource.com/c/go/+/708495
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocrypto/x509: rework fix for CVE-2025-58187
Roland Shoemaker [Thu, 9 Oct 2025 20:35:24 +0000 (13:35 -0700)]
crypto/x509: rework fix for CVE-2025-58187

In CL 709854 we enabled strict validation for a number of properties of
domain names (and their constraints). This caused significant breakage,
since we didn't previously disallow the creation of certificates which
contained these malformed domains.

Rollback a number of the properties we enforced, making domainNameValid
only enforce the same properties that domainToReverseLabels does. Since
this also undoes some of the DoS protections our initial fix enabled,
this change also adds caching of constraints in isValid (which perhaps
is the fix we should've initially chosen).

Updates #75835
Fixes #75828

Change-Id: Ie6ca6b4f30e9b8a143692b64757f7bbf4671ed0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/710735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
3 months agocmd/link: in TestFallocate, only check number of blocks on Darwin
Cherry Mui [Sat, 11 Oct 2025 14:36:49 +0000 (10:36 -0400)]
cmd/link: in TestFallocate, only check number of blocks on Darwin

The number-of-blocks check was introduced when fixing a Darwin-
specific bug. On Darwin, the file allocation syscall is a bit
tricky. On Linux and BSDs, it is more straightforward and unlikely
to go wrong.

The test itself, on the other hand, is less reliable on Linux (and
perhaps BSDs), as it is considered less portable and is an
implementation detail of the file system.

Given these two reasons, only check it on Darwin.

Fixes #75795.

Change-Id: I3da891fd60a141c3eca5d0f5ec20c2cad65b8862
Reviewed-on: https://go-review.googlesource.com/c/go/+/711095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 months agoencoding/json: fix regression in quoted numbers under goexperiment.jsonv2
Joe Tsai [Mon, 6 Oct 2025 19:56:29 +0000 (12:56 -0700)]
encoding/json: fix regression in quoted numbers under goexperiment.jsonv2

The legacy parsing of quoted numbers in v1 was according to
the Go grammar for a number, rather than
the JSON grammar for a number.
The former is a superset of the latter.

This is a historical mistake, but usages exist that depend on it.
We already have branches for StringifyWithLegacySemantics
to handle quoted nulls, so we can expand it to handle this.

Fixes #75619

Change-Id: Ic07802539b7cbe0e1f53bd0f7e9bb344a8447203
Reviewed-on: https://go-review.googlesource.com/c/go/+/709615
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agocmd/compile: repair bisection behavior for float-to-unsigned conversion
David Chase [Fri, 10 Oct 2025 21:08:20 +0000 (17:08 -0400)]
cmd/compile: repair bisection behavior for float-to-unsigned conversion

My stab at a bisect-reproducer failed, but I verified that
it fixed the problem described in the issue.

Updates #75834

Change-Id: I9e0dfacd2bbd22cbc557e144920ee3417a48088c
Reviewed-on: https://go-review.googlesource.com/c/go/+/710997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agoruntime: fail TestGoroutineLeakProfile on data race
Michael Anthony Knyszek [Thu, 9 Oct 2025 20:58:34 +0000 (20:58 +0000)]
runtime: fail TestGoroutineLeakProfile on data race

Some of the programs in testdata/testgoroutineleakprofile have data
races because they were taken from a corpus that showcases general Go
concurrency bugs, not just leaked goroutines.

This causes some flakiness as tests might fail due to, for example, a
concurrent map access, even outside of race mode.

Let's just call data races a failure and fix them in the examples. As
far as I can tell, there are only two that show up consistently.

Fixes #75732.

Change-Id: I160b3a1cdce4c2de3f2320b68b4083292e02b557
Reviewed-on: https://go-review.googlesource.com/c/go/+/710756
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agonet/url: disallow raw IPv6 addresses in host
Sean Liao [Thu, 9 Oct 2025 00:56:09 +0000 (01:56 +0100)]
net/url: disallow raw IPv6 addresses in host

RFC 3986 requires square brackets around IPv6 addresses.
Parse's acceptance of raw IPv6 addresses is non compliant,
and complicates splitting out a port.

Fixes #31024
Fixes #75223

Change-Id: I477dc420a7441cb33156627dbd5e46d88c677f1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/710176
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agonet/http: strip request body headers on POST to GET redirects
Sean Liao [Thu, 9 Oct 2025 01:26:02 +0000 (02:26 +0100)]
net/http: strip request body headers on POST to GET redirects

According to WHATWG Fetch, when the body is dropped in a redirect,
headers that describe the body should also be dropped.
https://fetch.spec.whatwg.org/#http-redirect-fetch

Fixes #57273

Change-Id: I84598f69608e95c1b556ea0ce5953ed43bf2d824
Reviewed-on: https://go-review.googlesource.com/c/go/+/710395
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoall: omit unnecessary reassignment
cuishuang [Fri, 10 Oct 2025 03:47:13 +0000 (11:47 +0800)]
all: omit unnecessary reassignment

The new version of Go has been optimized, and variables do not need
to be reassigned.

Change-Id: I0374b049271e53510f2b162f6821fb3595f2c8ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/710835
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agonet/http: set cookie host to Request.Host when available
Sean Liao [Wed, 8 Oct 2025 21:33:24 +0000 (22:33 +0100)]
net/http: set cookie host to Request.Host when available

When both Request.URL and Request.Host are set, the host in URL
is used for connecting at the transport level, while Host is used
for the request host line. Cookies should be set for the request,
not the underlying connection destination.

Fixes #38988

Change-Id: I09053b87ccac67081f6038d205837d9763701526
Reviewed-on: https://go-review.googlesource.com/c/go/+/710335
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/go: unify "go fix" and "go vet"
Alan Donovan [Fri, 26 Sep 2025 17:33:09 +0000 (13:33 -0400)]
cmd/go: unify "go fix" and "go vet"

This change unifies the fix and vet subcommands; they use the
same run function, action graph, and external tool (-vettool
for go vet and -fixtool for go fix). go fix runs the tool
with the -fix flag, whereas although go vet also supports
-fix, it is not the default. The two tools have different
(overlapping) suites of analyzers.

The high-level parts are fully parameterized over the
vet/fix distinction; the lower-level parts (the action
graph) continue to use only the "vet" terminology.
The cmd/{vet,fix} executable is referred to as the "tool".

The tool is generally invoked in -json mode, regardless
of whether -json was requested, so that the tool produces
a cacheable JSON blob on stdout. When the go user did not
request -json, this blob is parsed and printed to stderr
by logic in the go vet command. (Formerly the tool would
print diagnostics to stderr, but this interacts poorly
with the build cache.)

go fix's legacy -fix=fixer,... flag is now a no-op that
prints a warning that the flag is obsolete.

The unitchecker's -c=n flag (to display n lines of context
around each diagnostic) is reimplemented in go vet based
on the JSON information, to avoid reliance on the stderr
output of the tool.

cmd/fix is added to dist's prebuilt set of tools since
go fix cannot build it dynamically (though ideally
it would).

Updates #71859
For #75432

Change-Id: I0a84746720b59d05d662ed57826747c5598dca44
Reviewed-on: https://go-review.googlesource.com/c/go/+/700795
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Bypass: Alan Donovan <adonovan@google.com>

3 months agoruntime: support arm64 Neon in async preemption
Julia Lapenko [Wed, 13 Aug 2025 19:23:14 +0000 (22:23 +0300)]
runtime: support arm64 Neon in async preemption

This is a port of CL 669195 adjusted to save arm64 Neon registers
off stack.

Change-Id: Ia014778a8c9f0c1d05977b04184f51e791ae8495
Reviewed-on: https://go-review.googlesource.com/c/go/+/695916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agonet/http: run TestRequestWriteTransport with fake time to avoid flakes
Damien Neil [Thu, 9 Oct 2025 22:25:30 +0000 (15:25 -0700)]
net/http: run TestRequestWriteTransport with fake time to avoid flakes

This test verifies whether or not we use the chunked encoding when
sending a request with a body like io.NopCloser(strings.NewReader("")).
This depends on whether the transport can read a single byte from the
request body within 200ms, which is flaky on very slow builders.

Use fake time to avoid flakes.

Fixes #52575

Change-Id: Ie11a58ac6bc18d43af1423827887e804242dee30
Reviewed-on: https://go-review.googlesource.com/c/go/+/710737
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agointernal/buildcfg: enable greenteagc experiment for loong64
WANG Xuerui [Thu, 9 Oct 2025 08:05:35 +0000 (16:05 +0800)]
internal/buildcfg: enable greenteagc experiment for loong64

The loong64 compiler bug has been resolved, so we can now
unconditionally enable the experiment on the architecture.

Updates #73581
Fixes #75776

Change-Id: I390f8a125d43ca64798ea5b6a408aaf7220fadbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/710476
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agocmd/compile: declare no output register for loong64 LoweredAtomic{And,Or}32 ops
WANG Xuerui [Thu, 9 Oct 2025 07:52:02 +0000 (15:52 +0800)]
cmd/compile: declare no output register for loong64 LoweredAtomic{And,Or}32 ops

The ICE seen on loong64 while compiling the `(*gcWork).tryStealSpan`
function was due to an `LoweredAtomicAnd32` op (inlined from the
`(pMask).clear` implementation) being incorrectly assigned an output
register while it shouldn't have. Because the op is of mem type, it has
needRegister() == false; hence in the shuffle phase of regalloc, its
bogus output register has no associated `orig` value recorded. The bug
was introduced in CL 482756, but only recently exposed by CL 696035.

Since the old-style atomic ops need no return value (and is even
documented so besides the loong64 ssa op definition), just fix the
register info for both.

While at it, add a note in the ssa op definition file about the
architectural necessity of resultNotInArgs for loong64 atomic ops,
because the practice is not seen in several other arches I have
checked.

Updates #75776

Change-Id: I087f51b8a2825d7b00fc3965b0afcc8b02cad277
Reviewed-on: https://go-review.googlesource.com/c/go/+/710475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agocmd/compile: call generated size-specialized malloc functions directly
Michael Matloob [Mon, 29 Sep 2025 21:26:49 +0000 (17:26 -0400)]
cmd/compile: call generated size-specialized malloc functions directly

This change creates calls to size-specialized malloc functions instead
of calls to newObject when we know the size of the allocation at
compilation time. Most of it is a matter of calling the newObject
function (which will create calls to the size-specialized functions)
rather then the newObjectNonSpecialized function (which won't). In the
newHeapaddr, small, non-pointer case, we'll create a non specialized
newObject and transform that into the appropriate size-specialized
function when we produce the mallocgc in flushPendingHeapAllocations.

We have to update some of the rewrites in generic.rules to also apply to
the size-specialized functions when they apply to newObject.

The messiest thing is we have to adjust the offset we use to save the
memory profiler stack, because the depth of the call to profilealloc is
two frames fewer in the size-specialized malloc functions compared to
when newObject calls mallocgc. A bunch of tests have been adjusted to
account for that.

Change-Id: I6a6a6964c9037fb6719e392c4a498ed700b617d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/707856
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 months agoreflect: remove timeout in TestChanOfGC
Michael Anthony Knyszek [Thu, 9 Oct 2025 21:13:59 +0000 (21:13 +0000)]
reflect: remove timeout in TestChanOfGC

This test has an arbitrary 5 second timeout, and this seems to fire on
Darwin with mayMoreStackMove enabled (which is slow). Just rely on the
regular test timeout instead of this arbitrary shorter timeout to
eliminate the possibility that the test is just too slow.

On my Linux VM, I can get this test to take up to 2 seconds with
mayMoreStackMove set on all the same packages dist does, so this failure
mode is actually plausible.

Fixes #75742.

Change-Id: Iebcc859cab26e9205b57b869690162a9a424dfce
Reviewed-on: https://go-review.googlesource.com/c/go/+/710618
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 months agonet/url: allow IP-literals with IPv4-mapped IPv6 addresses
Roland Shoemaker [Thu, 9 Oct 2025 00:13:12 +0000 (17:13 -0700)]
net/url: allow IP-literals with IPv4-mapped IPv6 addresses

The security fix we applied in CL709857 was overly broad. It applied
rules from RFC 2732, which disallowed IPv4-mapped IPv6 addresses, but
these were later allowed in RFC 3986, which is the canonical URI syntax
RFC.

Revert the portion of CL709857 which restricted IPv4-mapped addresses,
and update the related tests.

Fixes #75815

Change-Id: I3192f2275ad5c386f5c15006a6716bdb5282919d
Reviewed-on: https://go-review.googlesource.com/c/go/+/710375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ethan Lee <ethanalee@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>

3 months agocmd/compile: make wasm match other platforms for FP->int32/64 conversions
David Chase [Wed, 1 Oct 2025 15:29:13 +0000 (11:29 -0400)]
cmd/compile: make wasm match other platforms for FP->int32/64 conversions

this change is for overflows, so that all the platforms agree.

Change-Id: I9f459353615bf24ef8a5de641063d9ce34986241
Reviewed-on: https://go-review.googlesource.com/c/go/+/708358
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
3 months agoruntime: adjust softfloat corner cases to match amd64/arm64
David Chase [Mon, 6 Oct 2025 19:01:03 +0000 (15:01 -0400)]
runtime: adjust softfloat corner cases to match amd64/arm64

This chooses saturating behavior for over/underflow.

Change-Id: I96a33ef73feacdafe8310f893de445060bc1a536
Reviewed-on: https://go-review.googlesource.com/c/go/+/709595
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/compile: make 386 float-to-int conversions match amd64
David Chase [Tue, 30 Sep 2025 20:27:32 +0000 (16:27 -0400)]
cmd/compile: make 386 float-to-int conversions match amd64

Change-Id: Iff13b4471f94a6a91d8b159603a9338cb9c89747
Reviewed-on: https://go-review.googlesource.com/c/go/+/708295
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: modify float-to-[u]int so that amd64 and arm64 match
David Chase [Mon, 21 Jul 2025 17:30:08 +0000 (13:30 -0400)]
cmd/compile: modify float-to-[u]int so that amd64 and arm64 match

Eventual goal is that all the architectures agree, and are
sensible.  The test will be build-tagged to exclude
not-yet-handled platforms.

This change also bisects the conversion change in case of bugs.
(`bisect -compile=convert ...`)

Change-Id: I98528666b0a3fde17cbe8d69b612d01da18dce85
Reviewed-on: https://go-review.googlesource.com/c/go/+/691135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
3 months agonet/http/httptest: check whether response bodies are allowed
Sean Liao [Sun, 5 Oct 2025 22:09:03 +0000 (23:09 +0100)]
net/http/httptest: check whether response bodies are allowed

Fixes #75471

Change-Id: Ie8fc5fae4b2a9285501198d8379bbffe51ee63f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/709335
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agopath/filepath: return cleaned path from Rel
Federico Guerinoni [Mon, 6 Oct 2025 23:13:14 +0000 (01:13 +0200)]
path/filepath: return cleaned path from Rel

As the doc says, Rel should return a cleaned path.

Fixes #75763

Change-Id: Ic0f5a3b1da3cc4cf3c31fdb1a88ebcc4ea6f9169
Reviewed-on: https://go-review.googlesource.com/c/go/+/709675
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agocmd/compile/internal/devirtualize: improve concrete type analysis
Mateusz Poliwczak [Tue, 7 Oct 2025 17:57:59 +0000 (17:57 +0000)]
cmd/compile/internal/devirtualize: improve concrete type analysis

This change improves the concrete type analysis in the devirtualizer,
it not longer relies on ir.Reassigned, it now statically tries to
determine the concrete type of an interface, even when assigned
multiple times, following type assertions and iface conversions.

Alternative to CL 649195

Updates #69521
Fixes #64824

Change-Id: Ib1656e19f3619ab2e1e6b2c78346cc320490b2af
GitHub-Last-Rev: e8fa0b12f0a7b1d7ae00e5edb54ce04d1f702c09
GitHub-Pull-Request: golang/go#71935
Reviewed-on: https://go-review.googlesource.com/c/go/+/652036
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>

3 months agocrypto/internal/fips140test: make entropy file pair names match
Filippo Valsorda [Mon, 29 Sep 2025 11:36:28 +0000 (13:36 +0200)]
crypto/internal/fips140test: make entropy file pair names match

Change-Id: I6a6a69642d00e3994277d9b5631d1d7f18f3f356
Reviewed-on: https://go-review.googlesource.com/c/go/+/710055
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 months agoruntime: cleanup comments from asm_ppc64x.s improvements
Paul Murphy [Wed, 1 Oct 2025 14:23:18 +0000 (09:23 -0500)]
runtime: cleanup comments from asm_ppc64x.s improvements

CL 706395 consolidated the aix and elf startup code, further
update the comments to reflect this.

Change-Id: Iccb98008b3fe4a4b08e55ee822924fad76846cc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/708355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Paul Murphy <paumurph@redhat.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/gofmt: change -d to exit 1 if diffs exist
Robbie McMichael [Mon, 6 Oct 2025 12:47:34 +0000 (12:47 +0000)]
cmd/gofmt: change -d to exit 1 if diffs exist

When using the -d flag, set the exit code to 1 if there is a diff.

Fixes #46289

Change-Id: I802e8ccd1798ed7f4448696bec4bc82835ec71a2
GitHub-Last-Rev: db2207fba9a8f7a2f50138ec1f086ac6a74e1b10
GitHub-Pull-Request: golang/go#75649
Reviewed-on: https://go-review.googlesource.com/c/go/+/707635
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/internal/obj: fix Link.Diag printf errors
Alan Donovan [Wed, 8 Oct 2025 16:19:14 +0000 (12:19 -0400)]
cmd/internal/obj: fix Link.Diag printf errors

go1.26's vet printf checker can associate the printf-wrapper
property with local vars and struct fields if they are assigned
from a printf-like func literal (CL 706635). This leads to better
detection of mistakes.

Change-Id: I604be1e200aa1aba75e09d4f36ab68c1dba3b8a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/710195
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agonet/http: format pprof.go
Vlad Saioc [Mon, 6 Oct 2025 15:10:52 +0000 (15:10 +0000)]
net/http: format pprof.go

Properly formatted net/http/pprof.go to correct
inconsistent whitespaces between keys and values
for profileSupportsDelta.

Change-Id: Iea1515b4289de95862d7eb3af5b8d8d13df2b990
GitHub-Last-Rev: 381d2d3ee746fafdf688b96c8b56a081a1283381
GitHub-Pull-Request: golang/go#75769
Reviewed-on: https://go-review.googlesource.com/c/go/+/709415
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

3 months agonet/http: update HTTP/2 documentation to reference new config features
Damien Neil [Tue, 7 Oct 2025 18:06:18 +0000 (11:06 -0700)]
net/http: update HTTP/2 documentation to reference new config features

Update the package docs to point users at the modern HTTP/2
configuration APIs.

Mention in the TLSNextProto documentation that this field is
superseded by the Protocols field for most user-facing purposes.

Change-Id: I30cd9a85a27e1174338f0d6b887f98c28eac5b5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/709797
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: fuse NaN checks with other comparisons
Michael Munday [Mon, 18 Aug 2025 21:51:36 +0000 (22:51 +0100)]
cmd/compile: fuse NaN checks with other comparisons

NaN checks can often be merged into other comparisons by inverting them.
For example, `math.IsNaN(x) || x > 0` is equivalent to `!(x <= 0)`.

goos: linux
goarch: amd64
pkg: math
cpu: 12th Gen Intel(R) Core(TM) i7-12700T
            â”‚         sec/op         â”‚    sec/op     vs base                â”‚
Acos                     4.315n Â± 0%    4.314n Â± 0%        ~ (p=0.642 n=10)
Acosh                    8.398n Â± 0%    7.779n Â± 0%   -7.37% (p=0.000 n=10)
Asin                     4.203n Â± 0%    4.211n Â± 0%   +0.20% (p=0.001 n=10)
Asinh                   10.150n Â± 0%    9.562n Â± 0%   -5.79% (p=0.000 n=10)
Atan                     2.363n Â± 0%    2.363n Â± 0%        ~ (p=0.801 n=10)
Atanh                    8.192n Â± 2%    7.685n Â± 0%   -6.20% (p=0.000 n=10)
Atan2                    4.013n Â± 0%    4.010n Â± 0%        ~ (p=0.073 n=10)
Cbrt                     4.858n Â± 0%    4.755n Â± 0%   -2.12% (p=0.000 n=10)
Cos                      4.596n Â± 0%    4.357n Â± 0%   -5.20% (p=0.000 n=10)
Cosh                     5.071n Â± 0%    5.071n Â± 0%        ~ (p=0.585 n=10)
Erf                      2.802n Â± 1%    2.788n Â± 0%   -0.54% (p=0.002 n=10)
Erfc                     3.087n Â± 1%    3.071n Â± 0%        ~ (p=0.320 n=10)
Erfinv                   3.981n Â± 0%    3.965n Â± 0%   -0.41% (p=0.000 n=10)
Erfcinv                  3.985n Â± 0%    3.977n Â± 0%   -0.20% (p=0.000 n=10)
ExpGo                    8.721n Â± 2%    8.252n Â± 0%   -5.38% (p=0.000 n=10)
Expm1                    4.378n Â± 0%    4.228n Â± 0%   -3.43% (p=0.000 n=10)
Exp2                     8.313n Â± 0%    7.855n Â± 0%   -5.52% (p=0.000 n=10)
Exp2Go                   8.498n Â± 2%    7.921n Â± 0%   -6.79% (p=0.000 n=10)
Mod                      15.16n Â± 4%    12.20n Â± 1%  -19.58% (p=0.000 n=10)
Frexp                    1.780n Â± 2%    1.496n Â± 0%  -15.96% (p=0.000 n=10)
Gamma                    4.378n Â± 1%    4.013n Â± 0%   -8.35% (p=0.000 n=10)
HypotGo                  2.655n Â± 5%    2.427n Â± 1%   -8.57% (p=0.000 n=10)
Ilogb                    1.912n Â± 5%    1.749n Â± 0%   -8.53% (p=0.000 n=10)
J0                       22.43n Â± 9%    20.46n Â± 0%   -8.76% (p=0.000 n=10)
J1                       21.03n Â± 4%    19.96n Â± 0%   -5.09% (p=0.000 n=10)
Jn                       45.40n Â± 1%    42.59n Â± 0%   -6.20% (p=0.000 n=10)
Ldexp                    2.312n Â± 1%    1.944n Â± 0%  -15.94% (p=0.000 n=10)
Lgamma                   4.617n Â± 1%    4.584n Â± 0%   -0.73% (p=0.000 n=10)
Log                      4.226n Â± 0%    4.213n Â± 0%   -0.31% (p=0.001 n=10)
Logb                     1.771n Â± 0%    1.775n Â± 0%        ~ (p=0.097 n=10)
Log1p                    5.102n Â± 2%    5.001n Â± 0%   -1.97% (p=0.000 n=10)
Log10                    4.407n Â± 0%    4.408n Â± 0%        ~ (p=1.000 n=10)
Log2                     2.416n Â± 1%    2.138n Â± 0%  -11.51% (p=0.000 n=10)
Modf                     1.669n Â± 2%    1.611n Â± 0%   -3.50% (p=0.000 n=10)
Nextafter32              2.186n Â± 0%    2.185n Â± 0%        ~ (p=0.051 n=10)
Nextafter64              2.182n Â± 0%    2.184n Â± 0%   +0.09% (p=0.016 n=10)
PowInt                   11.39n Â± 6%    10.68n Â± 2%   -6.24% (p=0.000 n=10)
PowFrac                  26.60n Â± 2%    26.12n Â± 0%   -1.80% (p=0.000 n=10)
Pow10Pos                0.5067n Â± 4%   0.5003n Â± 1%   -1.27% (p=0.001 n=10)
Pow10Neg                0.8552n Â± 0%   0.8552n Â± 0%        ~ (p=0.928 n=10)
Round                    1.181n Â± 0%    1.182n Â± 0%   +0.08% (p=0.001 n=10)
RoundToEven              1.709n Â± 0%    1.710n Â± 0%        ~ (p=0.053 n=10)
Remainder                12.54n Â± 5%    11.99n Â± 2%   -4.46% (p=0.000 n=10)
Sin                      3.933n Â± 5%    3.926n Â± 0%   -0.17% (p=0.000 n=10)
Sincos                   5.672n Â± 0%    5.522n Â± 0%   -2.65% (p=0.000 n=10)
Sinh                     5.447n Â± 1%    5.444n Â± 0%   -0.06% (p=0.029 n=10)
Tan                      4.061n Â± 0%    4.058n Â± 0%   -0.07% (p=0.005 n=10)
Tanh                     5.599n Â± 0%    5.595n Â± 0%   -0.06% (p=0.042 n=10)
Y0                       20.75n Â± 5%    19.73n Â± 1%   -4.92% (p=0.000 n=10)
Y1                       20.87n Â± 2%    19.78n Â± 1%   -5.20% (p=0.000 n=10)
Yn                       44.50n Â± 2%    42.04n Â± 2%   -5.53% (p=0.000 n=10)
geomean                  4.989n         4.791n        -3.96%

goos: linux
goarch: riscv64
pkg: math
cpu: Spacemit(R) X60
                    â”‚     sec/op     â”‚    sec/op     vs base                  â”‚
Acos                    159.9n Â±  0%   159.9n Â±  0%        ~ (p=0.269 n=10)
Acosh                   244.7n Â±  0%   235.0n Â±  0%   -3.98% (p=0.000 n=10)
Asin                    159.9n Â±  0%   159.9n Â±  0%        ~ (p=0.154 n=10)
Asinh                   270.8n Â±  0%   261.1n Â±  0%   -3.60% (p=0.000 n=10)
Atan                    119.1n Â±  0%   119.1n Â±  0%        ~ (p=0.347 n=10)
Atanh                   260.2n Â±  0%   261.8n Â±  4%        ~ (p=0.459 n=10)
Atan2                   186.8n Â±  0%   186.8n Â±  0%        ~ (p=0.487 n=10)
Cbrt                    203.5n Â±  0%   198.2n Â±  0%   -2.60% (p=0.000 n=10)
Ceil                    31.82n Â±  0%   31.81n Â±  0%        ~ (p=0.714 n=10)
Copysign                4.894n Â±  0%   4.893n Â±  0%        ~ (p=0.161 n=10)
Cos                     107.6n Â±  0%   103.6n Â±  0%   -3.76% (p=0.000 n=10)
Cosh                    259.0n Â±  0%   252.8n Â±  0%   -2.39% (p=0.000 n=10)
Erf                     133.7n Â±  0%   133.7n Â±  0%        ~ (p=0.720 n=10)
Erfc                    137.9n Â±  0%   137.8n Â±  0%   -0.04% (p=0.033 n=10)
Erfinv                  173.7n Â±  0%   168.8n Â±  0%   -2.82% (p=0.000 n=10)
Erfcinv                 173.7n Â±  0%   168.8n Â±  0%   -2.82% (p=0.000 n=10)
Exp                     215.3n Â±  0%   208.1n Â±  0%   -3.34% (p=0.000 n=10)
ExpGo                   226.7n Â±  0%   220.6n Â±  0%   -2.69% (p=0.000 n=10)
Expm1                   164.8n Â±  0%   159.0n Â±  0%   -3.52% (p=0.000 n=10)
Exp2                    185.0n Â±  0%   182.7n Â±  0%   -1.22% (p=0.000 n=10)
Exp2Go                  198.9n Â±  0%   196.5n Â±  0%   -1.21% (p=0.000 n=10)
Abs                     4.894n Â±  0%   4.893n Â±  0%        ~ (p=0.262 n=10)
Dim                     16.31n Â±  0%   16.31n Â±  0%        ~ (p=1.000 n=10)
Floor                   31.81n Â±  0%   31.81n Â±  0%        ~ (p=0.067 n=10)
Max                     26.11n Â±  0%   26.10n Â±  0%        ~ (p=0.080 n=10)
Min                     26.10n Â±  0%   26.10n Â±  0%        ~ (p=0.095 n=10)
Mod                     337.7n Â±  0%   291.9n Â±  0%  -13.56% (p=0.000 n=10)
Frexp                   50.57n Â±  0%   42.41n Â±  0%  -16.13% (p=0.000 n=10)
Gamma                   206.3n Â±  0%   198.1n Â±  0%   -4.00% (p=0.000 n=10)
Hypot                   94.62n Â±  0%   94.61n Â±  0%        ~ (p=0.437 n=10)
HypotGo                 109.3n Â±  0%   109.3n Â±  0%        ~ (p=1.000 n=10)
Ilogb                   44.05n Â±  0%   44.04n Â±  0%   -0.02% (p=0.025 n=10)
J0                      663.1n Â±  0%   663.9n Â±  0%   +0.13% (p=0.002 n=10)
J1                      663.9n Â±  0%   666.4n Â±  0%   +0.38% (p=0.000 n=10)
Jn                      1.404µ Â±  0%   1.407µ Â±  0%   +0.21% (p=0.000 n=10)
Ldexp                   57.10n Â±  0%   48.93n Â±  0%  -14.30% (p=0.000 n=10)
Lgamma                  185.1n Â±  0%   187.6n Â±  0%   +1.32% (p=0.000 n=10)
Log                     182.7n Â±  0%   170.1n Â±  0%   -6.87% (p=0.000 n=10)
Logb                    46.49n Â±  0%   46.49n Â±  0%        ~ (p=0.675 n=10)
Log1p                   184.3n Â±  0%   179.4n Â±  0%   -2.63% (p=0.000 n=10)
Log10                   184.3n Â±  0%   171.2n Â±  0%   -7.08% (p=0.000 n=10)
Log2                    66.05n Â±  0%   57.90n Â±  0%  -12.34% (p=0.000 n=10)
Modf                    34.25n Â±  0%   34.24n Â±  0%        ~ (p=0.163 n=10)
Nextafter32             49.33n Â±  1%   48.93n Â±  0%   -0.81% (p=0.002 n=10)
Nextafter64             43.64n Â±  0%   43.23n Â±  0%   -0.93% (p=0.000 n=10)
PowInt                  267.6n Â±  0%   251.2n Â±  0%   -6.11% (p=0.000 n=10)
PowFrac                 672.9n Â±  0%   637.9n Â±  0%   -5.19% (p=0.000 n=10)
Pow10Pos                13.87n Â±  0%   13.87n Â±  0%        ~ (p=1.000 n=10)
Pow10Neg                19.58n Â± 62%   19.59n Â± 62%        ~ (p=0.355 n=10)
Round                   23.65n Â±  0%   23.65n Â±  0%        ~ (p=1.000 n=10)
RoundToEven             27.73n Â±  0%   27.73n Â±  0%        ~ (p=0.635 n=10)
Remainder               309.9n Â±  0%   280.5n Â±  0%   -9.49% (p=0.000 n=10)
Signbit                 13.05n Â±  0%   13.05n Â±  0%        ~ (p=1.000 n=10) Â¹
Sin                     120.7n Â±  0%   120.7n Â±  0%        ~ (p=1.000 n=10) Â¹
Sincos                  148.4n Â±  0%   143.5n Â±  0%   -3.30% (p=0.000 n=10)
Sinh                    275.6n Â±  0%   267.5n Â±  0%   -2.94% (p=0.000 n=10)
SqrtIndirect            3.262n Â±  0%   3.262n Â±  0%        ~ (p=0.263 n=10)
SqrtLatency             19.57n Â±  0%   19.57n Â±  0%        ~ (p=0.582 n=10)
SqrtIndirectLatency     19.57n Â±  0%   19.57n Â±  0%        ~ (p=1.000 n=10)
SqrtGoLatency           203.2n Â±  0%   197.6n Â±  0%   -2.78% (p=0.000 n=10)
SqrtPrime               4.952µ Â±  0%   4.952µ Â±  0%   -0.01% (p=0.025 n=10)
Tan                     153.3n Â±  0%   153.3n Â±  0%        ~ (p=1.000 n=10)
Tanh                    280.5n Â±  0%   272.4n Â±  0%   -2.91% (p=0.000 n=10)
Trunc                   31.81n Â±  0%   31.81n Â±  0%        ~ (p=1.000 n=10)
Y0                      680.1n Â±  0%   664.8n Â±  0%   -2.25% (p=0.000 n=10)
Y1                      684.2n Â±  0%   669.6n Â±  0%   -2.14% (p=0.000 n=10)
Yn                      1.444µ Â±  0%   1.410µ Â±  0%   -2.35% (p=0.000 n=10)
Float64bits             5.709n Â±  0%   5.708n Â±  0%        ~ (p=0.573 n=10)
Float64frombits         4.893n Â±  0%   4.893n Â±  0%        ~ (p=0.734 n=10)
Float32bits             12.23n Â±  0%   12.23n Â±  0%        ~ (p=0.628 n=10)
Float32frombits         4.893n Â±  0%   4.893n Â±  0%        ~ (p=0.971 n=10)
FMA                     4.893n Â±  0%   4.893n Â±  0%        ~ (p=0.736 n=10)
geomean                 88.96n         87.05n         -2.15%
¹ all samples are equal

Change-Id: I8db8ac7b7b3430b946b89e88dd6c1546804125c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/697360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Munday <mikemndy@gmail.com>

3 months agocmd/go: refactor usage of `workFilePath`
Ian Alexander [Thu, 21 Aug 2025 01:21:41 +0000 (21:21 -0400)]
cmd/go: refactor usage of `workFilePath`

This commit refactors usage of the global variable `workFilePath` to
the global LoaderState field of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'ex { workFilePath -> LoaderState.workFilePath }'
rf 'add State.requirements \
// Set to the path to the go.work file, or "" if workspace mode is\
// disabled'
rf 'rm workFilePath'

Change-Id: I53cdbc3cc619914421513db74a74a04ab10b3e33
Reviewed-on: https://go-review.googlesource.com/c/go/+/698062
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/go, testing: add TB.ArtifactDir and -artifacts flag
Damien Neil [Fri, 15 Aug 2025 22:24:05 +0000 (15:24 -0700)]
cmd/go, testing: add TB.ArtifactDir and -artifacts flag

Add TB.ArtifactDir, which returns a directory for a test to store
output files in. Add a -artifacts testflag which enables persistent
storage of artifacts in the output directory (-outputdir, or the
current directory by default).

Fixes #71287

Change-Id: I5f6515a6cd6c103f88588f4c033d5ea11ffd0c3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/696399
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
3 months agocmd/go: refactor usage of `requirements`
Ian Alexander [Thu, 21 Aug 2025 00:14:59 +0000 (20:14 -0400)]
cmd/go: refactor usage of `requirements`

This commit refactors usage of the global variable `requirements` to
the global LoaderState field of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'ex { requirements -> LoaderState.requirements }'
rf 'add State.MainModules \
// requirements is the requirement graph for the main module.\
//\
// It is always non-nil if the main module'\\\''s go.mod file has been\
// loaded.\
//\
// This variable should only be read from the loadModFile\
// function, and should only be written in the loadModFile and\
// commitRequirements functions.  All other functions that need or\
// produce a *Requirements should accept and/or return an explicit\
// parameter.'
rf 'rm requirements'

Change-Id: I9d7d1d301a9e89f9214ce632fa5b656dd2940f39
Reviewed-on: https://go-review.googlesource.com/c/go/+/698061
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
3 months agoRevert "crypto/internal/fips140/subtle: add assembly implementation of xorBytes for...
Keith Randall [Tue, 7 Oct 2025 17:15:43 +0000 (10:15 -0700)]
Revert "crypto/internal/fips140/subtle: add assembly implementation of xorBytes for mips64x"

This reverts commit 49d6777d87a0abb3eda032da95eff024156835f7.

Reason for revert: doesn't handle unaligned accesses correctly

Fixes #74998

Change-Id: Ia272245a6a2a91b305d411207430bad660ee355b
Reviewed-on: https://go-review.googlesource.com/c/go/+/709757
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoRevert "crypto/internal/fips140/subtle: add assembly implementation of xorBytes for...
Keith Randall [Tue, 7 Oct 2025 17:12:43 +0000 (10:12 -0700)]
Revert "crypto/internal/fips140/subtle: add assembly implementation of xorBytes for mipsx"

This reverts commit 343e486bfdbf9ca614d3e197afd79ad7ed5fef3e.

Reason for revert: doesn't handle unaligned accesses correctly.

Update #74998

Change-Id: I1d6210eeca9336f2ce311e99944cb270565563aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/709795
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agocmd/go: refactor usage of `MainModules`
Ian Alexander [Wed, 20 Aug 2025 23:56:29 +0000 (19:56 -0400)]
cmd/go: refactor usage of `MainModules`

This commit refactors usage of the global variable `MainModules` to
the global LoaderState variable of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'mv State.mainModules State.MainModules'
rf 'ex { MainModules -> LoaderState.MainModules }'
for dir in load modcmd modget test tool workcmd ; do
  cd ../${dir}
  rf 'ex {
    import "cmd/go/internal/modload"
    modload.MainModules -> modload.LoaderState.MainModules
  }'
done
cd ../modload
rf 'rm MainModules'

Change-Id: I15644c84190717d62ae953747a288ec6495ef168
Reviewed-on: https://go-review.googlesource.com/c/go/+/698060
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoarchive/tar: set a limit on the size of GNU sparse file 1.0 regions
Damien Neil [Thu, 11 Sep 2025 20:32:10 +0000 (13:32 -0700)]
archive/tar: set a limit on the size of GNU sparse file 1.0 regions

Sparse files in tar archives contain only the non-zero components
of the file. There are several different encodings for sparse
files. When reading GNU tar pax 1.0 sparse files, archive/tar did
not set a limit on the size of the sparse region data. A malicious
archive containing a large number of sparse blocks could cause
archive/tar to read an unbounded amount of data from the archive
into memory.

Since a malicious input can be highly compressable, a small
compressed input could cause very large allocations.

Cap the size of the sparse block data to the same limit used
for PAX headers (1 MiB).

Thanks to Harshit Gupta (Mr HAX) (https://www.linkedin.com/in/iam-harshit-gupta/)
for reporting this issue.

Fixes CVE-2025-58183
Fixes #75677

Change-Id: I70b907b584a7b8676df8a149a1db728ae681a770
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2800
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709861
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agonet/mail: avoid quadratic behavior in mail address parsing
Damien Neil [Thu, 25 Sep 2025 21:41:53 +0000 (14:41 -0700)]
net/mail: avoid quadratic behavior in mail address parsing

RFC 5322 domain-literal parsing built the dtext value one character
at a time with string concatenation, resulting in excessive
resource consumption when parsing very large domain-literal values.

Replace with a subslice.

Benchmark not included in this CL because it's too narrow to be
of general ongoing use, but for:

    ParseAddress("alice@[" + strings.Repeat("a", 0x40000) + "]")

goos: darwin
goarch: arm64
pkg: net/mail
cpu: Apple M4 Pro
                â”‚  /tmp/bench.0  â”‚            /tmp/bench.1             â”‚
                â”‚     sec/op     â”‚   sec/op     vs base                â”‚
ParseAddress-14   1987.732m Â± 9%   1.524m Â± 5%  -99.92% (p=0.000 n=10)

                â”‚   /tmp/bench.0   â”‚             /tmp/bench.1              â”‚
                â”‚       B/op       â”‚     B/op      vs base                 â”‚
ParseAddress-14   33692.767Mi Â± 0%   1.282Mi Â± 0%  -100.00% (p=0.000 n=10)

                â”‚  /tmp/bench.0  â”‚            /tmp/bench.1            â”‚
                â”‚   allocs/op    â”‚ allocs/op   vs base                â”‚
ParseAddress-14   263711.00 Â± 0%   17.00 Â± 0%  -99.99% (p=0.000 n=10)

Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

Fixes CVE-2025-61725
Fixes #75680

Change-Id: Id971c2d5b59882bb476e22fceb7e01ec08234bb7
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2840
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709860
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 months agonet/textproto: avoid quadratic complexity in Reader.ReadResponse
Damien Neil [Tue, 30 Sep 2025 22:11:16 +0000 (15:11 -0700)]
net/textproto: avoid quadratic complexity in Reader.ReadResponse

Reader.ReadResponse constructed a response string from repeated
string concatenation, permitting a malicious sender to cause excessive
memory allocation and CPU consumption by sending a response consisting
of many short lines.

Use a strings.Builder to construct the string instead.

Thanks to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-61724
Fixes #75716

Change-Id: I1a98ce85a21b830cb25799f9ac9333a67400d736
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2940
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709859
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agoencoding/pem: make Decode complexity linear
Roland Shoemaker [Tue, 30 Sep 2025 18:16:56 +0000 (11:16 -0700)]
encoding/pem: make Decode complexity linear

Because Decode scanned the input first for the first BEGIN line, and
then the first END line, the complexity of Decode is quadratic. If the
input contained a large number of BEGINs and then a single END right at
the end of the input, we would find the first BEGIN, and then scan the
entire input for the END, and fail to parse the block, so move onto the
next BEGIN, scan the entire input for the END, etc.

Instead, look for the first END in the input, and then the first BEGIN
that precedes the found END. We then process the bytes between the BEGIN
and END, and move onto the bytes after the END for further processing.
This gives us linear complexity.

Fixes CVE-2025-61723
Fixes #75676

Change-Id: I813c4f63e78bca4054226c53e13865c781564ccf
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2921
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709858
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agonet/url: enforce stricter parsing of bracketed IPv6 hostnames
Ethan Lee [Fri, 29 Aug 2025 17:35:55 +0000 (17:35 +0000)]
net/url: enforce stricter parsing of bracketed IPv6 hostnames

- Previously, url.Parse did not enforce validation of hostnames within
  square brackets.
- RFC 3986 stipulates that only IPv6 hostnames can be embedded within
  square brackets in a URL.
- Now, the parsing logic should strictly enforce that only IPv6
  hostnames can be resolved when in square brackets. IPv4, IPv4-mapped
  addresses and other input will be rejected.
- Update url_test to add test cases that cover the above scenarios.

Thanks to Enze Wang, Jingcheng Yang and Zehui Miao of Tsinghua
University for reporting this issue.

Fixes CVE-2025-47912
Fixes #75678

Change-Id: Iaa41432bf0ee86de95a39a03adae5729e4deb46c
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2680
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709857
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 months agoruntime: make work.spanSPMCs.all doubly-linked
Michael Pratt [Mon, 6 Oct 2025 21:55:06 +0000 (17:55 -0400)]
runtime: make work.spanSPMCs.all doubly-linked

Making this a doubly-linked list allows spanQueue.destroy to immediately
remove and free rings rather than simply marking them as dead and
waiting for the sweeper to deal with them.

For #75771.

Change-Id: I6a6a636c0fb6be08ee967cb6d8f0577511a33c13
Reviewed-on: https://go-review.googlesource.com/c/go/+/709657
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agoruntime: free spanQueue on P destroy
Michael Pratt [Mon, 6 Oct 2025 21:28:37 +0000 (17:28 -0400)]
runtime: free spanQueue on P destroy

Span queues must be empty when destroying a P since we are outside of
the mark phase. But we don't actually free them, so they simply sit
around using memory. More importantly, they are still in
work.spanSPMCs.all, so freeDeadSpanSPMCs must continue traversing past
them until the end of time.

Prior to CL 709575, keeping them in work.spanSPMCs.all allowed programs
with low GOMAXPROCS to continue triggering the bug if they ever had high
GOMAXPROCS in the past.

The spanSPMCs list is singly-linked, so it is not efficient to remove a
random element from the middle. Instead, we simply mark it as dead to
all freeDeadSpanSPMCs to free it when it scans the full list.

For #75771.

Change-Id: I6a6a636cfa22a4bdef0c273d083c91553e923fe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/709656
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agoencoding/asn1: prevent memory exhaustion when parsing using internal/saferio
Nicholas Husin [Wed, 3 Sep 2025 13:30:56 +0000 (09:30 -0400)]
encoding/asn1: prevent memory exhaustion when parsing using internal/saferio

Within parseSequenceOf, reflect.MakeSlice is being used to pre-allocate
a slice that is needed in order to fully validate the given DER payload.
The size of the slice allocated are also multiple times larger than the
input DER:

- When using asn1.Unmarshal directly, the allocated slice is ~28x
  larger.
- When passing in DER using x509.ParseCertificateRequest, the allocated
  slice is ~48x larger.
- When passing in DER using ocsp.ParseResponse, the allocated slice is
  ~137x larger.

As a result, a malicious actor can craft a big empty DER payload,
resulting in an unnecessary large allocation of memories. This can be a
way to cause memory exhaustion.

To prevent this, we now use SliceCapWithSize within internal/saferio to
enforce a memory allocation cap.

Thanks to Jakub Ciolek for reporting this issue.

For #75671
Fixes CVE-2025-58185

Change-Id: Id50e76187eda43f594be75e516b9ca1d2ae6f428
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2700
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709856
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 months agonet/http: add httpcookiemaxnum GODEBUG option to limit number of cookies parsed
Nicholas Husin [Tue, 30 Sep 2025 18:02:38 +0000 (14:02 -0400)]
net/http: add httpcookiemaxnum GODEBUG option to limit number of cookies parsed

When handling HTTP headers, net/http does not currently limit the number
of cookies that can be parsed. The only limitation that exists is for
the size of the entire HTTP header, which is controlled by
MaxHeaderBytes (defaults to 1 MB).

Unfortunately, this allows a malicious actor to send HTTP headers which
contain a massive amount of small cookies, such that as much cookies as
possible can be fitted within the MaxHeaderBytes limitation. Internally,
this causes us to allocate a massive number of Cookie struct.

For example, a 1 MB HTTP header with cookies that repeats "a=;" will
cause an allocation of ~66 MB in the heap. This can serve as a way for
malicious actors to induce memory exhaustion.

To fix this, we will now limit the number of cookies we are willing to
parse to 3000 by default. This behavior can be changed by setting a new
GODEBUG option: GODEBUG=httpcookiemaxnum. httpcookiemaxnum can be set to
allow a higher or lower cookie limit. Setting it to 0 will also allow an
infinite number of cookies to be parsed.

Thanks to jub0bs for reporting this issue.

For #75672
Fixes CVE-2025-58186

Change-Id: Ied58b3bc8acf5d11c880f881f36ecbf1d5d52622
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2720
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709855
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 months agocrypto/x509: improve domain name verification
Neal Patel [Mon, 15 Sep 2025 20:31:22 +0000 (16:31 -0400)]
crypto/x509: improve domain name verification

Don't use domainToReverseLabels to check if domain names are valid,
since it is not particularly performant, and can contribute to DoS
vectors. Instead just iterate over the name and enforce the properties
we care about.

This also enforces that DNS names, both in SANs and name constraints,
are valid. We previously allowed invalid SANs, because some
intermediates had these weird names (see #23995), but there are
currently no trusted intermediates that have this property, and since we
target the web PKI, supporting this particular case is not a high
priority.

Thank you to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-58187
Fixes #75681

Change-Id: I6ebce847dcbe5fc63ef2f9a74f53f11c4c56d3d1
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2820
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709854
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocrypto/x509: mitigate DoS vector when intermediate certificate contains DSA public key
Neal Patel [Thu, 11 Sep 2025 20:27:04 +0000 (16:27 -0400)]
crypto/x509: mitigate DoS vector when intermediate certificate contains DSA public key

An attacker could craft an intermediate X.509 certificate
containing a DSA public key and can crash a remote host
with an unauthenticated call to any endpoint that
verifies the certificate chain.

Thank you to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-58188
Fixes #75675

Change-Id: I2ecbb87b9b8268dbc55c8795891e596ab60f0088
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2780
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709853
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/go: refactor usage of `modRoots`
Ian Alexander [Wed, 20 Aug 2025 23:44:11 +0000 (19:44 -0400)]
cmd/go: refactor usage of `modRoots`

This commit refactors usage of the global variable `modRoots` to the
global LoaderState field of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'ex { modRoots -> LoaderState.modRoots }'
rf 'add State.RootMode \
// These are primarily used to initialize the MainModules, and should\
// be eventually superseded by them but are still used in cases where\
// the module roots are required but MainModules has not been\
// initialized yet. Set to the modRoots of the main modules.\
// modRoots != nil implies len(modRoots) > 0'
rf 'rm modRoots'

Change-Id: Ie9e1f3d468cfceee25efefaf945b10492318b079
Reviewed-on: https://go-review.googlesource.com/c/go/+/698059
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoruntime: fix self-deadlock on sbrk platforms
Michael Anthony Knyszek [Tue, 7 Oct 2025 16:10:19 +0000 (16:10 +0000)]
runtime: fix self-deadlock on sbrk platforms

The sbrk mem.go implementation doesn't enforce being called on the
systemstack, but it can call back into itself if there's a stack growth.
Because the sbrk implementation requires acquiring memlock, it can
self-deadlock.

For the most part the mem.go API is called on the system stack, but
there are cases where we call sysAlloc on the regular Go stack. This is
fine in general, except on sbrk platforms because of the aforementioned
deadlock.

This change, rather than adding a new invariant to mem.go, switches to
the systemstack in the mem.go API implementation for sbrk platforms.

Change-Id: Ie0f0ea80a8d7578cdeabc8252107e64a5e633856
Reviewed-on: https://go-review.googlesource.com/c/go/+/709775
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/go: refactor usage of `RootMode`
Ian Alexander [Wed, 20 Aug 2025 23:34:40 +0000 (19:34 -0400)]
cmd/go: refactor usage of `RootMode`

This commit refactors usage of the global variable `RootMode` to the
global LoaderState variable of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'mv State.rootMode State.RootMode'
for dir in load modcmd run tool toolchain work ; do
  cd ../${dir}
  rf 'ex {
    import "cmd/go/internal/modload";
    modload.RootMode -> modload.LoaderState.RootMode
  }'
done
cd ../modload
rf 'ex { RootMode -> LoaderState.RootMode }'
rf 'add State.ForceUseModules \
// RootMode determines whether a module root is needed.'
rf 'rm RootMode'

Change-Id: Ib5e513ee570dfc3b01cc974fe32944e5e391fd82
Reviewed-on: https://go-review.googlesource.com/c/go/+/698058
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
3 months agocmd/go: refactor usage of `ForceUseModules`
Ian Alexander [Wed, 20 Aug 2025 23:21:56 +0000 (19:21 -0400)]
cmd/go: refactor usage of `ForceUseModules`

This commit refactors usage of the global variable `ForceUseModules`
to the global LoaderState field of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'mv State.forceUseModules State.ForceUseModules'
rf 'ex { ForceUseModules -> LoaderState.ForceUseModules }'
for dir in load modcmd modget run toolchain work workcmd ; do
  cd ../${dir}
  rf 'ex {
    import "cmd/go/internal/modload";
    modload.ForceUseModules -> modload.LoaderState.ForceUseModules
  }'
done
cd ../modload
rf 'add State.initialized \
// ForceUseModules may be set to force modules to be enabled when\
// GO111MODULE=auto or to report an error when GO111MODULE=off.'
rf 'rm ForceUseModules'

Change-Id: Ibdecfd273ff672516c9eb86279e5dfc6cdecb2ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/698057
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoRevert "cmd/compile: redo arm64 LR/FP save and restore"
Keith Randall [Tue, 7 Oct 2025 14:58:50 +0000 (07:58 -0700)]
Revert "cmd/compile: redo arm64 LR/FP save and restore"

This reverts commit 719dfcf8a8478d70360bf3c34c0e920be7b32994.

Reason for revert: Causing crashes.

Change-Id: I0b8526dd03d82fa074ce4f97f1789eeac702b3eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/709755
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agoruntime: assert p.destroy runs with GC not running
Michael Pratt [Mon, 6 Oct 2025 20:38:29 +0000 (16:38 -0400)]
runtime: assert p.destroy runs with GC not running

This is already guaranteed by stopTheWorldGC prior to procresize. Thus
the cleanup code here is dead, which is a bit confusing.

Replace it with a throw for clarity.

Change-Id: I6a6a636c8ca1487b720c4fab41b2b86c13d1d9e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/709655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agointernal/goexperiment: remove the synctest GOEXPERIMENT
Mateusz Poliwczak [Mon, 6 Oct 2025 18:54:27 +0000 (20:54 +0200)]
internal/goexperiment: remove the synctest GOEXPERIMENT

synctest package is enabled by default and the synctest
goexperiment does nothing after CL 709355.

Change-Id: Ia96b070d5f3779ae7c38a9044f754e716a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/709555
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agofmt: reduce Errorf("x") allocations to match errors.New("x")
thepudds [Fri, 3 Oct 2025 14:59:54 +0000 (10:59 -0400)]
fmt: reduce Errorf("x") allocations to match errors.New("x")

For unformatted strings, it comes up periodically that there are
more allocations using fmt.Errorf("x") compared to errors.New("x").
People cite it as a reason to switch code using fmt.Errorf to
use errors.New instead.

Three examples from the last few weeks essentially made
this suggestion: #75235, CL 708496, and CL 708618. Prior to that,
it is periodically suggested as a vet check (e.g., proposals #17173
and #52696) or in various CLs to change the standard library
(e.g., CL 403938 and CL 588776).

On the other hand, I believe the position of the core Go team
is that it is usually not worthwhile to make such a change. For example,
in #52696, Russ wrote:

  Thanks for raising the issue, but please don't do this. Using
  fmt.Errorf("foo") is completely fine, especially in a program where
  all the errors are constructed with fmt.Errorf. Having to
  mentally switch between two functions based on the argument
  is unnecessary noise.

This CL attempts to mostly take performance out of the discussion.

We drop from 2 allocations to 0 allocations for a non-escaping error,
and drop from 2 allocations to 1 allocation for an escaping error:

  _ = fmt.Errorf("foo")    // non-escaping error
  sink = fmt.Errorf("foo") // escaping error

This now matches the allocations for errors.New("foo") in both cases.

The CPU cost difference is greatly reduced, though there is still
a small ~4ns difference measurable in these microbenchmarks. Previously,
it was ~64ns vs. ~21ns for fmt.Errorf("x") vs. errors.New("x")
for escaping errors, whereas with this CL it is now ~25ns vs. ~21ns.

When fmt.Errorf("foo") executes with this CL, there are essentially
three optimizations now, in rough order of usefulness:
 (1) we always avoid an allocation inside the doPrintf machinery;
 (2) if the error does not otherwise escape, we can stack allocate
     the errors.errorString struct by virtue of mid-stack inlining
     of fmt.Errorf and the resulting inlining of errors.New, which
     also can be more effective via PGO;
 (3) stringslite.IndexByte is a tiny bit faster than going through the
     for loops looking for '%' inside doPrintf.

See https://blog.filippo.io/efficient-go-apis-with-the-inliner/ for
background on avoiding heap allocations via mid-stack inlining.

The common case here is likely that the string format argument is a
constant when there are no other arguments.

However, one concern could be that by not allocating a copy, we could
now keep a string argument alive longer with this change, which could
be a pessimization if for example that string argument is a
slice of a much bigger string:

  s := bigString[m:n]
  longLivedErr := fmt.Errorf(s)

Aside from that being perhaps unusual code, vet will complain about
s there as a "non-constant format string in call to fmt.Errorf", so that
particular example seems unlikely to occur frequently in practice.

The main benchmark results are below. "old" is prior to this CL, "new"
is with this CL. The non-escaping case is "local", the escaping case is
"sink". In practice, I suspect errors escape the majority of the time.
Benchmark code at https://go.dev/play/p/rlRSO1ehx8O

goos: linux
goarch: amd64
pkg: fmt
cpu: AMD EPYC 7B13
                         â”‚  old-7bd6fac4.txt      â”‚           new-dcd2a72f0.txt    â”‚
                         â”‚      sec/op            â”‚   sec/op     vs base           â”‚
Errorf/no-args/local-16              63.76n Â± 1%   4.874n Â± 0%  -92.36% (n=120)
Errorf/no-args/sink-16               64.25n Â± 1%   25.81n Â± 0%  -59.83% (n=120)
Errorf/int-arg/local-16              90.86n Â± 1%   90.97n Â± 1%        ~ (p=0.713 n=120)
Errorf/int-arg/sink-16               91.81n Â± 1%   91.10n Â± 1%   -0.76% (p=0.036 n=120)
geomean                              76.46n        31.95n       -58.20%

                         â”‚  old-7bd6fac4.txt      â”‚             new-dcd2a72f0.txt  â”‚
                         â”‚       B/op             â”‚    B/op     vs base            â”‚
Errorf/no-args/local-16               19.00 Â± 0%    0.00 Â± 0%  -100.00% (n=120)
Errorf/no-args/sink-16                19.00 Â± 0%   16.00 Â± 0%   -15.79% (n=120)
Errorf/int-arg/local-16               24.00 Â± 0%   24.00 Â± 0%         ~ (p=1.000 n=120) Â¹
Errorf/int-arg/sink-16                24.00 Â± 0%   24.00 Â± 0%         ~ (p=1.000 n=120) Â¹
geomean                               21.35                    ?                        Â² Â³
¹ all samples are equal

                         â”‚  old-7bd6fac4.txt      â”‚       new-dcd2a72f0.txt        â”‚
                         â”‚     allocs/op          â”‚ allocs/op   vs base            â”‚
Errorf/no-args/local-16               2.000 Â± 0%   0.000 Â± 0%  -100.00% (n=120)
Errorf/no-args/sink-16                2.000 Â± 0%   1.000 Â± 0%   -50.00% (n=120)
Errorf/int-arg/local-16               2.000 Â± 0%   2.000 Â± 0%         ~ (p=1.000 n=120) Â¹
Errorf/int-arg/sink-16                2.000 Â± 0%   2.000 Â± 0%         ~ (p=1.000 n=120) Â¹
geomean                               2.000                    ?                        Â² Â³
¹ all samples are equal

Change-Id: Ib27c52933bec5c2236624c577fbb1741052e792f
Reviewed-on: https://go-review.googlesource.com/c/go/+/708836
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 months agointernal/buildcfg: enable greenteagc experiment by default
Michael Anthony Knyszek [Sun, 9 Mar 2025 17:19:48 +0000 (17:19 +0000)]
internal/buildcfg: enable greenteagc experiment by default

Slightly bump the value in Test/wasmmemsize.go. We use 1 additional page
compared to before, and we were already sitting *right* on the edge.

For #73581.

Change-Id: I485df16c3cf59803a8a1fc852b3e90666981ab09
Reviewed-on: https://go-review.googlesource.com/c/go/+/656195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 months agocmd/go: refactor usage of `initialized`
Ian Alexander [Wed, 20 Aug 2025 23:16:36 +0000 (19:16 -0400)]
cmd/go: refactor usage of `initialized`

This commit refactors usage of the global variable `initialized` to
the global LoaderState field of the same name.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'ex { initialized -> LoaderState.initialized }'
rf 'rm initialized'

Change-Id: I97e35bab00f4c22661670b01b69425fc25efe6df
Reviewed-on: https://go-review.googlesource.com/c/go/+/698056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
3 months agotest/codegen: make sure assignment results are used.
Cherry Mui [Sat, 4 Oct 2025 15:32:33 +0000 (11:32 -0400)]
test/codegen: make sure assignment results are used.

Some tests make assignments to an argument without reading it.
With CL 708865, they are treated as dead stores and are removed.
Make sure the results are used.

Fixes #75745.
Fixes #75746.

Change-Id: I05580beb1006505ec1550e5fa245b54dcefd10b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/708916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 months agoruntime: delete redundant code in the page allocator
tony [Mon, 29 Sep 2025 14:25:57 +0000 (14:25 +0000)]
runtime: delete redundant code in the page allocator

The page allocator's scavenge index has sysGrow called on it twice,
once in pageAlloc.grow, and once in pageAlloc.sysGrow on 64-bit
platforms. Calling it twice is OK since sysGrow is idempotent,
but it's also wasteful. This change removes the call
in pageAlloc.sysGrow.

Change-Id: I5b955b6e2beed5c2b8305ab82b76718ea305792c
Reviewed-on: https://go-review.googlesource.com/c/go/+/707735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agocmd/compile: redo arm64 LR/FP save and restore
Keith Randall [Sat, 17 May 2025 22:05:56 +0000 (15:05 -0700)]
cmd/compile: redo arm64 LR/FP save and restore

Instead of storing LR (the return address) at 0(SP) and the FP
(parent's frame pointer) at -8(SP), store them at framesize-8(SP)
and framesize-16(SP), respectively.

We push and pop data onto the stack such that we're never accessing
anything below SP.

The prolog/epilog lengths are unchanged (3 insns for a typical prolog,
2 for a typical epilog).

We use 8 bytes more per frame.

Typical prologue:

    STP.W   (FP, LR), -16(SP)
    MOVD    SP, FP
    SUB     $C, SP

Typical epilogue:

    ADD     $C, SP
    LDP.P   16(SP), (FP, LR)
    RET

The previous word where we stored LR, at 0(SP), is now unused.
We could repurpose that slot for storing a local variable.

The new prolog and epilog instructions are recognized by libunwind,
so pc-sampling tools like perf should now be accurate. (TODO: except
maybe after the first RET instruction? Have to look into that.)

Update #73753 (fixes, for arm64)
Update #57302 (Quim thinks this will help on that issue)

Change-Id: I4800036a9a9a08aaaf35d9f99de79a36cf37ebb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/674615
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
3 months agoruntime: remove batching from spanSPMC free
Michael Pratt [Mon, 6 Oct 2025 18:38:47 +0000 (14:38 -0400)]
runtime: remove batching from spanSPMC free

Added in CL 700496, freeSomeSpanSPMCs attempts to bound tail latency by
processing at most 64 entries at a time, as well as returning early if
it notices a preemption request. Both of those are attempts to reduce
tail latency, as we cannot preempt the function while it holds the lock.
This scheme is based on a similar scheme in freeSomeWbufs.

freeSomeWbufs has a key difference: all workbufs in its list are
unconditionally freed. So freeSomeWbufs will always make forward
progress in each call (unless it is constantly preempted).

In contrast, freeSomeSpanSPMCs only frees "dead" entries. If the list
contains >64 live entries, a call may make no progress, and the caller
will simply keep calling in a loop forever, until the GC ends at which
point it returns success early. The infinite loop likely restarts at the
next GC cycle.

The queues are used on each P, so it is easy to have 64 permanently live
queues if GOMAXPROCS >= 64. If GOMAXPROCS < 64, it is possible to
transiently have more queues, but spanQueue.drain increases queue size
in an attempt to reach a steady state of one queue per P.

We must drop work.spanSPMCs.lock to allow preemption, but dropping the
lock allows mutation of the linked list, meaning we cannot simply
continue iteration after retaking lock. Since there is no
straightforward resolution to this and we expect this to generally only
be around 1 entry per P, simply remove the batching and process the
entire list without preemption. We may want to revisit this in the
future for very high GOMAXPROCS or if application regularly otherwise
create very long lists.

Fixes #75771.

Change-Id: I6a6a636cd3be443aacde5a678c460aa7066b4c4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/709575
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/go: export type State
Ian Alexander [Wed, 20 Aug 2025 23:12:20 +0000 (19:12 -0400)]
cmd/go: export type State

Export the type `State` and add global variable `LoaderState` in
preparation for refactoring usage of other global variables in the
modload package.

This commit is part of the overall effort to eliminate global
modloader state.

[git-generate]
cd src/cmd/go/internal/modload
rf 'mv state State'
rf 'add State func NewState() *State { return &State{} }'
rf 'add init.go:/NewState/+0 var LoaderState = NewState()'

Change-Id: I0ec6199ba3e05927bec12f11a60383d1b51b111a
Reviewed-on: https://go-review.googlesource.com/c/go/+/698055
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agotesting/synctest: remove Run
Sean Liao [Sun, 5 Oct 2025 22:17:40 +0000 (23:17 +0100)]
testing/synctest: remove Run

Run (experimental) is replaced by Test.

Fixes #74012

Change-Id: I1721e1edfbcb4f1fe2159dc0430a13685b2d08c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/709355
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
3 months agoruntime: bump thread count slack for TestReadMetricsSched
Michael Anthony Knyszek [Fri, 3 Oct 2025 16:23:10 +0000 (16:23 +0000)]
runtime: bump thread count slack for TestReadMetricsSched

This test is *still* flaky, but it appears to be just
mayMoreStackPreempt and the thread count *occasionally* exceeds the
original (and arbitrary) thread count slack by exactly 1.

Bump the thread count slack by one. We can investigate further and bump
it again if it continues to be a problem.

Fixes #75664.

Change-Id: I29c922bba6d2cc99a8c3bf5e04cc512d0694f7fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/708868
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocrypto/tls: streamline BoGo testing w/ -bogo-local-dir
Daniel McCarney [Fri, 11 Jul 2025 14:42:22 +0000 (10:42 -0400)]
crypto/tls: streamline BoGo testing w/ -bogo-local-dir

If -bogo-local-dir is provided but doesn't exist, populate it with a git
checkout of the BoringSSL repo at the correct SHA.

Without any -bogo-local-dir argument the BoGo TLS handshake test will
fetch the BoringSSL source at a specific SHA as a Go module in a r/o
module directory. When debugging, or extending BoGo coverage, it's
preferable to have a mutable local copy of BoGo that the test will
use.

The pre-existing -bogo-local-dir flag offered a way to use a checkout of
BoGo but it relied on the user fetching the correct repo & revision
manually ahead of time. This commit extends the test to automatically
invoke `git` to clone the repo into the provided local dir at the
correct SHA based on the boringsslModVer const if the local dir doesn't
exist.

This leaves the user ready to make changes in local BoGo dir to aid
debugging, or to upstream as CRs to BoringSSL, and prevents using an
incorrect SHA by mistake.

Updates #72006

Change-Id: I0451a3d35203878cdf02a7587e138c3cd60d15a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/687475
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Daniel McCarney <daniel@binaryparadox.net>

3 months agospec: close tag
Oliver Eikemeier [Sun, 5 Oct 2025 11:57:40 +0000 (11:57 +0000)]
spec: close tag

Close an "a" tag. While we are here, fix some escapes.

Change-Id: I16040eff0d4beeef6230aec8fcf4315f0efd13a4
GitHub-Last-Rev: 3ba7b9f7478f54338bd3ca7ac55cc2ad1ffcb3a4
GitHub-Pull-Request: golang/go#75760
Reviewed-on: https://go-review.googlesource.com/c/go/+/708517
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>

3 months agonet/url: improve URL docs
Mateusz Poliwczak [Wed, 24 Sep 2025 14:40:55 +0000 (16:40 +0200)]
net/url: improve URL docs

The Raw fields are confusing and easy to use by mistake. Adds more
context in comments to these fields.

Also the current docs (and the names of these fields) of these
boolean fields are not obvious that parser might produce them,
so clarify that

Change-Id: I6a6a69644834c3ccbf657147f771930b6875f721
Reviewed-on: https://go-review.googlesource.com/c/go/+/706515
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/link: add LIBRARY statement only with -buildmode=cshared
qmuntal [Fri, 3 Oct 2025 09:18:47 +0000 (11:18 +0200)]
cmd/link: add LIBRARY statement only with -buildmode=cshared

When creating a .def file for Windows linking, add a LIBRARY statement
only when building a DLL with -buildmode=cshared. That statement is
documented to instruct the linker to create a DLL, overriding any
other flag that might indicate building an executable.

Fixes #75734

Change-Id: I0231435df70b71a493a39deb639f6328a8e354f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/708815
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dominic Della Valle <ddvpublic@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: improve slicemask removal
David Chase [Wed, 17 Sep 2025 21:21:37 +0000 (17:21 -0400)]
cmd/compile: improve slicemask removal

this will be subsumed by pending changes in local slice
representation, however this was easy and works well.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I5b6eb10d257f04f906be7a8a6f2b6833992a39e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/704876
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708866
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: remove stores to unread parameters
Cherry Mui [Mon, 22 Sep 2025 14:57:29 +0000 (10:57 -0400)]
cmd/compile: remove stores to unread parameters

Currently, we remove stores to local variables that are not read.
We don't do that for arguments. But arguments and locals are
essentially the same. Arguments are passed by value, and are not
expected to be read in the caller's frame. So we can remove the
writes to them as well. One exception is the cgo_unsafe_arg
directive, which makes all the arguments effectively address-taken.
cgo_unsafe_arg implies ABI0, so we just skip ABI0 functions'
arguments.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I8999fc50da6a87f22c1ec23e9a0c15483b6f7df8
Reviewed-on: https://go-review.googlesource.com/c/go/+/705815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708865

3 months agocmd/compile: fix SIMD const rematerialization condition
Junyang Shao [Fri, 19 Sep 2025 18:38:25 +0000 (18:38 +0000)]
cmd/compile: fix SIMD const rematerialization condition

This CL fixes a condition for the previous fix CL 704056.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk. Test is
SIMD specific so not included for now.

Change-Id: I1f1f8c6f72870403cb3dff14755c43385dc0c933
Reviewed-on: https://go-review.googlesource.com/c/go/+/705499
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708864
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: enhance prove to infer bounds in slice len/cap calculations
David Chase [Wed, 17 Sep 2025 21:19:15 +0000 (17:19 -0400)]
cmd/compile: enhance prove to infer bounds in slice len/cap calculations

the example comes up in chunked reslicing, e.g. A[i:] where i
has a relationship with len(A)-K.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: Ib97dede6cfc7bbbd27b4f384988f741760686604
Reviewed-on: https://go-review.googlesource.com/c/go/+/704875
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708863
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: enhance the chunked indexing case to include reslicing
David Chase [Wed, 17 Sep 2025 18:25:16 +0000 (14:25 -0400)]
cmd/compile: enhance the chunked indexing case to include reslicing

this helps SIMD, but also helps plain old Go

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: Idcdacd54b6776f5c32b497bc94485052611cfa8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/704756
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708862
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: handle rematerialized op for incompatible reg constraint
Junyang Shao [Tue, 16 Sep 2025 03:27:41 +0000 (03:27 +0000)]
cmd/compile: handle rematerialized op for incompatible reg constraint

This CL fixes an issue raised by contributor dominikh@.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk. Test is
SIMD specific so not included for now.

Change-Id: I941b330a6ba6f6c120c69951ddd24933f2f0b3ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/704056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708861

3 months agocmd/compile: use the right type for spill slot
Cherry Mui [Tue, 16 Sep 2025 01:27:19 +0000 (21:27 -0400)]
cmd/compile: use the right type for spill slot

Currently, when shuffling registers, if we need to spill a
register, we always create a spill slot of type int64. The type
doesn't actually matter, as long as it is wide enough to hold the
registers. This is no longer true with SIMD registers, which could
be wider than a int64. Create the slot with the proper type
instead.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk. Test is
SIMD specific so not included for now.

Change-Id: I85c82e2532001bfdefe98c9446f2dd18583d49b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/704055
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708860
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: enhance prove to deal with double-offset IsInBounds checks
David Chase [Wed, 3 Sep 2025 17:09:32 +0000 (13:09 -0400)]
cmd/compile: enhance prove to deal with double-offset IsInBounds checks

For chunked iterations (useful for, but not exclusive to,
SIMD calculations) it is common to see the combination of
```
for ; i <= len(m)-4; i += 4 {
```
and
```
r0, r1, r2, r3 := m[i], m[i+1], m[i+2], m[i+3]
``

Prove did not handle the case of len-offset1 vs index+offset2
checking, but this change fixes this.  There may be other
similar cases yet to handle -- this worked for the chunked
loops for simd, as well as a handful in std.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I3785df83028d517e5e5763206653b34b2befd3d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/700696
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708859
Reviewed-by: David Chase <drchase@google.com>
3 months agocmd/compile: rewrite to elide Slicemask from len==c>0 slicing
David Chase [Wed, 20 Aug 2025 16:29:02 +0000 (12:29 -0400)]
cmd/compile: rewrite to elide Slicemask from len==c>0 slicing

This might have been something that prove could be educated
into figuring out, but this also works, and it also helps
prove downstream.

Adjusted the prove test, because this change moved a message.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I5eabe639eff5db9cd9766a6a8666fdb4973829cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/697715
Commit-Queue: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708858
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agocmd/compile: accounts rematerialize ops's output reginfo
Junyang Shao [Tue, 12 Aug 2025 16:53:44 +0000 (16:53 +0000)]
cmd/compile: accounts rematerialize ops's output reginfo

This CL implements the check for rematerializeable value's output
regspec at its remateralization site. It has some potential problems,
please see the TODO in regalloc.go.

Fixes #70451.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: Ib624b967031776851136554719e939e9bf116b7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/695315
Reviewed-by: David Chase <drchase@google.com>
TryBot-Bypass: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708857
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agocmd/compile: minor tweak for race detector
David Chase [Wed, 2 Jul 2025 22:00:12 +0000 (18:00 -0400)]
cmd/compile: minor tweak for race detector

This makes the front-end a little bit less temp-happy
when instrumenting, which repairs the "is it a constant?"
test in the simd intrinsic conversion which is otherwise
broken by race detection.

Also, this will perhaps be better code.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I84b7a45b7bff62bb2c9f9662466b50858d288645
Reviewed-on: https://go-review.googlesource.com/c/go/+/685637
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708856

3 months agocmd/compile: don't treat devel compiler as a released compiler
Cherry Mui [Fri, 20 Jun 2025 16:02:18 +0000 (12:02 -0400)]
cmd/compile: don't treat devel compiler as a released compiler

The compiler has a logic to print different messages on internal
compiler error depending on whether this is a released version of
Go. It hides the panic stack trace if it is a released version. It
does this by checking the version and see if it has a "go" prefix.
This includes all the released versions. However, for a non-
released build, if there is no explicit version set, cmd/dist now
sets the toolchain version as go1.X-devel_XXX, which makes it be
treated as a released compiler, and causes the stack trace to be
hidden. Change the logic to not match a devel compiler as a
released compiler.

Cherry-picked from the dev.simd branch. This CL is not
necessarily SIMD specific. Apply early to reduce risk.

Change-Id: I5d3b2101527212f825b6e4000b36030c4f83870b
Reviewed-on: https://go-review.googlesource.com/c/go/+/682975
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/708855
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agoruntime: support valgrind (but not asan) in specialized malloc functions
matloob [Wed, 1 Oct 2025 16:06:14 +0000 (12:06 -0400)]
runtime: support valgrind (but not asan) in specialized malloc functions

We're adding this so that the compiler doesn't need to know about
valgrind since it's just implemented using a build tag.

Change-Id: I6a6a696452b0379caceca2ae4e49195016f7a90d
Reviewed-on: https://go-review.googlesource.com/c/go/+/708296
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agointernal/buildcfg: enable specializedmalloc experiment
Michael Matloob [Mon, 17 Mar 2025 15:45:52 +0000 (11:45 -0400)]
internal/buildcfg: enable specializedmalloc experiment

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64_c2s16-perf_vs_parent,gotip-linux-amd64_c3h88-perf_vs_parent,gotip-linux-arm64_c4ah72-perf_vs_parent,gotip-linux-arm64_c4as16-perf_vs_parent
Change-Id: I6a6a6964c4c596bbf4f072b5a44a34c3ce4f6541
Reviewed-on: https://go-review.googlesource.com/c/go/+/696536
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 months agocrypto/tls: add flag to render HTML BoGo report
Daniel McCarney [Mon, 30 Jun 2025 16:45:36 +0000 (12:45 -0400)]
crypto/tls: add flag to render HTML BoGo report

Updates the BoGo test runner to add a `-bogo-html-report` flag. When
provided, an HTML report is written to the flag argument path. The
report shows the fail/pass/skip status of run tests and allows
sorting/searching the output.

Change-Id: I8c704a51fbb03500f4134ebfaba06248baa3ca2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/684955
Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Daniel McCarney <daniel@binaryparadox.net>
Commit-Queue: Carlos Amedee <carlos@golang.org>

3 months agocmd/link: support .def file with MSVC clang toolchain
Cherry Mui [Thu, 2 Oct 2025 22:24:12 +0000 (18:24 -0400)]
cmd/link: support .def file with MSVC clang toolchain

lld-link supports .def file, but requires a "-def:" (or "/def:")
flag. (MinGW linker, on the other hand, requires no flag.) Pass
the flag when using MSVC-based toolchain.

CL originally authored by Chressie Himpel.

Change-Id: I8c327ab48d36b0bcbb1d127cff544ffdb06be38e
Reviewed-on: https://go-review.googlesource.com/c/go/+/708716
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
3 months agocmd/cgo: fix unaligned arguments typedmemmove crash on iOS
Tim Cooijmans [Tue, 30 Sep 2025 21:53:11 +0000 (21:53 +0000)]
cmd/cgo: fix unaligned arguments typedmemmove crash on iOS

Irregularly typedmemmove and bulkBarrierPreWrite crashes on unaligned
arguments. By aligning the arguments this is fixed.

Fixes #46893

Change-Id: I7beb9fdc31053fcb71bee6c6cb906dea31718c56
GitHub-Last-Rev: 46ae8b96889644aab60ea4284cf447a740354c6a
GitHub-Pull-Request: golang/go#74868
Reviewed-on: https://go-review.googlesource.com/c/go/+/692935
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 months agonet/http/httputil: deprecate ReverseProxy.Director
Damien Neil [Thu, 2 Oct 2025 16:42:57 +0000 (09:42 -0700)]
net/http/httputil: deprecate ReverseProxy.Director

The Director function has been superseded by Rewrite.
Rewrite avoids fundamental security issues with hop-by-hop header
handling in the Director API and has better default handling
of X-Forwarded-* headers.

Fixes #73161

Change-Id: Iadaf3070e0082458f79fb892ade51cb7ce832802
Reviewed-on: https://go-review.googlesource.com/c/go/+/708615
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
3 months agonet/http: update bundled x/net/http2 and delete obsolete http2inTests
Nicholas S. Husin [Thu, 2 Oct 2025 16:41:25 +0000 (12:41 -0400)]
net/http: update bundled x/net/http2 and delete obsolete http2inTests

http2inTests is no longer needed after go.dev/cl/708135 and should be
deleted. To prevent errors in future vendored dependency updates,
h2_bundle.go is also updated together in this change.

Change-Id: I7b8c3f6854203fab4ec639a2a268df0cd2b1dee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/708595
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 months agoio/fs: move path name documentation up to the package doc comment
Damien Neil [Thu, 2 Oct 2025 17:45:01 +0000 (10:45 -0700)]
io/fs: move path name documentation up to the package doc comment

Perhaps surprisingly to users, io/fs path names are slash-separated.
Move the documentation for path names up to the top of the package
rather than burying it in the ValidPath documentation.

Change-Id: Id338df07c74a16be74c687ac4c45e0513ee40a8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/708616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

3 months agoruntime: skip TestGoroutineLeakProfile under mayMoreStackPreempt
Michael Anthony Knyszek [Thu, 2 Oct 2025 19:15:34 +0000 (19:15 +0000)]
runtime: skip TestGoroutineLeakProfile under mayMoreStackPreempt

This may be the long-term fix, but we first need to understand if this
just makes the tests flaky, or if it's revealing an actual underlying
issue. I'm leaning toward the former. If it is the former, ideally we
just make the tests robust (wait longer, maybe?).

For now, this change will make the longtest builders OK again.

For #75729.

Change-Id: If9b30107d04a8e5af5670850add3a53f9471eec6
Reviewed-on: https://go-review.googlesource.com/c/go/+/708715
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agoruntime: fix aix/ppc64 library initialization
qmuntal [Wed, 1 Oct 2025 08:59:53 +0000 (10:59 +0200)]
runtime: fix aix/ppc64 library initialization

AIX sets the argc and argv parameters in R14 and R15, but
_rt0_ppc64x_lib expects them to be in R3 and R4. Also, call reginit in
_rt0_ppc64x_lib.

These issues were oversights from CL 706395 which went unnoticed because
there if no LUCI aix/ppc64 builder (see #67299).

Change-Id: I93a2798739935fbcead3e6162b4b90db7e740aa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/708255
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
3 months agocmd/go: update `go help mod edit` with the tool and ignore sections
Daniel Martí [Sat, 30 Aug 2025 20:13:12 +0000 (21:13 +0100)]
cmd/go: update `go help mod edit` with the tool and ignore sections

The types were added to the docs, but not the fields in GoMod.
While here, I was initially confused about what is the top-level type
given that `type Module` comes first. Move `type GoMod` to the top
as it is the actual top-level type.

Change-Id: I1270154837501f5c7f5b21959b2841fd4ac808d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/700116
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
3 months agoruntime,net/http/pprof: goroutine leak detection by using the garbage collector
Vlad Saioc [Thu, 2 Oct 2025 11:57:58 +0000 (11:57 +0000)]
runtime,net/http/pprof: goroutine leak detection by using the garbage collector

Proposal #74609

Change-Id: I97a754b128aac1bc5b7b9ab607fcd5bb390058c8
GitHub-Last-Rev: 60f2a192badf415112246de8bc6c0084085314f6
GitHub-Pull-Request: golang/go#74622
Reviewed-on: https://go-review.googlesource.com/c/go/+/688335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 months agocmd/compile: propagate len([]T{}) to make builtin to allow stack allocation
Mateusz Poliwczak [Fri, 26 Sep 2025 18:47:45 +0000 (20:47 +0200)]
cmd/compile: propagate len([]T{}) to make builtin to allow stack allocation

Updates #75620

Change-Id: I6a6a6964af4512e30eb4806e1dc7b0fd0835744f
Reviewed-on: https://go-review.googlesource.com/c/go/+/707255
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>