]> Cypherpunks repositories - gostls13.git/log
gostls13.git
14 months agocmd/link: replace function pointers to static calls in loadelf
Cherry Mui [Thu, 15 Feb 2024 22:05:05 +0000 (17:05 -0500)]
cmd/link: replace function pointers to static calls in loadelf

When transitioning between the old object loader and the new
object loader, to support both we made loadelf to take symbol
loading functions as function pointers. Now we only have the new
object loader. Change the function pointers back to static calls.

Change-Id: Ia623a6010376a3d7c0be5eacae002144d956f28a
Reviewed-on: https://go-review.googlesource.com/c/go/+/564635
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agocmd/link: add -randlayout flag to randomize function ordering
Cherry Mui [Tue, 6 Feb 2024 23:08:34 +0000 (18:08 -0500)]
cmd/link: add -randlayout flag to randomize function ordering

Sometimes we found that benchmark results may strongly depend on
the ordering of functions laid out in the binary. This CL adds a
flag -randlayout=seed, which randomizes the function layout (in a
deterministic way), so can verify the benchmark results against
different function ordering.

Change-Id: I85f33881bbfd4ca6812fbd4bec00bf475755a09e
Reviewed-on: https://go-review.googlesource.com/c/go/+/562157
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoruntime,cmd/link: merge pcbucketsize const into internal/abi
qiulaidongfeng [Fri, 16 Feb 2024 00:15:29 +0000 (00:15 +0000)]
runtime,cmd/link: merge pcbucketsize const into internal/abi

For #59670

Change-Id: I6343bacd3126fe6381a2e73be10f61691792824d
GitHub-Last-Rev: bbab8d1142e5749f58c17f6f668e2eb679ff69d7
GitHub-Pull-Request: golang/go#65373
Reviewed-on: https://go-review.googlesource.com/c/go/+/559475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/compile: improve rotations for riscv64
Joel Sing [Thu, 1 Feb 2024 12:58:54 +0000 (23:58 +1100)]
cmd/compile: improve rotations for riscv64

Enable canRotate for riscv64, enable rotation intrinsics and provide
better rewrite implementations for rotations. By avoiding Lsh*x64
and Rsh*Ux64 we can produce better code, especially for 32 and 64
bit rotations. By enabling canRotate we also benefit from the generic
rotation rewrite rules.

Benchmark on a StarFive VisionFive 2:

               │   rotate.1   │              rotate.2               │
               │    sec/op    │   sec/op     vs base                │
RotateLeft-4     14.700n ± 0%   8.016n ± 0%  -45.47% (p=0.000 n=10)
RotateLeft8-4     14.70n ± 0%   10.69n ± 0%  -27.28% (p=0.000 n=10)
RotateLeft16-4    14.70n ± 0%   12.02n ± 0%  -18.23% (p=0.000 n=10)
RotateLeft32-4   13.360n ± 0%   8.016n ± 0%  -40.00% (p=0.000 n=10)
RotateLeft64-4   13.360n ± 0%   8.016n ± 0%  -40.00% (p=0.000 n=10)
geomean           14.15n        9.208n       -34.92%

Change-Id: I1a2036fdc57cf88ebb6617eb8d92e1d187e183b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/560315
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agosyscall: rm obsoleted comment
Kir Kolyshkin [Wed, 15 Nov 2023 00:28:29 +0000 (16:28 -0800)]
syscall: rm obsoleted comment

The comment being removed is no longer true as of CL 494916.

Change-Id: I4975866c58efb5c9c41db3640564ac7233f5840f
Reviewed-on: https://go-review.googlesource.com/c/go/+/542415
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/compile: update the incorrect assignment of call site offset.
Jin Lin [Thu, 8 Feb 2024 20:52:07 +0000 (12:52 -0800)]
cmd/compile: update the incorrect assignment of call site offset.

The call site calculation in the previous version is incorrect. For
the PGO preprocess file, the compiler should directly use the call
site offset value. Additionly, this change refactors the preprocess
tool to clean up unused fields including startline, the flat and the
cum.

Change-Id: I7bffed3215d4c016d9a9e4034bfd373bf50ab43f
Reviewed-on: https://go-review.googlesource.com/c/go/+/562795
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agolog/slog: add test case for level_test.go
pgxiaolianzi [Wed, 7 Feb 2024 07:45:14 +0000 (07:45 +0000)]
log/slog: add test case for level_test.go

adds a test case for the MarshalJSON and MarshalText method of the Level type in the slog package.

Change-Id: I3f79f0b46c41252ad9d743e03e34503e19998f3e
GitHub-Last-Rev: dab00d4c206ca59fcca7ee8d97ca8cdc9475fdce
GitHub-Pull-Request: golang/go#65525
Reviewed-on: https://go-review.googlesource.com/c/go/+/561315
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
14 months agolog/slog: document atomicity guarantees and ordering limitations of handlers
Joe Tsai [Tue, 13 Feb 2024 23:34:26 +0000 (15:34 -0800)]
log/slog: document atomicity guarantees and ordering limitations of handlers

The new wording is slightly more strict than before in that
it guarantees each Write only contains exactly one Record,
while the previous wording opened up the possibility for
multiple Records in a Write call.

We also add a comment about the lack of sorting guarantees for
concurrently logged Records. That is, the obtained lock only covers
the Write call, rather than the combination of the call to time.Now,
JSON/text serialization, and also the Write call.

Change-Id: Ia65c50579215a35a1f5b2952c6954ddb60e7fe66
Reviewed-on: https://go-review.googlesource.com/c/go/+/563976
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
14 months agonet/http: reject requests with invalid Content-Length headers
Andy Pan [Sun, 4 Feb 2024 06:50:42 +0000 (14:50 +0800)]
net/http: reject requests with invalid Content-Length headers

According to RFC 9110 and RFC 9112, invalid "Content-Length" headers
might involve request smuggling or response splitting, which could
also cause security failures. Currently, `net/http` ignores all
"Content-Length" headers when there is a "Transfer-Encoding" header and
forward the message anyway while other mainstream HTTP implementations
such as Apache Tomcat, Nginx, HAProxy, Node.js, Deno, Tornado, etc. reject
invalid Content-Length headers regardless of the presence of a
"Transfer-Encoding" header and only forward chunked-encoding messages
with either valid "Content-Length" headers or no "Content-Length" headers.

Fixes #65505

Change-Id: I73af2ee0785137e56c7546a4cce4a5c5c348dbc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/561075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
14 months agocmd/link/internal/ld: unify OS/SDK versions for macOS linking
Dmitri Shuralyov [Wed, 14 Feb 2024 16:52:22 +0000 (11:52 -0500)]
cmd/link/internal/ld: unify OS/SDK versions for macOS linking

Go 1.23 will require macOS 11 Big Sur or later, even on AMD64.
The comment here suggests the main requirement for the OS and
SDK version is to be recent enough not to break Apple signing,
and recent enough not to cause other problems.

For now, this CL simplifies the code by merging the ARM64 and
AMD64 cases into one, given 1.23 will be the first Go release
with a common minimum macOS version for both architectures so
there's no need to treat them separately here.

For #64207.

Change-Id: I821fcb9a2a316de0703833c8a75abcbaa10b17a3
Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_11,gotip-darwin-amd64_14,gotip-darwin-arm64_11,gotip-darwin-arm64_13
Reviewed-on: https://go-review.googlesource.com/c/go/+/563857
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agodoc/go1.23: document macOS requirements
Dmitri Shuralyov [Wed, 14 Feb 2024 16:25:03 +0000 (11:25 -0500)]
doc/go1.23: document macOS requirements

For #64207.
For #65614.

Change-Id: Ia5365b4090060e0657c255341751d3e67691f836
Reviewed-on: https://go-review.googlesource.com/c/go/+/563856
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoruntime: make netpoll events sources identifiable on Windows
qmuntal [Thu, 8 Feb 2024 07:46:24 +0000 (08:46 +0100)]
runtime: make netpoll events sources identifiable on Windows

This is another attempt at CL 558895, but without adding stale pollDescs
protection, which deviates from the original goal of the CL and adds
complexity without proper testing.

It is currently not possible to distinguish between a netpollBreak,
an internal/poll WSA operation, and an external WSA operation (as
in #58870). This can cause spurious wakeups when external WSA operations
are retrieved from the queue, as they are treated as netpollBreak
events.

This CL makes use of completion keys to identify the source of the
event.

While here, fix TestWSASocketConflict, which was not properly
exercising the "external WSA operation" case.

Change-Id: I91f746d300d32eb7fed3c8f27266fef379360d98
Reviewed-on: https://go-review.googlesource.com/c/go/+/561895
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
14 months agonet: skip TestModeSocket on older Windows versions
qmuntal [Mon, 12 Feb 2024 10:04:24 +0000 (11:04 +0100)]
net: skip TestModeSocket on older Windows versions

CL 561937 taught os.Stat about IO_REPARSE_TAG_AF_UNIX and added a
test for it, TestModeSocket. This test fails on Windows older than
10.0.17063, in which AF_UNIX support was added. Skip the test on those
versions.

Some CI builders use Windows 10.0.14393, so CL 561937 broke them,
e.g. https://build.golang.org/log/5ea4f6422779f32eccfef3a25df54283ddd4e65e.

Change-Id: I6c21a78a1454d2d88321478288c0da1b8a93e590
Reviewed-on: https://go-review.googlesource.com/c/go/+/563256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agoruntime/cgo: mark fatalf as noreturn
Mauri de Souza Meneguzzo [Fri, 15 Dec 2023 02:02:41 +0000 (02:02 +0000)]
runtime/cgo: mark fatalf as noreturn

Fixes #64553

Change-Id: I7860cd9ba74d70a7d988538ea4df8e122f94cde6
GitHub-Last-Rev: 06164374734aef5b94566930426005ad66d0a5b6
GitHub-Pull-Request: golang/go#64727
Reviewed-on: https://go-review.googlesource.com/c/go/+/550115
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agointernal/asan: add new package
Mauri de Souza Meneguzzo [Wed, 7 Feb 2024 22:51:00 +0000 (22:51 +0000)]
internal/asan: add new package

The internal/asan package contains helper functions for manually
instrumenting code for the address sanitizer. It reexports the asan
routines in runtime unconditionally, making the functions a no-op if the
build flag "asan" is not present.

For #64611

Change-Id: Ie79e698aea7a6d969afd2a5f008c084c9545b1a5
GitHub-Last-Rev: e658670c146adb5a5496afe4a2425dd5291fd7ac
GitHub-Pull-Request: golang/go#64635
Reviewed-on: https://go-review.googlesource.com/c/go/+/548695
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agocmd/internal/obj/ppc64: rename and remove aliased optab classifiers
Paul E. Murphy [Tue, 14 Nov 2023 20:58:49 +0000 (14:58 -0600)]
cmd/internal/obj/ppc64: rename and remove aliased optab classifiers

Rename C_LCON, C_SCON, C_ADDCON, C_ANDCON into their aliased names
and remove them.

Change-Id: I8f67cc973f8059e65b81669d91a44500fc136b0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/563097
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agonet/http: close connection if OnProxyConnectResponse returns an error
Damien Neil [Sat, 3 Feb 2024 00:19:37 +0000 (16:19 -0800)]
net/http: close connection if OnProxyConnectResponse returns an error

Fixes #64804

Change-Id: Ibe56ab8d114b8826e477b0718470d0b9fbfef9b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/560856
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
14 months agonet/http: refine trailing-slash redirect logic
Jonathan Amsterdam [Fri, 9 Feb 2024 15:18:38 +0000 (10:18 -0500)]
net/http: refine trailing-slash redirect logic

Do not add a trailing slash and redirect if the path already
ends in a slash.

Also, and unrelatedly, add a test for cleanPath.

Fixes #65624.

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

14 months agointernal/safefilepath: use bytealg to search for zero byte
Ian Lance Taylor [Mon, 12 Feb 2024 03:54:52 +0000 (19:54 -0800)]
internal/safefilepath: use bytealg to search for zero byte

Change-Id: I20e72d421d89095c460495001969291b99cdf59e
Reviewed-on: https://go-review.googlesource.com/c/go/+/563139
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

14 months agotime: fix typo in ExampleParseDuration
Rob Pike [Mon, 12 Feb 2024 00:35:29 +0000 (11:35 +1100)]
time: fix typo in ExampleParseDuration

A typo without consequences, but confusing nonetheless. The last
line prints micro2 and then micro, instead of micro2 twice.
One-character fix.

Fixes #65666

Change-Id: I61d636382a2223d53eac58d6ddbcc7c15b4efc85
Reviewed-on: https://go-review.googlesource.com/c/go/+/563275
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agofmt: clear width and precision when recovering formatting object from the pool
Rob Pike [Wed, 17 Jan 2024 00:19:53 +0000 (11:19 +1100)]
fmt: clear width and precision when recovering formatting object from the pool

Probably a day 1 oversight, and almost always inconsequential, but
there is evidence of occasional trouble. There is no reason not to
clear them.

I tried and failed to write a test to catch this, but the change should
be harmless and is all but certain to fix the problem.

Fixes #61913

Change-Id: I0f7bbb4ab2780d8999d3ff7a35255dc07fb5c7e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/556215
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agofmt: document how %#g handles infinities and NaNs
Rob Pike [Sun, 21 Jan 2024 06:20:02 +0000 (17:20 +1100)]
fmt: document how %#g handles infinities and NaNs

The %#g format prints a "Go-syntax representation", but there is
no such thing for IEEE754 infinities and NaNs, so just document
what happens, which is that it prints +Inf, -Inf, or NaN.  We could
show something like math.Inf(1) and math.Nan(), but that doesn't
sit right, and anyway for NaNs you can't even recover the original
value. Simpler and more honest to give up.

Fixes #51486

Change-Id: I8d4e8186f5d7acc3e0e7b51d0b322142908ea0a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/557235
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agoruntime/cgo: add note about default stack bounds
Michael Pratt [Mon, 12 Feb 2024 19:32:22 +0000 (14:32 -0500)]
runtime/cgo: add note about default stack bounds

The default case in x_cgo_getstackbound does not actually get the stack bound of
the current thread, but estimates the bound based on the default stack size. Add
a comment noting this.

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

14 months agoruntime: skip failing traceback test on Android
Alan Donovan [Mon, 12 Feb 2024 15:34:54 +0000 (10:34 -0500)]
runtime: skip failing traceback test on Android

See e.g. https://build.golang.org/log/1e6bd28cf75679c66479025c1a0d9082734cf33e

Change-Id: Ic13bc0a40d04afe693d1de07973e2540dadacb23
Reviewed-on: https://go-review.googlesource.com/c/go/+/563415
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agointernal/xcoff: change zeroReaderAt to nobitsSectionReader for .bss with all 0s
Jes Cok [Sat, 10 Feb 2024 01:25:05 +0000 (01:25 +0000)]
internal/xcoff: change zeroReaderAt to nobitsSectionReader for .bss with all 0s

Fixes #63337

Change-Id: I239315047e6e4325e2f471108fd764f8dbb7d5b2
GitHub-Last-Rev: cacdf0a279451ab97e6e6ce3fe0d3a025f5ce3aa
GitHub-Pull-Request: golang/go#64952
Reviewed-on: https://go-review.googlesource.com/c/go/+/553616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoreflect: optimize TypeFor for non-interface types
Joe Tsai [Sat, 13 Jan 2024 02:13:14 +0000 (18:13 -0800)]
reflect: optimize TypeFor for non-interface types

The reflect.Type.Elem method is somewhat slow,
which is unfortunate since the reflect.TypeOf((*T)(nil)).Elem()
trick is only needed if T is an interface.

Optimize for concrete types by doing the faster reflect.TypeOf(v)
call first and only falling back on the Elem method if needed.

Performance:

name              old time/op  new time/op  delta
TypeForString-24  9.10ns ± 1%  1.78ns ± 2%  -80.49%  (p=0.000 n=10+10)
TypeForError-24   9.55ns ± 1%  9.78ns ± 1%   +2.39%  (p=0.000 n=10+9)

Updates #60088

Change-Id: I2ae76988c9a3dbcbae10d2c19b55db3c8d4559bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/555597
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
14 months agonet/http: remove superfluous newline on redirects
codesoap [Thu, 8 Feb 2024 22:18:27 +0000 (22:18 +0000)]
net/http: remove superfluous newline on redirects

Change-Id: I30d3ae9d540f9cc85ea5a6875ee8884d3e646d6f
GitHub-Last-Rev: 29cabdcb3a8746ef51953617f4ec47deac3608da
GitHub-Pull-Request: golang/go#65623
Reviewed-on: https://go-review.googlesource.com/c/go/+/562356
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>

14 months agoos: add os.ModeSocket support to os.Stat on windows
qmuntal [Wed, 7 Feb 2024 16:40:24 +0000 (17:40 +0100)]
os: add os.ModeSocket support to os.Stat on windows

Unix sockets are identified by the IO_REPARSE_TAG_AF_UNIX reparse tag.

Teach fileStat.Mode() to recognize this tag and set the os.ModeSocket
bit in such case.

Note that there is a bug starting in Windows 19H1 until 20H1 that
makes the IO_REPARSE_TAG_AF_UNIX tag not being set for unix sockets.
This CL doesn't provide a workaround for this bug.

Fixes #33357.

Change-Id: Iea8f24b20672c8d4b03f55ef298d128431dc3fac
Reviewed-on: https://go-review.googlesource.com/c/go/+/561937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agoruntime/cgo: ignore -Watomic-alignment in gcc_libinit.c
Mauri de Souza Meneguzzo [Fri, 9 Feb 2024 11:47:26 +0000 (11:47 +0000)]
runtime/cgo: ignore -Watomic-alignment in gcc_libinit.c

When cross-compiling a cgo program with CC=clang for Linux/ARMv5,
atomic warnings cause build errors, as cgo uses -Werror.

These warnings seem to be harmless and come from the usage of
__atomic_load_n, which is emulated due to the lack of atomic
instructions in armv5.

Fixes #65290

Change-Id: Ie72efb77468f06888f81f15850401dc8ce2c78f9
GitHub-Last-Rev: fbad847b962f6b4599cd843018e79f4b55be097e
GitHub-Pull-Request: golang/go#65588
Reviewed-on: https://go-review.googlesource.com/c/go/+/562348
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
14 months agoio/fs: set ErrInvalid for FS.Open from SubFS when it fails ValidPath
Andy Pan [Thu, 1 Feb 2024 03:28:44 +0000 (11:28 +0800)]
io/fs: set ErrInvalid for FS.Open from SubFS when it fails ValidPath

Fixes #65419

Change-Id: I8f9f82ab0387d8bb39aaca4f9e60e36ee15c587d
Reviewed-on: https://go-review.googlesource.com/c/go/+/560137
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agonet: skip BenchmarkSendFile on Windows
Andy Pan [Thu, 8 Feb 2024 02:15:53 +0000 (10:15 +0800)]
net: skip BenchmarkSendFile on Windows

Follow up CL 543276

Change-Id: Ie02cf8a489a069bb0a3be1d8636e30d0658329c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/562595
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

14 months agoruntime: call traceAdvance before exiting
Nicolas Hillegeer [Thu, 8 Feb 2024 16:56:33 +0000 (08:56 -0800)]
runtime: call traceAdvance before exiting

This ensures the trace buffers are as up-to-date as possible right
before crashing. It increases the chance of finding the culprit for the
crash when looking at core dumps, e.g. if slowness is the cause for the
crash (monitor kills process).

Fixes #65319.

Change-Id: Iaf5551911b3b3b01ba65cb8749cf62a411e02d9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/562616
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
14 months agonet: don't retry truncated TCP responses
Antonio Ojea [Fri, 22 Dec 2023 18:15:34 +0000 (18:15 +0000)]
net: don't retry truncated TCP responses

UDP messages may be truncated:

https://www.rfc-editor.org/rfc/rfc1035#section-4.2.1

> Messages carried by UDP are restricted to 512 bytes (not counting
> the IP or UDP headers). Longer messages are truncated and the TC
> bit is set in the header.

However, TCP also have a size limitation of 65535 bytes

https://www.rfc-editor.org/rfc/rfc1035#section-4.2.2

> The message is prefixed with a two byte length field which gives
the message length, excluding the two byte length field.

These limitations makes that the maximum possible number of A records
per RRSet is ~ 4090.

There are environments like Kubernetes that may have larger number of
records (5000+) that does not fit in a single message. In this cases,
the DNS server sets the Truncated bit on the message to indicate that
it could not send the full answer despite is using TCP.

We should only retry when the TC bit is set and the connection is UDP,
otherwise, we'll never being able to get an answer and the client will
receive an errNoAnswerFromDNSServer, that is a different behavior than
the existing in the glibc resolver, that returns all the existing
addresses in the TCP truncated response.

Fixes #64896

Signed-off-by: Antonio Ojea <aojea@google.com>
Change-Id: I1bc2c85f67668765fa60b5c0378c9e1e1756dff2
Reviewed-on: https://go-review.googlesource.com/c/go/+/552418
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Gudger <ian@iangudger.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agocmd/internal/obj/ppc64: add new constant optab classifications
Paul E. Murphy [Tue, 14 Nov 2023 20:45:21 +0000 (14:45 -0600)]
cmd/internal/obj/ppc64: add new constant optab classifications

Make C_S32CON, C_U32CON, and C_32CON distinct classifiers to allow
more specific matching of 32 bit constants. C_U31CON is added to
support C_S32CON.

Likewise, add C_16CON which is the union of C_S16CON and C_U16CON
classification. This wil allow simplifying MOVD/MOVW optab entries
in a future patch.

Change-Id: I193acc0ded8f3edd91d306e39c3e7e55a9811e04
Reviewed-on: https://go-review.googlesource.com/c/go/+/562346
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agointernal/trace: run children in race mode during race testing
Michael Pratt [Fri, 9 Feb 2024 19:06:39 +0000 (14:06 -0500)]
internal/trace: run children in race mode during race testing

This would have caught #65607.

On my machine:

internal/trace/v2:               ~13s
internal/trace/v2: -short:        ~4s
internal/trace/v2: -race -short: ~20s
internal/trace/v2: -race:        ~46s

For #65607.

Change-Id: I03a555ebaf8c761c98a82b6d35fa16d7a99aa9e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/562998
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
14 months agointernal/trace: fix race condition in gc-stress
Michael Pratt [Fri, 9 Feb 2024 19:16:11 +0000 (14:16 -0500)]
internal/trace: fix race condition in gc-stress

Multiple goroutines all writing to the same sink triggers the race detector,
rightfully so.

Change-Id: Ia64836d0d88c0f587a6cb96ed747f656a3c1804a
Reviewed-on: https://go-review.googlesource.com/c/go/+/562997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
14 months agoruntime: don't call traceReadCPU on the system stack
Michael Pratt [Fri, 9 Feb 2024 18:49:21 +0000 (13:49 -0500)]
runtime: don't call traceReadCPU on the system stack

traceReadCPU calls profBuf.read, which does a raceacquire. g0 does not
have a race context, so this crashes when running on the system stack.

We could borrow a race context, but it is simpler to just move
traceReadCPU off of the system stack.

Fixes #65607.

Change-Id: I335155b96d683aebb92b2f4e1eea063dd139f2d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/562996
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
14 months agocmd/compile: fail noder.LookupFunc gracefully if function generic
Michael Pratt [Thu, 8 Feb 2024 18:07:33 +0000 (13:07 -0500)]
cmd/compile: fail noder.LookupFunc gracefully if function generic

PGO uses noder.LookupFunc to look for devirtualization targets in
export data.  LookupFunc does not support type-parameterized
functions, and will currently fail the build when attempting to lookup
a type-parameterized function because objIdx is passed the wrong
number of type arguments.

This doesn't usually come up, as a PGO profile will report a generic
function with a symbol name like Func[.go.shape.foo]. In export data,
this is just Func, so when we do LookupFunc("Func[.go.shape.foo]")
lookup simply fails because the name doesn't exist.

However, if Func is not generic when the profile is collected, but the
source has since changed to make Func generic, then LookupFunc("Func")
will find the object successfully, only to fail the build because we
failed to provide type arguments.

Handle this with a objIdxMayFail, which allows graceful failure if the
object requires type arguments.

Bumping the language version to 1.21 in pgo_devirtualize_test.go is
required for type inference of the uses of mult.MultFn in
cmd/compile/internal/test/testdata/pgo/devirtualize/devirt_test.go.

Fixes #65615.

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

14 months agocmd/cgo/internal/testsanitizers: disable location checking for clang
Michael Anthony Knyszek [Thu, 8 Feb 2024 15:59:07 +0000 (15:59 +0000)]
cmd/cgo/internal/testsanitizers: disable location checking for clang

Pending a resolution to #65606, this CL marks clang's ASAN runtime as
unable to symbolize stack traces to unblock the LUCI clang builder.

For #65606.
Fixes #65469.

Change-Id: I649773085aff30e5703e7f7ac2c72a0430a015c2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-clang15
Reviewed-on: https://go-review.googlesource.com/c/go/+/562675
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agocmd/compile: separate inline cost analysis from applying inlining
Matthew Dempsky [Wed, 7 Feb 2024 18:23:53 +0000 (10:23 -0800)]
cmd/compile: separate inline cost analysis from applying inlining

This CL separates the pass that computes inlinability from the pass
that performs inlinability. In particular, the latter can now happen
in any flat order, rather than bottom-up order. This also allows
inlining of calls exposed by devirtualization.

Change-Id: I389c0665fdc8288a6e25129a6744bfb1ace1eff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/562319
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agocmd/trace/v2,internal/trace: use correct frame for identifying goroutines
Nick Ripley [Wed, 7 Feb 2024 16:43:05 +0000 (11:43 -0500)]
cmd/trace/v2,internal/trace: use correct frame for identifying goroutines

To determine the identity of a goroutine for displaying in the trace UI,
we should use the root frame from a call stack. This will be the
starting function for the goroutine and is the same for each call stack
from a given goroutine. The new tracer no longer includes starting PCs
for goroutines which existed at the start of tracing, so we can't use a
PC for grouping together goroutines any more. Instead, we just use the
name of the entry function for grouping.

Fixes #65574

Change-Id: I5324653316f1acf0ab90c30680f181060ea45dd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/562455
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agocontext: improve valueCtx.String
Joe Tsai [Sat, 13 Jan 2024 00:28:56 +0000 (16:28 -0800)]
context: improve valueCtx.String

Check for stringer on the key itself.
This is useful for locally defined context key types,
where there may be multiple instances of that type.
For example, see http.contextKey,
which can now be called after this change.

For the value itself, print the type at least
instead of just resorting to "<not stringer>".

Change-Id: I588ef1df34e90fb9ebd83cb180fea495e1fedaa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/555697
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agotime: fix FuzzFormatRFC3339 nano comparison
Jorropo [Mon, 5 Feb 2024 00:22:58 +0000 (01:22 +0100)]
time: fix FuzzFormatRFC3339 nano comparison

Change-Id: I13ed84b99459d5844abb6e932cc4b8e0bd3ae9f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/561215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agosort: use math/rand/v2 in tests and benchmarks
Tobias Klauser [Tue, 23 Jan 2024 16:36:06 +0000 (17:36 +0100)]
sort: use math/rand/v2 in tests and benchmarks

This allows to drop the use of deprecated rand.Seed in benchmarks.

Fixes #61142

Change-Id: I628848c0d4a500dc9a361930c393e47c3361a95c
Reviewed-on: https://go-review.googlesource.com/c/go/+/551155
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agoruntime: traceback: include pc=0x%x for inline frames
Alan Donovan [Mon, 5 Feb 2024 21:38:41 +0000 (16:38 -0500)]
runtime: traceback: include pc=0x%x for inline frames

Crash monitoring tools may parse the PC values and feed them
to CallersFrames, which does not run the inline unwinder, since
Callers already did so. So, the GOTRACEBACK=system output
must also include PC values even for inlined frames.
(The actual values are just marker NOP instructions,
but that isn't important.)

This CL also includes a test that the PC values can be
parsed out of the crash report and fed to CallersFrames
to yield a sensible result. (The logic is a distillation
of the x/telemetry crashmonitor.)

The previously printed PCs were in fact slightly wrong
for frames containing inlined calls: instead of the
virtual CALL instruction (a NOP) to the first
inlined call, it would display the PC of the
CALL in the innermost inlined function.

Change-Id: I64a06771fc191ba16c1383b8139b714f4f299703
Reviewed-on: https://go-review.googlesource.com/c/go/+/561635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/compile: accept -lang=go1 as -lang=go1.0
Matthew Dempsky [Thu, 8 Feb 2024 01:25:48 +0000 (17:25 -0800)]
cmd/compile: accept -lang=go1 as -lang=go1.0

Fixes #65528.

Change-Id: I55fef8cf7be4654c7242462d45f12999e0c91c02
Reviewed-on: https://go-review.googlesource.com/c/go/+/562322
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agocmd/go: add telemetry counters for flag names and subcommand
Michael Matloob [Thu, 8 Feb 2024 17:50:44 +0000 (17:50 +0000)]
cmd/go: add telemetry counters for flag names and subcommand

For #58894,#65586

This is a revert of CL 560655 which was a revert of CL 559519.
CL 559519 was reverted because it was broken on windows/386. But now
CL 562715 pulls in x/telemetry CL 560462 which disables telemetry on
windows/386, fixing that issue.

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

14 months agocmd: update golang.org/x/telemetry and its dependencies
Michael Matloob [Thu, 8 Feb 2024 17:34:44 +0000 (12:34 -0500)]
cmd: update golang.org/x/telemetry and its dependencies

This change was produced with
go get golang.org/x/telemetry@latest
go mod tidy
go mod vendor

For golang/go#65586,golang/go#58894

Change-Id: I631a424ebb726fb0999d4b5d1e6e7a288b475344
Cq-Include-Trybots: luci.golang.try:gotip-windows-386,gotip-windows-amd64-longtest,gotip-solaris-amd64,gotip-openbsd-amd64,gotip-wasip1-wasm_wazero,gotip-js-wasm
Reviewed-on: https://go-review.googlesource.com/c/go/+/562715
TryBot-Bypass: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Commit-Queue: Michael Matloob <matloob@golang.org>

14 months agoall: update golang.org/x/sys and vendor it
Michael Matloob [Thu, 8 Feb 2024 19:07:40 +0000 (14:07 -0500)]
all: update golang.org/x/sys and vendor it

Commands run (in both src and src/cmd):
go get golang.org/x/sys@latest
go mod tidy
go mod vendor

Change-Id: Ia041258c71ffb93428257b547411d359c62d9b70
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/562736
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agoencoding/xml: rewrite func procInst
Jes Cok [Wed, 7 Feb 2024 04:56:26 +0000 (04:56 +0000)]
encoding/xml: rewrite func procInst

This CL tries to make function procInst more exact,
also adds test cases, however, including tricky ones.

Change-Id: If421299fc84d136e56a25dba7a4919c4424702c8
GitHub-Last-Rev: b9a3192718ae5535d66fddd260c27b48d93b4af1
GitHub-Pull-Request: golang/go#64336
Reviewed-on: https://go-review.googlesource.com/c/go/+/544475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agogo/types, types2: factor out hasDots to check for ... arguments in calls (cleanup)
Robert Griesemer [Thu, 8 Feb 2024 19:14:35 +0000 (11:14 -0800)]
go/types, types2: factor out hasDots to check for ... arguments in calls (cleanup)

This further reduces the differences between go/types and types2.

Change-Id: Ie651c13dd12ecf043b8be92655d48d1ce32d4c5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/562777
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
14 months agogo/types, types2: consistently use ast/syntax.Unparen (cleanup)
Robert Griesemer [Thu, 8 Feb 2024 18:52:19 +0000 (10:52 -0800)]
go/types, types2: consistently use ast/syntax.Unparen (cleanup)

This further reduces the differences between go/types and types2.

Change-Id: I5ed0f621e1d64cd65b6a3e8eaca9926a1ccb5794
Reviewed-on: https://go-review.googlesource.com/c/go/+/562776
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
14 months agointernal/goroot: in IsStandardPackage check for go source files
Michael Matloob [Mon, 5 Feb 2024 17:20:45 +0000 (12:20 -0500)]
internal/goroot: in IsStandardPackage check for go source files

Be more strict in IsStandardPackage: before this change we'd just
check for the existence of the directory, but now we check to see that
there's at least one .go file in the directory.

Also update some comments in the modindex package to reflect the fact
that an IndexPackage might represent a directory that does not contain
any source files.

Fixes #65406
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest

Change-Id: I82f0c0e7bfcd5bb4df0195c4c8c7fc7c67fae53e
Reviewed-on: https://go-review.googlesource.com/c/go/+/561338
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agointernal/pprof: remove unused code
qiulaidongfeng [Thu, 8 Feb 2024 05:39:07 +0000 (05:39 +0000)]
internal/pprof: remove unused code

Change-Id: I47e98122668960321124e426b345d36f6916b738
GitHub-Last-Rev: b72c9ab33e1c9c49b3b44dc8782344d1ed481123
GitHub-Pull-Request: golang/go#65594
Reviewed-on: https://go-review.googlesource.com/c/go/+/562324
Reviewed-by: Michael Pratt <mpratt@google.com>
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>
14 months agocmd: vendor version error message changes from x/mod
Sam Thanawalla [Fri, 2 Feb 2024 19:20:06 +0000 (19:20 +0000)]
cmd: vendor version error message changes from x/mod

For golang/go#61888

Change-Id: I254fe559f25ac643e842a935954d18744ae87b0b
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560855
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
14 months agogo/types, types2: document deterministic method index order and add test
Robert Griesemer [Wed, 7 Feb 2024 21:58:38 +0000 (13:58 -0800)]
go/types, types2: document deterministic method index order and add test

Fixes #61298.

Change-Id: Ie2f930752867710884ace3990447866e785ebf1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/562347
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

14 months agotest/codegen: add float max/min codegen test
Meng Zhuo [Mon, 5 Feb 2024 12:49:16 +0000 (20:49 +0800)]
test/codegen: add float max/min codegen test

As CL 514596 and CL 514775 adds hardware implement of float
max/min, we should add codegen test for these two CL.

Change-Id: I347331032fe9f67a2e6fdb5d3cfe20203296b81c
Reviewed-on: https://go-review.googlesource.com/c/go/+/561295
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: M Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agocmd/link: use symbolic offset for ITab.Type
Keith Randall [Wed, 13 Dec 2023 05:25:14 +0000 (21:25 -0800)]
cmd/link: use symbolic offset for ITab.Type

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

14 months agocmd/compile: generate itabs using rttype mechanism
Keith Randall [Wed, 13 Dec 2023 05:03:09 +0000 (21:03 -0800)]
cmd/compile: generate itabs using rttype mechanism

Change-Id: I9a85704c57e978c8c6303b21da3e4627d3446f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/549455
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>
14 months agocmd/compile: move runtime.itab to internal/abi.ITab
Keith Randall [Wed, 13 Dec 2023 04:40:33 +0000 (20:40 -0800)]
cmd/compile: move runtime.itab to internal/abi.ITab

Change-Id: I44293452764dc4bc4de8d386153c6402a9cbe409
Reviewed-on: https://go-review.googlesource.com/c/go/+/549435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoslices: document that BinarySearch[Func] return earliest position
Ian Lance Taylor [Wed, 7 Feb 2024 21:36:46 +0000 (13:36 -0800)]
slices: document that BinarySearch[Func] return earliest position

Fixes #65446

Change-Id: I08dc512fb1f0101eb8aac8767cdf582360699559
Reviewed-on: https://go-review.googlesource.com/c/go/+/562345
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agonet: don't return errno from _C_res_nsearch
Ian Lance Taylor [Tue, 13 Dec 2022 22:51:17 +0000 (14:51 -0800)]
net: don't return errno from _C_res_nsearch

We ignore the value anyhow.

Change-Id: I1b1db7831c42bf852652236212812fd5cf258530
Reviewed-on: https://go-review.googlesource.com/c/go/+/457439
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agointernal/trace/v2: store stacks as PCs, not frames
Dominik Honnef [Sat, 20 Jan 2024 16:34:06 +0000 (17:34 +0100)]
internal/trace/v2: store stacks as PCs, not frames

Most stacks share some frames, especially prefixes, and deduplicating
them can save significant amounts of memory.

This will be especially true when we convert traces from the old to the
new format. Here, all stacks exist in a single generation and will be
live together.

For busy traces, such as one of running Staticcheck on std, with CPU
profiling enabled, this change saves ~400 MiB of memory.

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

14 months agocmd/internal/obj/ppc64: combine C_SBRA and C_LBRA optab classes
Paul E. Murphy [Thu, 26 Oct 2023 20:10:23 +0000 (15:10 -0500)]
cmd/internal/obj/ppc64: combine C_SBRA and C_LBRA optab classes

The assembler treats C_SBRA and C_LBRA optab classes identically,
combine them into one class to reduce the number of optab classes.

Likewise, C_LBRAPIC is renamed to C_BRAPIC for consistency with
the above change.

Change-Id: I47000e7273cb8f89a4d0621d71433ccbfb7afb70
Reviewed-on: https://go-review.googlesource.com/c/go/+/557916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agodoc/next: add release note for sync/Map.Clear
Nasfame [Tue, 6 Feb 2024 18:51:22 +0000 (18:51 +0000)]
doc/next: add release note for sync/Map.Clear

Fix https://go-review.git.corp.google.com/c/go/+/561456

For #61696

Change-Id: I573bd14cf0e5c41adcc8c2b9481e85c5792c2a82
GitHub-Last-Rev: c6fce6d25f8c071c92926ec3341855ad2303b876
GitHub-Pull-Request: golang/go#65534
Reviewed-on: https://go-review.googlesource.com/c/go/+/561755
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
14 months agoruntime,internal/syscall/windows: remove long path support check
qmuntal [Thu, 19 Oct 2023 16:06:27 +0000 (18:06 +0200)]
runtime,internal/syscall/windows: remove long path support check

The runtime currently enables long path support process-wide by updating
the process environment block (PEB). It then tries to create a file
using a long path to check if the PEB update made any difference.

There hasn't been any report that the PEB update was not effective,
and the check itself is quite tricky, so it's time to remove it.

While here, linkname `runtime.canUseLongPaths` to a variable in
internal/syscall/windows instead of the os package so it is easier to
consume from other packages.

Change-Id: I549380b7f2c242dc4db20d5be603840282de69b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/536495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agoos: support Stat and LStat for CON device on Windows
qmuntal [Fri, 2 Feb 2024 15:30:54 +0000 (16:30 +0100)]
os: support Stat and LStat for CON device on Windows

\\.\con and CON need to be opened with GENERIC_READ access, else
CreateFile will fail with ERROR_INVALID_PARAMETER.

Special-case ERROR_INVALID_PARAMETER in os.[L]Stat so it retries with
GENERIC_READ access.

Fixes #34900.

Change-Id: I5010e736d0189c8ada4fc0eca98d71a438c41426
Reviewed-on: https://go-review.googlesource.com/c/go/+/560755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
14 months agonet: support benchmark testing for sendfile on various platforms
Andy Pan [Sat, 18 Nov 2023 10:59:51 +0000 (18:59 +0800)]
net: support benchmark testing for sendfile on various platforms

When I introduced the benchmark test code for sendfile(2) in CL 425878,
I only did it on Linux while the sendfile system call is also available
on other Unix-like and Windows platforms, this CL will pick up where I left out.

goos: darwin
goarch: arm64
pkg: net
BenchmarkSendFile/file-to-tcp/1024-10      2240488        749.5 ns/op 1366.30 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/2048-10      1956669        850.4 ns/op 2408.38 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/4096-10       840103       1593 ns/op 2571.30 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/8192-10       449536       2881 ns/op 2843.35 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/16384-10      269974       6307 ns/op 2597.86 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/32768-10      137210      12646 ns/op 2591.09 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/65536-10       66642      24557 ns/op 2668.74 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/131072-10      37852      59550 ns/op 2201.03 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/262144-10      16288     107859 ns/op 2430.44 MB/s        2 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/524288-10      10540     249957 ns/op 2097.52 MB/s        3 B/op        0 allocs/op
BenchmarkSendFile/file-to-tcp/1048576-10      4982     419750 ns/op 2498.09 MB/s        6 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/1024-10     1180185       1187 ns/op  862.66 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/2048-10      523159       2294 ns/op  892.78 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/4096-10      238792       5223 ns/op  784.29 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/8192-10      116611      10929 ns/op  749.58 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/16384-10      57568      19870 ns/op  824.57 MB/s        0 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/32768-10      32280      33696 ns/op  972.47 MB/s        1 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/65536-10      17242      72122 ns/op  908.69 MB/s        1 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/131072-10      8350     159131 ns/op  823.67 MB/s        3 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/262144-10      3872     318000 ns/op  824.35 MB/s        8 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/524288-10      1766     600785 ns/op  872.67 MB/s       18 B/op        0 allocs/op
BenchmarkSendFile/file-to-unix/1048576-10            993    1138624 ns/op  920.92 MB/s       33 B/op        0 allocs/op

goos: linux
goarch: amd64
pkg: net
cpu: DO-Premium-AMD
BenchmarkSendFile/file-to-tcp/1024-8             1796002               716.3 ns/op      1429.59 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/2048-8             1196700               896.6 ns/op      2284.23 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/4096-8              923604              2385 ns/op        1717.48 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/8192-8              638967              9722 ns/op         842.60 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/16384-8             357740             18710 ns/op         875.67 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/32768-8             147417             17489 ns/op        1873.66 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/65536-8             113054             58818 ns/op        1114.21 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/131072-8             57981            113202 ns/op        1157.86 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/262144-8             26362            253376 ns/op        1034.61 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/524288-8             13767            442053 ns/op        1186.03 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-tcp/1048576-8             4906            829984 ns/op        1263.37 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/1024-8            2031691               628.9 ns/op      1628.36 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/2048-8            1294472               965.0 ns/op      2122.30 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/4096-8            1005753              1203 ns/op        3404.27 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/8192-8             865448              6412 ns/op        1277.65 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/16384-8            268946             12801 ns/op        1279.89 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/32768-8            153398              6691 ns/op        4897.23 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/65536-8             88911             11969 ns/op        5475.36 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/131072-8            48639            107538 ns/op        1218.84 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/262144-8            22720            203199 ns/op        1290.09 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/524288-8            12034             97126 ns/op        5398.03 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/file-to-unix/1048576-8            5374            202308 ns/op        5183.06 MB/s           0 B/op          0 allocs/op

Change-Id: Ib9507bd9837ecb38b1702afa89502da18806929c
Reviewed-on: https://go-review.googlesource.com/c/go/+/543276
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agoRevert "runtime: make netpollBreak entries identifiable on Windows"
Quim Muntal [Mon, 5 Feb 2024 14:15:26 +0000 (14:15 +0000)]
Revert "runtime: make netpollBreak entries identifiable on Windows"

This reverts commit 29746b4814bb76a3d5a36fc86967b358f11bbb93.

Reason for revert: Windows builders are flaky since this CL. Needs investigation. See https://build.golang.org/log/70d5d039b57b505870c9cc4e61de320df06a6f3a.

Change-Id: I8a5874bb057785497d03b9450819578de7faeb47
Reviewed-on: https://go-review.googlesource.com/c/go/+/561276
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agodoc: move Go 1.22 release notes to x/website
David Chase [Tue, 6 Feb 2024 17:48:15 +0000 (12:48 -0500)]
doc: move Go 1.22 release notes to x/website

Now that the development of the Go 1.22 release is almost done, its
release notes are moved to their eventual long-term home in x/website
in CL 562195. Delete the initial development copy here.

Change-Id: Ic8e44ee5d95ff121f96a53f6093fd8764abea004
Reviewed-on: https://go-review.googlesource.com/c/go/+/562155
Auto-Submit: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
14 months agospec: fix typo in year (it's 2024 now)
Robert Griesemer [Wed, 7 Feb 2024 17:12:05 +0000 (09:12 -0800)]
spec: fix typo in year (it's 2024 now)

While at it, set the date to the Go 1.22 release date.

Change-Id: I03872626e500433eb63786d24c67810c8c6289f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/562337
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>

14 months agogo/types, types2: optimize Named type method lookup
Robert Griesemer [Wed, 7 Feb 2024 05:57:06 +0000 (21:57 -0800)]
go/types, types2: optimize Named type method lookup

Because methods associated with named types are in the
same package as the type, when looking up a method we
don't need to check the package repeatedly.

Rename the global lookupMethod function to methodIndex,
to match the corresponding fieldIndex function (cleanup).

Implement Named.methodIndex, optimized for method lookup
on named types (optimization).

Adjust call sites.

Change-Id: Ifa05306126773262b1af3ce73365b5742b470eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/562297
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

14 months agogo/types, types2: better errors for non-existing fields or methods
Robert Griesemer [Wed, 31 Jan 2024 23:02:31 +0000 (15:02 -0800)]
go/types, types2: better errors for non-existing fields or methods

This CL improves the error messages reported when a field or method
name is used that doesn't exist. It brings the error messges on par
(or better) with the respective errors reported before Go 1.18 (i.e.
before switching to the new type checker):

Make case distinctions based on whether a field/method is exported
and how it is spelled. Factor out that logic into a new function
(lookupError) in a new file (errsupport.go), which is generated for
go/types. Use lookupError when reporting selector lookup errors
and missing struct field keys.

Add a comprehensive set of tests (lookup2.go) and spot tests for
the two cases brought up by the issue at hand.

Adjusted existing tests as needed.

Fixes #49736.

Change-Id: I2f439948dcd12f9bd1a258367862d8ff96e32305
Reviewed-on: https://go-review.googlesource.com/c/go/+/560055
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
14 months agocmd/go: avoid copying a binary to be exec'd in TestScript/gotoolchain_path
Bryan C. Mills [Thu, 1 Feb 2024 15:24:25 +0000 (10:24 -0500)]
cmd/go: avoid copying a binary to be exec'd in TestScript/gotoolchain_path

Runinng 'go build' writes the binary in a separate process, so avoids
the race described in #22315. However, the script engine's 'cp'
command currently executes in-process, so it does not avoid that bug
and may retain stale file descriptors when running tests in parallel.

Avoid the race in this particular test by giving the final binary
location in the '-o' argument instead of copying it there after the
fact.

Fixes #64019.

Change-Id: I96d276f33c09e39f465e9877356f1d8f2ae55062
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560415
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
14 months agocmd/compile: add missing colon in debug log
Michael Pratt [Tue, 6 Feb 2024 20:37:51 +0000 (15:37 -0500)]
cmd/compile: add missing colon in debug log

Change-Id: Id76f4688a2ac45c1616d5c03274eec5d2108e555
Reviewed-on: https://go-review.googlesource.com/c/go/+/562156
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agodog/go1.22: tweak coverage testing notes
Than McIntosh [Mon, 5 Feb 2024 16:58:35 +0000 (11:58 -0500)]
dog/go1.22: tweak coverage testing notes

Clarify the section in the "go" command notes that deals with the
changes to "go test -cover" for packages without tests, adding a note
that if a package has not tests and no executable code, you still get
a "package has no test files" diagnostic.

Fixes #65262.

Change-Id: Ie960871f9d5c1a1965090738644eace28fc3e156
Reviewed-on: https://go-review.googlesource.com/c/go/+/561337
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>
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
14 months agoarchive/zip: reduce memory held by Writer.Copy
Jonathan Amsterdam [Sat, 3 Feb 2024 16:48:50 +0000 (11:48 -0500)]
archive/zip: reduce memory held by Writer.Copy

Make a copy of the argument File's FileHeader, and pass a pointer
to the copy to CreateRaw.

Passing the pointer directly causes the entire `File` to be referenced
by the receiver. The `File` includes a reference to the `ReaderAt`
underlying the `Reader`, so all its memory, which may be the entire
contents of the archive, is prevented from being garbage-collected.

Also, explain the issue in the doc comment for CreateRaw. We
cannot change its behavior because someone may depend on the
preserving the identity of its argument pointer.

For #65499.

Change-Id: Ieb4963a0ea30539d597547d3511accbd8c6b5c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/560238
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
14 months agocmd/compile: delete unused code and fix typo in comment
Jun10ng [Mon, 5 Feb 2024 17:12:17 +0000 (17:12 +0000)]
cmd/compile: delete unused code and fix typo in comment

Change-Id: Ia1f1c7d5563a74950c47cf3ebdcb600b34c83e85
GitHub-Last-Rev: bd58214e5e66e32c0055936820b8f0adf7f388c6
GitHub-Pull-Request: golang/go#65527
Reviewed-on: https://go-review.googlesource.com/c/go/+/561355
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agodoc/next: add release note file for api/next file
Jonathan Amsterdam [Mon, 5 Feb 2024 18:44:05 +0000 (13:44 -0500)]
doc/next: add release note file for api/next file

Change-Id: I3003968d9d7e543c25d4b0ab1d1cd924a1efd3ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/561456
Auto-Submit: Jonathan Amsterdam <jba@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>

14 months agogo/types, types2: bail early if we want a type but don't have one
Robert Griesemer [Tue, 30 Jan 2024 00:34:16 +0000 (16:34 -0800)]
go/types, types2: bail early if we want a type but don't have one

If we do know whether we need a type or not, make use of the
information when we know that we don't have a type and bail out.

Fixes the issue at hand and also improves some other error messages
which now report that we don't have a type instead of reporting a cycle.

For #65344.

Change-Id: I11182efd452c485d89e6c09ead8a647ea05d7318
Reviewed-on: https://go-review.googlesource.com/c/go/+/559335
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
14 months agogo/types, types2: ensure that Alias.actual is set in NewAlias
Rob Findley [Fri, 2 Feb 2024 23:26:06 +0000 (18:26 -0500)]
go/types, types2: ensure that Alias.actual is set in NewAlias

Types returned by the go/types API must be immutable (or at least
concurrency safe), but NewAlias returned an alias without actual set.

Ensure that actual is set by unaliasing. Also make some superficial
simplifications to unalias, and avoid indirection where unnecessary.

Fixes golang/go#65455

Change-Id: Ic9a020da5accf9032056a924b65c9e9e08cb2e0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/560915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
14 months agocmd/compile: consistently use s.pp in genssa
Michael Pratt [Fri, 2 Feb 2024 18:30:15 +0000 (13:30 -0500)]
cmd/compile: consistently use s.pp in genssa

In genssa, s.pp == pp, so using either is equivalent, but use is
inconsistent. About half of the uses use s.pp and the other half use pp.

This gets confusing, especially when two different uses are right next
to each other, because it implies that these might be different.

Pick one and use it consistently.

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

14 months agocmd/relnote: fix API relnote check
Jonathan Amsterdam [Thu, 1 Feb 2024 21:00:51 +0000 (16:00 -0500)]
cmd/relnote: fix API relnote check

Fix the check for release note files that correspond to API files
to look in the right directory, doc/next/*stdlib/*minor. Previously
the test looked in doc/next.

Improve the error messages when the test fails to explain the problem
better and refer to further documentation.

(These changes are actually in the x/build repo; this CL vendors
the latest version.)

Lastly, re-enable the check.

For #64169.

Change-Id: I8bba845e9bd12afbe269ce42d6d4b17b1e3c0252
Reviewed-on: https://go-review.googlesource.com/c/go/+/560516
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

14 months agoruntime/internal/atomic: add loong64 operators for And/Or
Mauri de Souza Meneguzzo [Wed, 24 Jan 2024 10:19:30 +0000 (10:19 +0000)]
runtime/internal/atomic: add loong64 operators for And/Or

These primitives will be used by the new And/Or sync/atomic apis.

For #61395

Change-Id: I64b2e599e4f91412e0342aa01f5fd53271e9a333
GitHub-Last-Rev: 9755db5406b84dd84fa5432382bfabc801a34ed3
GitHub-Pull-Request: golang/go#63314
Reviewed-on: https://go-review.googlesource.com/c/go/+/531895
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
14 months agocmd/go: fix tests that fail when running a cross-compiled GOARCH
Bryan C. Mills [Thu, 1 Feb 2024 20:56:05 +0000 (15:56 -0500)]
cmd/go: fix tests that fail when running a cross-compiled GOARCH

In CL 356611 I changed cmd/go to run most of its tests (instead of
skipping them all) when cross-compiled, such as with GOARCH=386 on an
amd64 host. Unfortunately, since we don't have a CI builder that runs
long tests in a cross-compiled configuration, some of the tests have
rotted since then.

This fixes 'GOARCH=386 go test cmd/go' on my workstation.

For #64963.
Updates #53936.

Change-Id: If7f4bc8e8d1ace7d36010d7a1b652fc7b2ceb276
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560782
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
15 months agogo/internal/gccgoimporter: recognize "any" as a builtin type
Ian Lance Taylor [Mon, 23 Oct 2023 21:32:44 +0000 (14:32 -0700)]
go/internal/gccgoimporter: recognize "any" as a builtin type

In CL 536715 we're changing the gofrontend export data to report
"any" as a builtin type. This permits us to distinguish the builtin
type from some other package-level type "any". That requires an update
to this code.

Change-Id: I91d75a056a155fa9892c4b25ab396cb4d39cc8e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/537195
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile: avoid reading entire PGO profile just to check the header
Michael Pratt [Wed, 31 Jan 2024 22:56:47 +0000 (17:56 -0500)]
cmd/compile: avoid reading entire PGO profile just to check the header

isPreProfileFile reads the entire file into memory just to check the
first few bytes, and then throws it all away. We can avoid this by just
peeking at the beginning.

For #58102.

Change-Id: Id2c2844e5e44a2f3a9c7cdb9a027d94d26bdf71d
Reviewed-on: https://go-review.googlesource.com/c/go/+/560035
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>

15 months agoruntime: initialize crashFD to -1
Michael Pratt [Fri, 2 Feb 2024 18:00:02 +0000 (13:00 -0500)]
runtime: initialize crashFD to -1

crashFD defaults to the zero value of (surprise!) zero. Zero is a valid
FD, so on the first call to SetCrashOutput we actually close FD 0 since
it is a "valid" FD.

Initialize crashFD to -1, the sentinel for "no FD".

Change-Id: I3b108c60603f2b83b867cbe079f035c159b6a6ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/560776
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

15 months agolib/time: update to 2024a/2024a
Dmitri Shuralyov [Thu, 1 Feb 2024 21:55:50 +0000 (16:55 -0500)]
lib/time: update to 2024a/2024a

Commit generated by update.bash.

For #22487.

Change-Id: I1c46ec1f3a84e385f8eab2c4c9a14d3513a85a44
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560517
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoruntime/debug: add Example of SetCrashOutput in a crash monitor
Alan Donovan [Fri, 8 Dec 2023 22:03:46 +0000 (17:03 -0500)]
runtime/debug: add Example of SetCrashOutput in a crash monitor

Updates #42888

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

15 months agocmd/compile/internal: fix function names
cui fliter [Fri, 2 Feb 2024 09:30:03 +0000 (17:30 +0800)]
cmd/compile/internal: fix function names

Change-Id: Id9103aa4bda221f5eb34a0ede8676364c574b696
Reviewed-on: https://go-review.googlesource.com/c/go/+/560616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
15 months agocmd/link/internal/dwtest: fix inconsistent receiver name
cui fliter [Mon, 8 Jan 2024 13:55:30 +0000 (21:55 +0800)]
cmd/link/internal/dwtest: fix inconsistent receiver name

The DIEs method of Examiner is the only one with a receiver declared 'e'; all the rest have 'ex'. Fix it to be consistent.

Change-Id: I494a53cf3db5575d45831cab3cf612c20962f8fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/554575
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoRevert "cmd/go: add telemetry counters for flag names and subcommand"
Quim Muntal [Fri, 2 Feb 2024 13:30:55 +0000 (13:30 +0000)]
Revert "cmd/go: add telemetry counters for flag names and subcommand"

This reverts CL 559519.

Reason for revert: Broke windows/386. See https://build.golang.org/log/03594b706c425bd61fb3c65495aae6dd01b4a81b.

Fixes #65447.

Change-Id: I567bca0368168dbfb256fadba37bce3cd31aceb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/560655
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
15 months agocmd/go: add telemetry counters for flag names and subcommand
Michael Matloob [Tue, 30 Jan 2024 21:47:34 +0000 (16:47 -0500)]
cmd/go: add telemetry counters for flag names and subcommand

For #58894

Change-Id: I6b5d5b14be9858f5855eeac0110aa44e762cee03
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/559519
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd: update golang.org/x/telemetry to 1cb064e and vendor it
Michael Matloob [Wed, 31 Jan 2024 16:17:58 +0000 (11:17 -0500)]
cmd: update golang.org/x/telemetry to 1cb064e and vendor it

This brings in CL 559505 which adds a stub for counter.CountFlags so
it can be depended on and still build on Go 1.18 and earlier. This
will allow the go command to use counter.CountFlags and still be able
to build as the bootstrap command with an earlier version of Go.

For #58894

Change-Id: I31d5b96bd47eef2e407ef97e6146adece403f2c0
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/559795
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

15 months agocmd/go: fix build config before creating actions for 'go list -cover'
Ehden Sinai [Thu, 1 Feb 2024 18:38:56 +0000 (13:38 -0500)]
cmd/go: fix build config before creating actions for 'go list -cover'

When -covermode is set to atomic, instrumented packages need to import
sync/atomic. If this is not already imported by a package being
instrumented, the build needs to ensure that sync/atomic is compiled
whenever 'go list' is run in a way that triggers package builds.

The build config was already being made to ensure the import, but only
after the action graph had been created, so there was no guarantee that
sync/atomic would be built when needed.

Fixes #65264.

Change-Id: Ib3f1e102ce2ef554ea08330d9db69a8c98790ac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/560236
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
15 months agoruntime: traceAcquire and traceRelease across all P steals
Michael Anthony Knyszek [Thu, 1 Feb 2024 05:32:03 +0000 (05:32 +0000)]
runtime: traceAcquire and traceRelease across all P steals

Currently there are a few places where a P can get stolen where the
runtime doesn't traceAcquire and traceRelease across the steal itself.
What can happen then is the following scenario:
- Thread 1 enters a syscall and writes an event about it.
- Thread 2 steals Thread 1's P.
- Thread 1 exits the syscall and writes one or more events about it.
- Tracing ends (trace.gen is set to 0).
- Thread 2 checks to see if it should write an event for the P it just
  stole, sees that tracing is disabled, and doesn't.

This results in broken traces, because there's a missing ProcSteal
event. The parser always waits for a ProcSteal to advance a
GoSyscallEndBlocked event, and in this case, it never comes.

Fixes #65181.

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

15 months agoruntime: clear trace map without write barriers
Michael Anthony Knyszek [Thu, 1 Feb 2024 05:10:32 +0000 (05:10 +0000)]
runtime: clear trace map without write barriers

Currently the trace map is cleared with an assignment, but this ends up
invoking write barriers. Theoretically, write barriers could try to
write a trace event and eventually try to acquire the same lock. The
static lock ranking expresses this constraint.

This change replaces the assignment with a call to memclrNoHeapPointer
to clear the map, removing the write barriers.

Note that technically this problem is purely theoretical. The way the
trace maps are used today is such that reset is only ever called when
the tracer is no longer writing events that could emit data into a map.
Furthermore, reset is never called from an event-writing context.

Therefore another way to resolve this is to simply not hold the trace
map lock over the reset operation. However, this makes the trace map
implementation less robust because it needs to be used in a very
specific way. Furthermore, the rest of the trace map code avoids write
barriers already since its internal structures are all notinheap, so
it's actually more consistent to just avoid write barriers in the reset
method.

Fixes #56554.

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

15 months agoruntime: model wakeableSleep.lock in the race detector
Michael Anthony Knyszek [Thu, 1 Feb 2024 04:47:22 +0000 (04:47 +0000)]
runtime: model wakeableSleep.lock in the race detector

Currently the flight recorder tests are failing in race mode because the
race detector doesn't see s.lock, leading to false positives. This has
also appeared in the trace tests. Model the lock in the race detector.

Fixes #65207.
Fixes #65283.

Change-Id: I1e9a5c9606536f55fdfc46b5f8443e9c7213c23d
Reviewed-on: https://go-review.googlesource.com/c/go/+/560215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoruntime: fix trace EvGoStop Gosched reason to match function
Michael Anthony Knyszek [Thu, 21 Dec 2023 20:26:38 +0000 (20:26 +0000)]
runtime: fix trace EvGoStop Gosched reason to match function

Currently the stop reason for runtime.Gosched is labeled
"runtime.GoSched" which doesn't actually match the function name. Fix
the label to match the function name.

This change doesn't regenerate the internal/trace/v2 tests, because
regenerating the tests breaks summarization tests in internal/trace that
rely on very specific details in the example traces that aren't
guaranteed. Also, go122-gc-trace.test isn't generated at all, as it
turns out. I'll fix this all up in a follow-up CL. For now, just replace
runtime.GoSched with runtime.Gosched in the traces so we don't have a
problem later if a test wants to look for that string.

This change does regenerate the cmd/trace/v2 test, but it turns out the
cmd/trace/v2 tests are way too strict about network unblock events, and
3 usually pop up instead of 1 or 2, which is what the test expects.
AFAICT this looks plausible to me, so just lift the restriction on
"up to 2" events entirely.

Change-Id: Id7350132be19119c743c259f2f5250903bf41a04
Reviewed-on: https://go-review.googlesource.com/c/go/+/552275
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>