57324 Commits

Author SHA1 Message Date
Michael Matloob
50f94b1dcd cmd/go/internal/doc: follow up to CL 733200
I submitted a rebased variant of the CL that dropped changes in
response to Sean Liao and Ian Alexander's comments.

Add the bug updates below and re-implement Ian's suggestion.

Fixes #34750
For #53446
For #60645

Change-Id: Ie132ac65efd27e811edabfbbb083b6946a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761580
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Ian Alexander <jitsu@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2026-03-31 22:06:52 -07:00
wangboyao
b5b9e3cdfe cmd/internal/obj/riscv: add support for FENCE operands and FENCE.TSO
Add support for fine-grained memory ordering flags in the RISC-V FENCE
instruction to the assembler. This implements instruction validation and
encoding for predecessor and successor flags (I, O, R, W) rather than
always falling back to a full memory barrier. This allows more precise
memory barriers like FENCE R, RW or FENCE W, W.

Additionally, this adds assembly support for the FENCE.TSO, which is
encoded as FENCE RW, RW with the fm field set to 1000.

Change-Id: Ie9c6c8cd24b38b08013032972bd54515eaedd637
Reviewed-on: https://go-review.googlesource.com/c/go/+/758000
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 21:17:57 -07:00
limeidan
87013ffec0 cmd/link/internal/loong64: remove the handling of R_CONST and R_GOTOFF from linker
These two relocations are general relocations and do not require special architectural handling.

Change-Id: Ibd5e71f6337e8dbb68e84759a46a46d9843b0382
Reviewed-on: https://go-review.googlesource.com/c/go/+/760080
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 18:42:56 -07:00
Mark Freeman
4f62ef0625 cmd/compile/internal/noder: reword comment
Change-Id: I9312f0b138e42363b611fc5193dd99a4a1f57db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/761600
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-31 16:42:03 -07:00
Mark Freeman
328950b13c cmd/compile/internal/noder: encode dictionaries for generic methods
Generic methods have 2 sources of explicit type arguments-the receiver
and the method itself. We simply concatenate these lists when
constructing the dictionary.

Change-Id: I8ba99fa7274b594941867e9bf6c2a22356c03e46
Reviewed-on: https://go-review.googlesource.com/c/go/+/761341
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 16:41:58 -07:00
Mark Freeman
9cd372147e cmd/compile/internal/noder: mangle method names
Mangling produces shaped qualified identifiers using a dictionary. It's
important for determining the stenciled type to use for a given
instantiation.

Since generic methods have qualified identifiers, they need mangling.
Suppose a generic method like T[P].m[Q] and a shaped dictionary like:

{
  implicits: 0
  receivers: 1
  targs:     [go.shape.int, go.shape.int]
}

This would be shaped to T[go.shape.int].m[go.shape.int].

Change-Id: Idc4c825f77a4e9209da65b5b0acb74b9f845bde7
Reviewed-on: https://go-review.googlesource.com/c/go/+/761340
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-31 16:41:49 -07:00
Michael Matloob
fe0850174f cmd/go: add more go tool documentation and show tool aliases in go tool
This change adds pointers in the documentation for go tool to point to
go get -tool, and vice versa, and documents the rules for when aliases
can be used for tools and what those aliases are.

It also modifies go tool with no arguments so that it prints the alias
for any tools for which aliases can be provided, such as:
    $ go tool
    asm
    cgo
    [...]
    bar (foo.com/full/package/path/bar)

For #71663

Change-Id: Id008cffbb02863692a18d4e1c1458b5b6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761100
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: 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>
2026-03-31 16:06:54 -07:00
Nicholas S. Husin
e3a10fe374 net/http/internal/http2: prevent hanging Transport due to bad SETTINGS frame
When processing SETTINGS frame, Transport currently only checks if the
frame is valid for SETTINGS_ENABLE_CONNECT_PROTOCOL. As a result, a
SETTINGS_MAX_FRAME_SIZE with the invalid value of 0 is erroneously
accepted. This will then result in Transport being stuck in an infinite
loop writing CONTINUATION frames.

This CL fixes the issue by ensuring that SETTINGS frame are always
validated, regardless of the SETTINGS parameter.

Thanks to Marwan Atia (marwansamir688@gmail.com) for reporting this
issue.

Fixes #78476
Fixes CVE-2026-33814

Change-Id: I8b6219431e87454d34bca738fbcb59b66a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761581
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-31 15:18:14 -07:00
Mark Freeman
836b0984ee cmd/compile/internal/noder: qualify identifiers for generic methods
Generic methods will be hoisted to objects so that they can get their
own dictionaries. We need to avoid name collisions, so within a
package, we qualify generic methods using their defining type.

We don't differentiate method identifiers by whether they have a pointer
or value receiver for simplicity.

Change-Id: Ied06c5e4a4c5a6f8de8027358ddbe38fc40ae452
Reviewed-on: https://go-review.googlesource.com/c/go/+/761263
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 15:09:29 -07:00
Mark Freeman
085187dc17 cmd/compile/internal/noder: method expressions have nil implicits
Change-Id: Ia7ba5484ef5258cc8edc19b7d500e334c0e0365d
Reviewed-on: https://go-review.googlesource.com/c/go/+/761261
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 15:05:12 -07:00
Mark Freeman
cafe443251 cmd/compile/internal/noder: method expressions for generic methods
This change permits shaping method expressions for generic methods.
The API is slightly different for generic and non-generic methods,
as explained in code comments.

Using OMETHEXPR minimizes the necessary changes, but forces us to
split / rejoin the linker symbol for generic methods. While a bit
odd, it seems sound.

Change-Id: Iff28b9b11b9e83f450225aba0873644633f20633
Reviewed-on: https://go-review.googlesource.com/c/go/+/761220
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 15:05:08 -07:00
qmuntal
fdd485c5f1 runtime/cgo: remove SIGSEGV emulation on iOS
The misc/ios exec wrapper doesn't support lldb since https://go.dev/cl/573175.
This means that the SIGSEGV emulation code in the cgo signal handling on
iOS is no longer needed, and can be removed.

Cq-Include-Trybots: luci.golang.try:gotip-darwin-arm64_26
Change-Id: I39827cb20756e4730352d87cb3514bb6a3f1cee8
Reviewed-on: https://go-review.googlesource.com/c/go/+/756800
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-31 12:52:46 -07:00
Kir Kolyshkin
974764364a runtime: unix: sane exit in dieFromSignal for pid 1
A curious bug was reported to kubernetes[1] and runc[2] recently:
sometimes runc init reports exit status of 2.

Turns out, Go runtime assumes that on any UNIX system signals such as
SIGTERM (or any other that has _sigKill flag set in sigtable) with no
signal handler set up, will result in kernel terminating the program.
This is true, except for PID 1 which gets a custom treatment from the
kernel.

As a result, when a Go program that runs as PID 1 (which is easy to
achieve in Linux by using a new PID namespace) receives such a signal,
Go runtime calls dieFromSignal which falls through all the way to
exit(2), which is very confusing to a user.

This issue can be worked around by the program by adding custom handlers
for SIGTERM/SIGINT/SIGHUP, but that requires a goroutine to handle those
signals, which, in case of runc, unnecessarily raises its NPROC/pid.max
requirement (see discussion at [2]).

Since practically exit(2) in dieFromSignal can only happen when the
process is running as PID 1, replace it with exit(128+sig) to mimic
the shell convention when a child is terminated by a signal.

Add a test case which demonstrates the issue and validates the fix
(albeit only on Linux).

[An earlier version of this patch used to do nothing in dieFromSignal
for PID 1 case, but such behavior might be a breaking change for a Go
program running in a Linux container as PID 1.]

Fixes #78442

[1]: https://github.com/kubernetes/kubernetes/issues/135713
[2]: https://github.com/opencontainers/runc/pull/5189

Change-Id: I196e09e4b5ce84ce2c747a0c2d1fc6e9cf3a6131
Reviewed-on: https://go-review.googlesource.com/c/go/+/759040
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-31 12:38:51 -07:00
matloob
2000e27ea6 cmd/go/internal/doc: use internal go command logic to load packages
We've been using go/build to load packages, and that doesn't
always do the right thing, because it doesn't have the same
context and settings that the go command uses to load packages.
Use the go command's loader to load packages.

This CL doesn't remove the logic for searching for matching
packages in dirs.go. A next step would be to remove that so
all the matching is also done with the go command's logic.

Fixes #75976

Change-Id: I3c76d9a54dc88648bb7c76a17afad8cb6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/733200
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2026-03-31 11:40:13 -07:00
Keith Randall
f9d2c2fd69 test/codegen: forbid commas as separators
We need to leave the comma in the regexp so we get the entire comment
for processing, but report an error if commas are actually used.

Change-Id: Ia19a329deda2524cea292d866a84d1bf3b4518c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/760780
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
Auto-Submit: Keith Randall <khr@google.com>
2026-03-31 11:01:23 -07:00
Keith Randall
1582ad4105 test/codegen: fix some unbalanced quotes
Change-Id: I081da8c79f0264118e079af21ff58c511ae37e6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/760682
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
2026-03-31 11:01:20 -07:00
Keith Randall
1673075d4b test/codegen: fix broken syntax
A bunch of tests had broken yet undetected syntax errors
in their assembly output regexps. Things like mismatched quotes,
using ^ instead of - for negation, etc.

In addition, since CL 716060 using commas as separators between
regexps doesn't work, and ends up just silently dropping every
regexp after the comma.

Fix all these things, and add a test to make sure that we're not
silently dropping regexps on the floor.

After this CL I will do some cleanup to align with CL 716060, like
replacing commas and \s with spaces (which was the point of that CL,
but wasn't consistently rewritten everywhere).

Change-Id: I54f226120a311ead0c6c62eaf5d152ceed106034
Reviewed-on: https://go-review.googlesource.com/c/go/+/760521
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Paul Murphy <paumurph@redhat.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-31 11:01:09 -07:00
Ian Lance Taylor
9387929d09 cmd/link, runtime: record size of itabs
We were depending on runtime.etypes immediately following the itabs.
However, on AIX, runtime.etypes, as a zero-sized symbol, can float
when using external linking. It won't necessarily stay right at the
end of the itabs. Rather than worry about this, just record the size
of the itab data.

In practice it almost always works on AIX, but it fails the runtime
test TestSchedPauseMetrics/runtime/debug.WriteHeapDump,
which fails when iterating over all the itabs.

Tested on AIX. This should fix AIX on the build dashboard.

Change-Id: Id3a113b75b93fa8440c047e92f764ab81423df48
Reviewed-on: https://go-review.googlesource.com/c/go/+/760203
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2026-03-31 11:01:05 -07:00
Cuong Manh Le
f665ff8bc1 cmd/compile: fix wrong label loop during rangefunc rewrite
During the rangefunc rewrite, the compiler must correctly identify
the target of branch statements. When a label is defined within a
nested scope - such as inside a function literal or a closure - it
can shadow a label with the same name in the outer scope.

If the rewrite logic does not account for this shadowing, it may
incorrectly associate a branch with a nested label rather than the
intended loop label. Since the typechecker already guarantees that
labels are unique within their respective scopes, any duplicate label
name encountered must belong to a nested scope. These should be
skipped to ensure branch computing correctly targets the current
range-loop scope.

Fixes #78408

Change-Id: I4dce8a4d956f41b3a717a509f8c3f7478720be9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/761420
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2026-03-31 10:58:57 -07:00
Cuong Manh Le
9002bd9fa1 cmd/compile: ensure map/slice clearing expressions are walked
The order pass ensures that initialization operations for clear(expr)
are scheduled. However, if 'expr' is a conversion that the walk pass
subsequently optimizes away or transforms, the resulting nodes can
be left in an un-walked state.

These un-walked nodes reach the SSA backend, which does not expect
high-level IR, resulting in an ICE.

This change ensures the expression is always walked during the
transformation of the 'clear' builtin.

Fixes #78410

Change-Id: I1997a28af020f39b2d325a58429eff9495048b1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/760981
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2026-03-31 10:58:53 -07:00
Jorropo
d9fbe4c90d cmd/compile: convert some condmoves in XOR
Similar to CL 685676 but for XOR.

Change-Id: Ib5ffd4c13348f176a808b3218fdbbafc2c42794f
Reviewed-on: https://go-review.googlesource.com/c/go/+/760921
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2026-03-31 10:58:48 -07:00
Jorropo
de7f006df2 cmd/compile: convert some condmoves in OR
Similar to CL 685676 but for OR.

Change-Id: I0ddfd457ed9e8888462306138a251ac48ad42084
Reviewed-on: https://go-review.googlesource.com/c/go/+/760920
Auto-Submit: Jorropo <jorropo.pgm@gmail.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>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2026-03-31 10:58:45 -07:00
Cherry Mui
97259c5d6b sync: replace linkname with import
The sync package uses linkname to access internal/runtime/atomic
package's LoadAcquintptr and StoreReluintptr functions. It was not
able to import the package when the package was
runtime/internal/atomic. Now that it moves to internal/runtime,
the sync package can just import it and call the functions
normally.

Change-Id: Ic7399e33d0e965fdcdf505be67a7f90e0260ddee
Reviewed-on: https://go-review.googlesource.com/c/go/+/750160
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2026-03-31 10:19:51 -07:00
Nicholas S. Husin
db6661a2fd net/http: support passing Server Shutdown context to HTTP/3 implementations
Currently, when Server.Shutdown is called with a given context, an
HTTP/3 server implementation does not have access to said context. This
forces HTTP/3 server implementations to guess a reasonable fixed timeout
when attempting to gracefully shutdown, which is not ideal.

Therefore, add ShutdownContext method to http3ServerHandler to handle
this.

For #77440

Change-Id: Ib15b615f646fd08788981eb06f3a70606a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761480
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-03-31 08:30:49 -07:00
Nigel Tao
af4c316c28 image/jpeg: reject RGB and non-standard chroma subsampling
This fixes a possible panic introduced a few months ago by "image/jpeg:
add support for non-standard chroma subsampling ratios" (CL 738280).

Fixes #78368

Change-Id: I1f181582b7dc1e2955e3ec26c3aa24bc0f4159df
Reviewed-on: https://go-review.googlesource.com/c/go/+/760701
Auto-Submit: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Nigel Tao <nigeltao@google.com>
2026-03-31 02:35:43 -07:00
Cuong Manh Le
1f8aff4386 simd/archsimd: mark pa* unsafe helpers as nocheckptr
Despite the cast from smaller to bigger slice, the elements after the
input slice length are not actually read. Thus they should have
nocheckptr annotation to make checkptr happy.

Fixes #78413

Change-Id: I3e27eab8a69b37bb11632b130a87e6625e06e8ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/761120
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2026-03-30 21:19:14 -07:00
Damien Neil
b526b2d49b net/http/internal/http2: don't reuse ClientRequest streams
The ClientRequest type (unlike http.Request) is not reusable
across RoundTrip attempts because it includes a single-use
clientStream. (It's possible for RoundTrip to return while
some goroutines are still accessing the clientStream.)

Always clone the ClientRequest on retries.

Fixes #78202
Fixes #78187

Change-Id: I4012bb4e017a9516278c873ec5a589086a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761301
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-30 14:49:44 -07:00
Florian Lehner
261d489139 internal/trace/tracev2: add String for ProcSyscallAbandoned
Add missing string for ProcSyscallAbandoned.

Change-Id: Ie6b049001432c2b667716d4eff95783c7eb1f350
Reviewed-on: https://go-review.googlesource.com/c/go/+/760840
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2026-03-30 14:46:40 -07:00
Robert Griesemer
ed3ec75df4 go/types, types2: report an error if constant string overflows
Set a limit of 10 GiB for strings obtained via constant string addition.

Fixes #78346.

Change-Id: I35dbdff94f3ed32bf69654f4b3da435dad9f6236
Reviewed-on: https://go-review.googlesource.com/c/go/+/761300
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
2026-03-30 13:36:41 -07:00
cuishuang
a4b534f5e4 all: fix some minor issues in the comments
Change-Id: If6c304efac7a46a9718cdc63ded3d98a26a3a831
Reviewed-on: https://go-review.googlesource.com/c/go/+/760700
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Fred Sauer <fredsa@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-30 10:18:42 -07:00
Michael Pratt
9c88851d45 runtime/race: allow TestOutput output in either order
We have only seen the wrappersym case reported in the opposite order in
practice, but since these are intentionally racy, they could
theoretically all occur in the opposite order.

It would be nice to have a bit more structure to these tests so the test
itself could easily flip the order. However, since they are just regular
expressions, for now I've simply listed both orders.

Fixes #78394.

Change-Id: I92e04127f275c2394a12d63d2f2a3ce56a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/761161
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-30 09:16:26 -07:00
matloob
7dbbeea110 cmd/go/internal/doc: document that -all and -short cannot be combined
And return an error message. Hopefully we can add support by the end of
the cycle, but for now return an error to avoid confusing users.

For #77191

Change-Id: I8a673a4bdfe640a04ec67b8bee0b5a056a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760304
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-30 09:07:22 -07:00
Mark Freeman
dadc8a5cd2 cmd/compile/internal/noder: swap use of TypeList for []Type
The noder will need to manipulate type argument lists. Because it is
outside types2, it needs exported APIs to do so, which then must also
be reflected in go/types.

We don't want APIs which only the noder cares about to be surfaced so
broadly. It might be better for the noder to use its own
representation for type lists; a []Type is fine for now.

Change-Id: Ia0917a6d26e00218fc9ccfd443d8d07224b1db5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/760360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-30 08:20:17 -07:00
Mark Freeman
3524089944 cmd/compile/internal/noder: add is[Concrete|Generic]Method helpers
The isGenericMethod helper will be necessary for upcoming changes
to UIR, though it's not currently used.

Since all generic methods are concrete methods, we also define the
isConcreteMethod helper to illustrate the subset relationship
between the two classes of methods. We use this helper for encoding
method dictionaries.

Change-Id: Ib7cdd7224fc733553726c8f86c0fe59ad60bff67
Reviewed-on: https://go-review.googlesource.com/c/go/+/759781
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-30 08:19:14 -07:00
Mateusz Poliwczak
4d1f503396 cmd/compile/internal/devirtualize: improve debug logs
Change-Id: Ie8d74d0968c3dfa6fe3454f1d3fdf13d6a6a6944
Reviewed-on: https://go-review.googlesource.com/c/go/+/760162
Auto-Submit: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-30 07:27:59 -07:00
Mateusz Poliwczak
09031d907c cmd/compile/internal/devirtualize: use pointer identity for type comparison
Fixes #78404

Change-Id: I6adc1fb42ad6a3acce21333c6819d0796a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760161
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2026-03-30 07:27:52 -07:00
Julien Cretel
acc2ce0759 encoding/hex: speed up Decode
This CL eliminates the remaining bounds check for index expressions on
Encode's src parameter within the function's loop.

Here are some benchmark results (no change to allocations):

goos: darwin
goarch: arm64
pkg: encoding/hex
cpu: Apple M4
                │     old     │             new              │
                │   sec/op    │   sec/op     vs base         │
Decode/256-10     166.2n ± 0%   142.9n ± 0%  -14.02% (n=180)
Decode/1024-10    626.9n ± 0%   532.7n ± 0%  -15.03% (n=180)
Decode/4096-10    2.472µ ± 0%   2.079µ ± 0%  -15.90% (n=180)
Decode/16384-10   9.843µ ± 0%   8.266µ ± 0%  -16.02% (n=180)
geomean           1.262µ        1.069µ       -15.25%

                │     old      │                  new                  │
                │     B/s      │     B/s       vs base                 │
Decode/256-10     1.434Gi ± 0%   1.669Gi ± 0%  +16.32% (p=0.000 n=180)
Decode/1024-10    1.521Gi ± 0%   1.790Gi ± 0%  +17.69% (p=0.000 n=180)
Decode/4096-10    1.543Gi ± 0%   1.834Gi ± 0%  +18.87% (p=0.000 n=180)
Decode/16384-10   1.550Gi ± 0%   1.846Gi ± 0%  +19.08% (p=0.000 n=180)
geomean           1.512Gi        1.783Gi       +17.98%

Change-Id: Ibf0471a75087feed528e6b547c7c2c88c6e14d38
GitHub-Last-Rev: dcda1b6a81
GitHub-Pull-Request: golang/go#78436
Reviewed-on: https://go-review.googlesource.com/c/go/+/760781
Auto-Submit: 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-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2026-03-30 07:09:16 -07:00
Tobias Klauser
3de9e7a067 runtime/cgo: remove unused _cgo_openbsd_try_pthread_create prototype
The function is no longer defined since CL 40331. Remove its prototype
from libcgo_unix.h as well.

Change-Id: I155ca632cd61bddcd798def691856c04b03040d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/760163
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2026-03-30 06:44:35 -07:00
Nick Ripley
d247ed00e4 runtime: remove redundant fields from memory profile records
The memProfCycle struct holds allocation counts and bytes allocated, and
frees and bytes freed. But the memory profile records are already
aggregated by allocation size, which is stored in the "size" field of
the bucket struct. We can derive the bytes allocated/freed using the
counts and the size we already store. Thus we can delete the bytes
fields from memProfCycle, saving 64 bytes per memRecord.

We can do something similar for the profilerecord.MemProfileRecord type.
We just need to know the object size and we can derive the allocated and
freed bytes accordingly.

Change-Id: I103885c2f29471b25283e330674fc16d6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760140
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2026-03-28 13:07:33 -07:00
Julian Zhu
e7e45d770c math: add assembly func archExp and archExp2 for riscv64
goos: linux
goarch: riscv64
pkg: math
                       │   math-old    │               math-new               │
                       │    sec/op     │    sec/op     vs base                │
Exp-64                    41.21n ±  0%    32.03n ±  0%  -22.28% (p=0.000 n=8)
Exp2-64                   38.86n ±  1%    28.18n ±  0%  -27.49% (p=0.000 n=8)
Exp2Go-64                 40.36n ±  1%    40.51n ±  1%   +0.36% (p=0.049 n=8)
Frexp-64                  5.681n ±  1%    5.446n ±  0%   -4.14% (p=0.000 n=8)
Ldexp-64                  7.676n ±  1%    7.555n ±  0%   -1.58% (p=0.001 n=8)

Change-Id: Ic122bf9598302f947c6dbf751db591f403c50373
Reviewed-on: https://go-review.googlesource.com/c/go/+/754687
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-27 21:02:30 -07:00
Cherry Mui
c7238e81ca cmd/link: run TestMachOBuildVersion only on darwin
There is no need to cross build a Mach-O binary in order to test
this. Only run it on Mach-O platforms. Also just do native build
instead of forcing GOARCH=amd64.

For #78266.

Change-Id: I7603ba9a51ea4f13411fdb4e159709f981ee755d
Reviewed-on: https://go-review.googlesource.com/c/go/+/759260
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2026-03-27 16:17:55 -07:00
Michael Pratt
733122c7cd runtime/race: use subtests for TestOutput
For #78394.

Change-Id: I4ef1a299f37e2b6532e2008378aca3aa6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760308
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2026-03-27 15:59:18 -07:00
Roland Shoemaker
5a0e083823 crypto: disallow RegisterHash with hash value 0
We already prevent registering hash values larger than the number of
hashes we actually have, but for some reason we don't prevent
registering hash value 0, which is the sentinel value we typically use
for "no hash". This change adds a check to prevent registering hash
value 0.

Fixes #60548

Change-Id: Ifd6edffb22b268ef282eae1b2ae4cc0ce748776c
Reviewed-on: https://go-review.googlesource.com/c/go/+/760280
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-27 13:05:00 -07:00
Michael Matloob
90adad7b25 cmd/go: specify full path to go command when running go tool covdata
Otherwise the GOROOT will be a post-1.25 GOROOT, while we try to run
"go tool covdata" with a go command that's 1.24 or earlier from the post
1.25 toolchain. The 1.24 go command won't be able to find covdata in the
1.25 goroot because go 1.25 and later don't ship with a prebuilt covdata
tool.

For #71867
Fixes #75031

Change-Id: I770f10a288347ac33cf721d34a2adb1a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/756220
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-27 12:13:00 -07:00
Cherry Mui
eeefb11776 cmd/go/internal/verylongtest: run tests in a separate GOCACHE
Based on the timing, the move to verylongtest seems to be related
to the start of #78180 flakiness. Run the tests in a separate
GOCACHE to isolate even more. Some tests indeed do something
unusual, like setting a umask, which could cause files in the
build cache to have an unusual permission. I'm not sure whether
and how the flaky failure could be related to this. Just give it
a shot.

Using a fresh GOCACHE might make it rebuild more packages. But it
is verylongtest anyway. Make it skip in short mode.

For #78180.

Change-Id: I5c9f83794d15310ffca8ba3dfa739016a5b8e899
Reviewed-on: https://go-review.googlesource.com/c/go/+/760382
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>
2026-03-27 11:22:02 -07:00
Cherry Mui
00146b7bab Revert "cmd/link: don't run TestExtLinkCmdlineDeterminism in parallel with other tests"
This reverts CL 759122.

Reason for revert: does not help reduce flakes.

For #78180.

Change-Id: Ia994d0bcc0ab681dd8cca9acbac20ac547647fe7
Reviewed-on: https://go-review.googlesource.com/c/go/+/760381
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-27 11:08:19 -07:00
Michael Matloob
4d6a40923b debug/buildinfo: remove macho/elf DataStart fallback code
The go version code can't read pre-1.13 go versions, but in 1.13 we
always write the go version info to the .go.buildinfo section. Remove
the fallback code because it won't be used.

See https://github.com/rsc/goversion/blob/v1.2.0/version/read.go for the
original rsc.io/goversion code that could read pre-1.13 data and
CL 173343 for the code added to go1.13 which would look for a writable
section rather than a read only section as rsc.io/goversion did.

Fixes #73060

Change-Id: I5d593d5724323351aef3ff04e04f7df96a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/756421
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-27 10:38:09 -07:00
Damien Neil
703bb60bf1 database/sql: don't try to synctest.Wait in benchmarks
Benchmarks shouldn't use synctest. Avoid a synctest.Wait in database
shutdown when in benchmarks.

Fixes #78373

Change-Id: I14755f8eefb3ab5c69cc660b1e884bbf6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/760400
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>
2026-03-27 10:31:58 -07:00
yongqijia
2d72c268ea cmd/fix: change -diff to exit 1 if diffs exist
Currently "go fix -diff" and "go vet -fix -diff" always exit with status
0 even when they print diffs, which is inconsistent with "gofmt -d"
(#46289) and "go mod tidy -diff" (#27005) that exit non-zero when diffs
are present.

The root cause is that the default VetHandleStdout (copyToStdout) simply
copies the tool stdout through without checking whether any content was
produced. This change installs a new copyAndDetectDiff handler in -diff
mode that copies the tool stdout through and calls base.SetExitStatus(1)
when content is present, matching the pattern used by "go mod tidy -diff".

Fixes #77583

Change-Id: I588fbaae8b3690da2f821240baa4a3b14b78f280
Reviewed-on: https://go-review.googlesource.com/c/go/+/749700
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-03-27 09:24:37 -07:00
Nick White
7f2e2fd71f cmd/go: add example support to go doc output
The go doc command now includes a -ex flag to list executable examples.
It will also print the code and expected output of an example when
passed its name.

Fixes #26715

Change-Id: I34b09403cc3cb45655939bd4fe27accec0e141f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/445116
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2026-03-27 07:58:59 -07:00