]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
14 months agocrypto/elliptic: deprecate unsafe APIs
Filippo Valsorda [Thu, 29 Dec 2022 14:38:18 +0000 (15:38 +0100)]
crypto/elliptic: deprecate unsafe APIs

Per the updated go.dev/wiki/Deprecated, those APIs replaced by
crypto/ecdh (added in Go 1.20) can now be marked as deprecated
in Go 1.21.

Updates #52221
Updates #34648

Change-Id: Id0e11d7faa3a58a1716ce1ec6e2fff97bab96259
Reviewed-on: https://go-review.googlesource.com/c/go/+/459977
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocrypto/rsa: deprecate multiprime RSA support
Filippo Valsorda [Thu, 29 Dec 2022 13:16:10 +0000 (14:16 +0100)]
crypto/rsa: deprecate multiprime RSA support

Fixes #56921

Change-Id: I03f9969a5146ab7becd983784d8cb5b23a3fbb18
Reviewed-on: https://go-review.googlesource.com/c/go/+/459976
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
14 months agoerrors: correct spelling
Vasili Revelas [Wed, 15 Mar 2023 11:22:04 +0000 (11:22 +0000)]
errors: correct spelling

Change-Id: Iba64f3d88b541c7fef15046720bfaba361291d94
GitHub-Last-Rev: 22cfd6382c42abfa7e1952cccf6e0ecb5990fdbf
GitHub-Pull-Request: golang/go#59047
Reviewed-on: https://go-review.googlesource.com/c/go/+/476395
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agointernal/fuzz: fix debug statement
Roland Shoemaker [Thu, 16 Mar 2023 01:16:57 +0000 (18:16 -0700)]
internal/fuzz: fix debug statement

Meant to check if the slice was empty, accidentally dumped the entire
slice to stdout...

Change-Id: I968cb2f20ffb006e4dcfea65a1bad794aac05d17
Reviewed-on: https://go-review.googlesource.com/c/go/+/476795
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>

14 months agointernal/fuzz: more debug logging
Roland Shoemaker [Wed, 15 Mar 2023 23:44:36 +0000 (16:44 -0700)]
internal/fuzz: more debug logging

Change-Id: I2c36baf423dde419aaa940ce9308088f3bf431f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/476718
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
14 months agoruntime: fix callee tracking in traceback printing
Austin Clements [Wed, 15 Mar 2023 18:27:10 +0000 (14:27 -0400)]
runtime: fix callee tracking in traceback printing

In CL 466099, we accidentally stopped tracking callees while unwinding
inlined frames during traceback printing. The effect is that if you
have a call stack like:

  f -> wrapper -> inlined into wrapper -> panic

when considering whether to print the frame for "wrapper", we'll think
that wrapper called panic, rather than the inlined function.

Fix this in the traceback code and add a test.

Change-Id: I30ec836cc316846ce93de94e28a650e23dca184e
Reviewed-on: https://go-review.googlesource.com/c/go/+/476579
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoos, internal/poll: don't use splice with tty
Ian Lance Taylor [Tue, 14 Mar 2023 21:49:16 +0000 (14:49 -0700)]
os, internal/poll: don't use splice with tty

Also don't try to wait for a non-pollable FD.

Fixes #59041

Change-Id: Ife469d8738f2cc27c0beba223bdc8f8bc757b2a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/476335
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agointernal/types/errors: add String method to Code
Robert Griesemer [Wed, 15 Mar 2023 20:15:28 +0000 (13:15 -0700)]
internal/types/errors: add String method to Code

Change-Id: Ia9fb7bdc39c1001c5cbb387d840ed923cf46b9e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/476715
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: 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>

14 months agosyscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupported
Tobias Klauser [Wed, 15 Mar 2023 18:26:33 +0000 (19:26 +0100)]
syscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupported

As suggested by Bryan. This should fix the failing
TestIPConnSpecificMethods on plan9 after CL 476217 was submitted.

For #41198

Change-Id: I18e87b3aa7c9f7d48a1bd9c2819340acd1d2ca4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/476578
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/asm: improve detector for incorrect R15 usage when dynamic linking
Keith Randall [Tue, 14 Mar 2023 18:34:51 +0000 (11:34 -0700)]
cmd/asm: improve detector for incorrect R15 usage when dynamic linking

Fixes #58632

Change-Id: Idb19af2ac693ea5920da57c1808f1bc02702929d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476295
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

14 months agointernal/fuzz: improve debugging messages
Roland Shoemaker [Wed, 15 Mar 2023 18:22:53 +0000 (11:22 -0700)]
internal/fuzz: improve debugging messages

Also enable debugging information in TestScript/test_fuzz_cov, which
hits a deadlock on builders, but I am unable to trigger locally. This
should make it somewhat easier to track down where the issue actually
is.

Updates #51484

Change-Id: I98124f862242798f2d9eba15cacefbd02924cfe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/476595
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agonet: correct TestIPConnSpecificMethods comment after CL 476217
Tobias Klauser [Wed, 15 Mar 2023 17:11:06 +0000 (18:11 +0100)]
net: correct TestIPConnSpecificMethods comment after CL 476217

As suggested by Cherry in
https://go-review.googlesource.com/c/go/+/476217/5/src/net/protoconn_test.go#171

Change-Id: I4ce3c034b44953720c543a87639fd173f86af7dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/476535
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: pass M to traceReleaseBuffer
Michael Pratt [Wed, 15 Mar 2023 17:58:44 +0000 (13:58 -0400)]
runtime: pass M to traceReleaseBuffer

This change is a no-op, but makes the acquire-release pair
traceAcquireBuffer / traceReleaseBuffer more explicit, since the former
does acquirem and the latter releasm.

Change-Id: If8a5b1ba8709bf6f39c8ff27b2d3e0c0b0da0e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/476575
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

14 months agonet/http: avoid making a request to a closed server in TestServerShutdown
Bryan C. Mills [Mon, 13 Mar 2023 21:36:36 +0000 (17:36 -0400)]
net/http: avoid making a request to a closed server in TestServerShutdown

As soon as the test server closes its listener, its port may be reused
for another test server. On some platforms port reuse takes a long
time, because they cycle through the available ports before reusing an
old one. However, other platforms reuse ports much more aggressively.
net/http shouldn't know or care which kind of platform it is on —
dialing wild connections is risky and can interfere with other tests
no matter what platform we do it on.

Instead of making the second request after the server has completely
shut down, we can start (and finish!) the entire request while we are
certain that the listener has been closed but the port is still open
serving an existing request. If everything synchronizes as we expect,
that should guarantee that the second request fails.

Fixes #56421.

Change-Id: I56add243bb9f76ee04ead8f643118f9448fd1280
Reviewed-on: https://go-review.googlesource.com/c/go/+/476036
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
14 months agocmd/link/internal/arm: fix off-by-1 in trampoline reachability computation
Than McIntosh [Mon, 13 Mar 2023 16:02:36 +0000 (12:02 -0400)]
cmd/link/internal/arm: fix off-by-1 in trampoline reachability computation

Tweak the code in trampoline generation that determines if a given
call branch will reach, changing the lower limit guard from "x <
-0x800000" to "x <= -0x800000". This is to resolve linking failures
when the computed displacement is exactly -0x800000, which results in
errors of the form

  .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079

when using the Gold linker, and

  ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt'

when using the bfd linker.

Fixes #59034.
Updates #58425.

Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/475957
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agosyscall: restore original NOFILE rlimit in child process
Ian Lance Taylor [Tue, 14 Mar 2023 03:59:14 +0000 (20:59 -0700)]
syscall: restore original NOFILE rlimit in child process

If we increased the NOFILE rlimit when starting the program,
restore the original rlimit when forking a child process.

For #46279

Change-Id: Ia5d2af9ef435e5932965c15eec2e428d2130d230
Reviewed-on: https://go-review.googlesource.com/c/go/+/476097
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

14 months agoos, syscall: move rlimit code to syscall
Ian Lance Taylor [Mon, 13 Mar 2023 22:20:11 +0000 (15:20 -0700)]
os, syscall: move rlimit code to syscall

In CL 393354 the os package was changed to raise the open file rlimit
at program start. That code is not inherently tied to the os package.
This CL moves it into the syscall package.

This is in preparation for future changes to restore the original
soft rlimit when exec'ing a new program.

For #46279

Change-Id: I981401b0345d017fd39fdd3dfbb58069be36c272
Reviewed-on: https://go-review.googlesource.com/c/go/+/476096
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agonet: skip tests if creating a socket is disallowed
Tobias Klauser [Wed, 15 Mar 2023 14:17:11 +0000 (15:17 +0100)]
net: skip tests if creating a socket is disallowed

In a container environment, creating a socket may be disallowed. Try to
detect these cases and skip the tests instead of failing them.

Fixes #58114

Change-Id: I681d19107e946d2508e2d1704956360f13c7335b
Reviewed-on: https://go-review.googlesource.com/c/go/+/476217
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agonet: remove max timeout from TestDialTimeout
Ian Lance Taylor [Wed, 15 Mar 2023 05:15:21 +0000 (22:15 -0700)]
net: remove max timeout from TestDialTimeout

Just rely on the testsuite timeout. If this hangs we will hopefully
get some real information.

Fixes #57475

Change-Id: I18dc5cae54ad5d2d8cc472056b8a3b4d5455c8b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/476356
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agoencoding/json: make use of Buffer.AvailableBuffer
Joe Tsai [Sat, 11 Mar 2023 20:03:28 +0000 (12:03 -0800)]
encoding/json: make use of Buffer.AvailableBuffer

Use the explicit API for acquiring an empty available buffer,
rather than the hack that's implemented in terms of Bytes and Len.

Change-Id: If286ed42693acd61ffe28dc849ed4b76c3ae4434
Reviewed-on: https://go-review.googlesource.com/c/go/+/476337
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agointernal/testenv, syscall: move isNotSupported to internal/testenv
Tobias Klauser [Wed, 15 Mar 2023 14:16:45 +0000 (15:16 +0100)]
internal/testenv, syscall: move isNotSupported to internal/testenv

This allows to use this helper function in packages other than syscall,
namely package net.

For #58114

Change-Id: I72c59ab013e9195801ff1315019ae1aef4396287
Reviewed-on: https://go-review.googlesource.com/c/go/+/476216
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agosyscall: handle errors.ErrUnsupported in isNotSupported
Tobias Klauser [Wed, 15 Mar 2023 14:15:04 +0000 (15:15 +0100)]
syscall: handle errors.ErrUnsupported in isNotSupported

Updates #41198

Change-Id: Ifed913f6088b77abc7a21d2a79168a20799f9d0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/475857
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

14 months agointernal/platform: add a function to report whether default builds are PIE
Bryan C. Mills [Fri, 10 Mar 2023 20:37:17 +0000 (15:37 -0500)]
internal/platform: add a function to report whether default builds are PIE

This consolidates a condition that was previously repeated (in
different approximations) in several different places in the code.

For #58807.

Change-Id: Idd308759f6262b1f5c61f79022965612319edf94
Reviewed-on: https://go-review.googlesource.com/c/go/+/475457
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agoruntime: add arg storage to ppc64le/linux runtime.sigprofNonGoWrapper frame
Paul E. Murphy [Tue, 14 Mar 2023 21:30:38 +0000 (16:30 -0500)]
runtime: add arg storage to ppc64le/linux runtime.sigprofNonGoWrapper frame

CL 475935 fixed the the ELFv2 ABI violations, but in the process created a
Go ABI violation by failing to allocate stack space for arguments.

Allocate this space while keeping the frame 16 byte aligned.

Updates #58953

Change-Id: I9942d9a433118b391ef8cd7bcea5808695cf94d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/476296
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/link/internal/loong64: use BREAK 0 as the code pad sequence
WANG Xuerui [Sat, 11 Mar 2023 14:38:01 +0000 (22:38 +0800)]
cmd/link/internal/loong64: use BREAK 0 as the code pad sequence

As the comment on CodePad goes, we "might want to pad with a trap
instruction to catch wayward programs". The current behavior of
zero-padding is equivalent to padding with an instruction of 0x00000000,
which is invalid according to the LoongArch manuals nevertheless, but
rumor has it that some early and/or engineering samples of Loongson
3A5000 recognized it (maybe behaving like NOP). It is better to avoid
undocumented behavior and ensure execution flow would not overflow the
pads.

Change-Id: I531b1eabeb355e9ad4a2d5340e61f2fe71349297
Reviewed-on: https://go-review.googlesource.com/c/go/+/475616
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64
WANG Xuerui [Sat, 11 Mar 2023 14:26:39 +0000 (22:26 +0800)]
cmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64

The canonical LoongArch NOP instruction form is "andi r0, r0, 0", as
described in the LoongArch Reference Manual Volume 1, Section 2.2.1.10.
We currently use NOR instead, which may or may not change anything (e.g.
performance on less capable micro-architectures) but is deviation from
upstream standards nevertheless. Fix them to use the explicit hardware
NOP which happens to be supported as `NOOP`.

Change-Id: I0a799a1da959e9c3b582feb88202df2bab0ab23a
Reviewed-on: https://go-review.googlesource.com/c/go/+/475615
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agoruntime: mark morestack_noctxt SPWRITE for linux/loong64
Guoqi Chen [Fri, 4 Nov 2022 05:27:23 +0000 (13:27 +0800)]
runtime: mark morestack_noctxt SPWRITE for linux/loong64

ref. CL 425396

Updates #54332.

Change-Id: I1a235b0cca4dbf79cf61cf5f40b594fc2d940857
Reviewed-on: https://go-review.googlesource.com/c/go/+/446895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
14 months agoruntime: refactor the linux/loong64 entrypoint
Guoqi Chen [Mon, 25 Jul 2022 07:30:53 +0000 (15:30 +0800)]
runtime: refactor the linux/loong64 entrypoint

Remove the meaningless jump, and add the missing NOFRAME flag to _rt0_loong64_linux.

Change-Id: I1aec68c556615b42042684bd176dfc2a8af094d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/420977
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
14 months agoos: don't hide all methods in recursive call to io.Copy
Ian Lance Taylor [Sat, 11 Mar 2023 04:41:14 +0000 (20:41 -0800)]
os: don't hide all methods in recursive call to io.Copy

In order to avoid a recursive call to ReadFrom, we were converting
a *File to an io.Writer. But all we really need to do is hide
the ReadFrom method. In particular, this gives us the option of
adding a WriteTo method.

For #58808

Change-Id: I20d3a45749d528c93c23267c467e607fc17dc83f
Reviewed-on: https://go-review.googlesource.com/c/go/+/475535
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/go/internal/modfetch: use errors.ErrUnsupported
Tobias Klauser [Tue, 14 Mar 2023 07:51:02 +0000 (08:51 +0100)]
cmd/go/internal/modfetch: use errors.ErrUnsupported

CL 473935 added errors.ErrUnsupported, let's use it.

Updates #41198

Change-Id: If6534d19cb31ca979ff00d529bd6bdfc964a616d
Reviewed-on: https://go-review.googlesource.com/c/go/+/476135
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

14 months agodatabase/sql: remove a distracting alloc, use atomic.Bool
Brad Fitzpatrick [Fri, 10 Mar 2023 17:38:49 +0000 (09:38 -0800)]
database/sql: remove a distracting alloc, use atomic.Bool

This removes an allocation in Conn.grabConn that, while not super
important, was distracting me when optimizing code elsewhere.

While here, convert an atomic that was forgotten when this package was
earlier updated to use the new Go 1.19 typed atomics.

Change-Id: I4666256b4c0512e2162bd485c389130699f9d5ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/475415
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

14 months agoruntime,runtime/cgo: fix tsan/pprof/cgo issues
Paul E. Murphy [Fri, 10 Mar 2023 22:05:47 +0000 (16:05 -0600)]
runtime,runtime/cgo: fix tsan/pprof/cgo issues

The tsan13 test highlighted a few bugs.

The first being runtime.sigprofNonGoWrapper was being
called from C code and violating the C ABI.

The second was a missed tsan acquire/release after
thread creation.

The third was runtime.cgoSigtramp violating ELFv2
ABI constraints when loading g. It is reworked to
avoid clobbering R30 and R31 via runtime.load_g.

Change-Id: Ib2d98047fa1b4e72b8045767e86457a8ddfe492e
Reviewed-on: https://go-review.googlesource.com/c/go/+/475935
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/go,cmd/link: prefer external linking when strange cgo flags seen
Than McIntosh [Fri, 10 Mar 2023 15:29:38 +0000 (10:29 -0500)]
cmd/go,cmd/link: prefer external linking when strange cgo flags seen

This patch changes the Go command to examine the set of compiler
flags feeding into the C compiler when packages that use cgo are built.
If any of a specific set of strange/dangerous flags are in use,
then the Go command generates a token file ("preferlinkext") and
embeds it into the compiled package's archive.

When the Go linker reads the archives of the packages feeding into the
link and detects a "preferlinkext" token, it will then use external
linking for the program by default (although this default can be
overridden with an explicit "-linkmode" flag).

The intent here is to avoid having to teach the Go linker's host object
reader to grok/understand the various odd symbols/sections/types that
can result from boutique flag use, but rather to just boot the objects
in question over to the C linker instead.

Updates #58619.
Updates #58620.
Updates #58848.

Change-Id: I56382dd305de8dac3841a7a7e664277826061eaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/475375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/link: store COFF symbol complex type in the LSB instead of the MSB
qmuntal [Mon, 13 Mar 2023 13:34:38 +0000 (14:34 +0100)]
cmd/link: store COFF symbol complex type in the LSB instead of the MSB

Microsoft's PE documentation is contradictory. It says that the
symbol's complex type [1] is stored in the pesym.Type most significant
byte (MSB), but MSVC, LLVM, and mingw store it in the 4 high bits of
the less significant byte (LSB). dumpbin understands both encoding.

Previous to CL 475355 the Go compiler mixed MSB and LSB encoding.
CL 475355 updated to compiler to use the MSB, but this causes problems
with mingw, which emits a warning when MSB is used.

For reference, LLVM also hit this issue long time ago:
https://github.com/llvm/llvm-project/issues/8692

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I7e750bde9c20e2c4c1c023203d7abd6fb26d9d30
Reviewed-on: https://go-review.googlesource.com/c/go/+/475855
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agocmd/go: restore 'extend path shortening to all paths in messages'
David Chase [Sun, 12 Mar 2023 17:19:57 +0000 (18:19 +0100)]
cmd/go: restore 'extend path shortening to all paths in messages'

The problem requiring a revert was creation (somehow) of /-containing
paths in compiler messages on Windows.  The new code deals with this
existing-but-unexpected behavior.

original was CL 465805
revert was CL 473795

this is the original, plus a correction for unexpected paths on Windows.

Change-Id: I786e875e704c2d7018c8248960f2ff7188cac3ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/474015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: David Chase <drchase@google.com>

14 months agoruntime/internal/sys: remove 386 assembly code
Wayne Zuo [Sun, 12 Mar 2023 08:02:19 +0000 (16:02 +0800)]
runtime/internal/sys: remove 386 assembly code

Change-Id: Ia4f8638d626c30b91729caa0c58a96451c627f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/475736
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/compile: instrinsify TrailingZeros{8,32,64} for 386
Wayne Zuo [Sun, 12 Mar 2023 07:34:20 +0000 (15:34 +0800)]
cmd/compile: instrinsify TrailingZeros{8,32,64} for 386

This CL add support for instrinsifying the TrialingZeros{8,32,64}
functions for 386 architecture. We need handle the case when the input
is 0, which could lead to undefined output from the BSFL instruction.

Next CL will remove the assembly code in runtime/internal/sys package.

Change-Id: Ic168edf68e81bf69a536102100fdd3f56f0f4a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475735
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoregexp/syntax: test for lowercase letters first in IsWordChar
Ludi Rehak [Wed, 4 May 2022 22:22:21 +0000 (15:22 -0700)]
regexp/syntax: test for lowercase letters first in IsWordChar

Lowercase letters occur more frequently than uppercase letters
in English text.  In IsWordChar, evaluate the most common case
(lowercase letters) first to minimize the expected value of its
execution time. Code clarity does not suffer by rearranging the
order of the checks.

Add a benchmark on a sentence demonstrating the performance
improvement.

name           old time/op  new time/op  delta
IsWordChar-10   122ns ± 0%   114ns ± 1%  -6.68%  (p=0.000 n=8+10)

Change-Id: Ieee8126a4bd8ee8703905b4f75724623029f6fa2
Reviewed-on: https://go-review.googlesource.com/c/go/+/404100
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: thepudds <thepudds1460@gmail.com>

14 months agoruntime/debug: replace "GOARM64" with "GOARM" in docs
Tianon Gravi [Mon, 13 Mar 2023 21:32:49 +0000 (21:32 +0000)]
runtime/debug: replace "GOARM64" with "GOARM" in docs

The former does not exist (yet) but the latter very much exists and is in active use.

Change-Id: Ic8812b98a10f01061a211a0de4caa9e9cfff36fa
GitHub-Last-Rev: 0dab9f524c778b176e4e4b3652f53ea5e2873d26
GitHub-Pull-Request: golang/go#59014
Reviewed-on: https://go-review.googlesource.com/c/go/+/476016
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/dist: add needCC comment, fix needCC
Russ Cox [Mon, 13 Mar 2023 17:14:35 +0000 (13:14 -0400)]
cmd/dist: add needCC comment, fix needCC

This was missed in CL 475377.

Change-Id: I4e8c4c0459a92029a3f448c1e4172d3343280c57
Reviewed-on: https://go-review.googlesource.com/c/go/+/475958
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agocmd/compile: tighten for huge functions in -N mode
Cherry Mui [Fri, 10 Mar 2023 21:28:57 +0000 (16:28 -0500)]
cmd/compile: tighten for huge functions in -N mode

Currently, in -N mode we skip the tighten pass. However, for very
large functions, many values live across blocks can cause
pathological behavior in the register allocator, which could use
a huge amount of memory or cause the program to hang. For
functions that large, debugging using a debugger is unlikely to be
very useful (the function is probably generated anyway). So we do
a little optimization to make fewer values live across blocks and
make it easier for the compiler.

Fixes #52180.

Change-Id: I355fe31bb87ea5d0870bb52dd06405dd5d791dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/475339
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
14 months agotesting: add Testing function
Ian Lance Taylor [Thu, 9 Mar 2023 00:16:59 +0000 (16:16 -0800)]
testing: add Testing function

The Testing function reports whether the program is a test created
by "go test".

Fixes #52600

Change-Id: Ie0fff7c7dfdfdf997c18b4b6112632600b327cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/475496
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

14 months agonet/http: remove more arbitrary timeouts from server tests
Bryan C. Mills [Mon, 13 Mar 2023 20:16:32 +0000 (16:16 -0400)]
net/http: remove more arbitrary timeouts from server tests

This change eliminates the easy, arbitrary timouts that should
never happen. It leaves in place a couple of more complicated ones
that will probably need retry loops for robustness.

For #49336.
For #36179.

Change-Id: I657ef223a66461413a915da5ce9150f49acec04a
Reviewed-on: https://go-review.googlesource.com/c/go/+/476035
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
14 months agocrypto/x509: surface ReasonCode in RevocationList API
Aaron Gable [Wed, 15 Feb 2023 22:25:34 +0000 (14:25 -0800)]
crypto/x509: surface ReasonCode in RevocationList API

Creates x509.RevocationListEntry, a new type representing a single
revoked certificate entry in a CRL. Like the existing Certificate and
RevocationList types, this new type has a field for its Raw bytes, and
exposes its mostly-commonly-used extension (ReasonCode) as a top-level
field. This provides more functionality to the user than the existing
pkix.RevokedCertificate type.

Adds a RevokedCertificateEntries field which is a []RevocationListEntry
to RevocationList. This field deprecates the RevokedCertificates field.
When the RevokedCertificates field is removed in a future release, this
will remove one of the last places where a pkix type is directly exposed
in the x509 package API.

Updates the ParseRevocationList function to populate both fields for
now, and updates the CreateRevocationList function to prefer the new
field if it is populated, but use the deprecated field if not. Finally,
also updates the x509 unit tests to use the new .ReasonCode field in
most cases.

Fixes #53573

Change-Id: Ia6de171802a5bd251938366508532e806772d7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/468875
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
14 months agosyscall: use clone3 syscall with CLONE_NEWTIME
Tobias Klauser [Wed, 8 Mar 2023 11:49:10 +0000 (12:49 +0100)]
syscall: use clone3 syscall with CLONE_NEWTIME

CLONE_NEWTIME can only be used with the clone3 and unshare system calls,
see https://github.com/torvalds/linux/commit/769071ac9f20b6a447410c7eaa55d1a5233ef40c:

> All available clone flags have been used, so CLONE_NEWTIME uses the highest
> bit of CSIGNAL. It means that it can be used only with the unshare() and
> the clone3() system calls.

The clone3 syscall was added in Linux kernel version 5.3 and
CLONE_NEWTIME was added in version 5.6. However, it was non-functional
until version 6.3 (and stable versions with the corresponding fix [1]).

[1] https://lore.kernel.org/lkml/20230308105126.10107-1-tklauser@distanz.ch/

In case CLONE_NEWTIME is set in SysProcAttr.Cloneflags on an unsupported
kernel version, the fork/exec call will fail.

Fixes #49779

Change-Id: Ic3ecfc2b601bafaab12b1805d7f9512955a8c7e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/474356
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocrypto/internal/nistec: refactor scalar multiplication
Filippo Valsorda [Mon, 13 Feb 2023 19:49:38 +0000 (20:49 +0100)]
crypto/internal/nistec: refactor scalar multiplication

The assumptions of some of the assembly functions were still scarcely
documented and even disregarded: p256ScalarMult was relying on the fact
that the "undefined behavior" of p256PointAddAsm with regards to
infinity inputs was returning the infinity.

Aside from expanding comments, moving the bit window massaging into a
more easily understood p256OrdRsh function, and fixing the above, this
change folds the last iteration of p256ScalarMult into the loop to
reduce special cases and inverts the iteration order of p256BaseMult so
it matches p256ScalarMult for ease of comparison.

Updates #58647

Change-Id: Ie5712ea778aadbe5adcdb478d111c2527e83caa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/471256
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

14 months agotime: fix timezone lookup logic for non-DST zones
Geon Kim [Sat, 11 Mar 2023 00:57:57 +0000 (00:57 +0000)]
time: fix timezone lookup logic for non-DST zones

This change fixes time.LoadLocationFromTZData and time.Location.lookup logic if the given time is after the last transition and the extend string doesn't have the DST rule.

Fixes #58682

Change-Id: Ie34a6d658d14c2b33098b29ab83c041ef0d34266
GitHub-Last-Rev: f6681eb44c0ea0772004e56eb68fcbd9023d971e
GitHub-Pull-Request: golang/go#58684
Reviewed-on: https://go-review.googlesource.com/c/go/+/471020
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

14 months agobytes: add Buffer.Available and Buffer.AvailableBuffer
Joe Tsai [Mon, 6 Feb 2023 19:37:39 +0000 (11:37 -0800)]
bytes: add Buffer.Available and Buffer.AvailableBuffer

This adds a new Buffer.AvailableBuffer method that returns
an empty buffer with a possibly non-empty capacity for use
with append-like APIs.

The typical usage pattern is something like:

b := bb.AvailableBuffer()
b = appendValue(b, v)
bb.Write(b)

It allows logic combining append-like APIs with Buffer
to avoid needing to allocate and manage buffers themselves and
allows the append-like APIs to directly write into the Buffer.

The Buffer.Write method uses the builtin copy function,
which avoids copying bytes if the source and destination are identical.
Thus, Buffer.Write is a constant-time call for this pattern.

Performance:

BenchmarkBufferAppendNoCopy  2.909 ns/op  5766942167.24 MB/s

This benchmark should only be testing the cost of bookkeeping
and never the copying of the input slice.
Thus, the MB/s should be orders of magnitude faster than RAM.

Fixes #53685

Change-Id: I0b41e54361339df309db8d03527689b123f99085
Reviewed-on: https://go-review.googlesource.com/c/go/+/474635
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agocmd/go: unify the format of the go help xxx command
cui fliter [Wed, 8 Mar 2023 11:00:51 +0000 (19:00 +0800)]
cmd/go: unify the format of the go help xxx command

Fixes #58871
Updates #58871

Change-Id: I947b71083e9559859b3ae6e17b5daad03a976707
Reviewed-on: https://go-review.googlesource.com/c/go/+/474375
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

14 months agoall: fix some problematic comments
cui fliter [Sat, 11 Mar 2023 02:33:57 +0000 (10:33 +0800)]
all: fix some problematic comments

Change-Id: Ia110d19fe5ff3adc8bbf86dd2112f9702164d495
Reviewed-on: https://go-review.googlesource.com/c/go/+/475515
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

14 months agocmd/dist: omit DWARF in build release toolchain binaries
Russ Cox [Wed, 8 Mar 2023 19:48:41 +0000 (14:48 -0500)]
cmd/dist: omit DWARF in build release toolchain binaries

The vast majority of users of Go toolchains have no need for
binaries like the go command and compiler to include DWARF
information, and the DWARF information is 34% of the size of
the overall Go toolchain zip files (14% when the toolchain is
unzipped on disk, because other parts get bigger).

To save network and disk, disable DWARF in build release binaries.
DWARF remains enabled when developing in the main branch
(signaled by no VERSION file existing), for better debuggability
when actually working on the compiler and go command.

Note that removing DWARF does not break the backtraces shown
when a binary panics, nor does it break other uses of stack traces
from within a Go program, such as runtime.Callers.

To build a release toolchain with DWARF included, people can use

GO_LDFLAGS=-w=0 ./make.bash

Change-Id: Ib0bbe1446adca4599066b2fb2f2734e6825c1106
Reviewed-on: https://go-review.googlesource.com/c/go/+/475378
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/dist: reproducibility fixes
Russ Cox [Sun, 5 Mar 2023 18:05:25 +0000 (13:05 -0500)]
cmd/dist: reproducibility fixes

Fix a few lingering reproducibility problems.

- Do not set CC during go install std if it is unset,
  so that the automatic disabling of cgo in cmd/go can run.

- Since CC is not necessary, remove code insisting on it.

- Use a fixed quoting algorithm instead of %q from the
  bootstrap toolchain, which can differ from release to release.

- Remove go_bootstrap tool successfully on Windows.

For #24904.

Change-Id: I5c29ba6a8592e93bfab37f123b69f55c02f12ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475377
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agoruntime: remove NOFRAME from asmcgocall, systemstack and mcall
qmuntal [Tue, 28 Feb 2023 18:30:32 +0000 (19:30 +0100)]
runtime: remove NOFRAME from asmcgocall, systemstack and mcall

This CL removes the NOFRAME flag from runtime.asmcgocall,
runtime.systemstack and runtime.mcall so the compiler can place
the frame pointer on the stack.

This will help unwinding cgo stack frames, and might be all what's
needed for tools that only use the frame pointer to unwind the stack.
That's not the case for gdb, which uses DWARF CFI, and windbg,
which uses SEH. Yet, having the frame pointer correctly set lays
the foundation for supporting cgo unwinding with DWARF CFI and SEH.

Updates #58378

Change-Id: I7655363b3fb619acccd9d5a7f0e3d3dec953cd52
Reviewed-on: https://go-review.googlesource.com/c/go/+/472195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: implement high resolution timer on windows arm/arm64
qmuntal [Fri, 24 Feb 2023 17:15:32 +0000 (18:15 +0100)]
runtime: implement high resolution timer on windows arm/arm64

This CL moves the usleep2HighRes from assembly to good old Go.
This is safe because since CL 288793 usleep is always called with
a g, else one wold have to call usleep_no_g. This condition was
not enforced when high resolution timers were first implemented
on Windows (CL 248699), so the implementation was done in assembly.

Other than removing a bunch of obscure assembly code, this CL makes
high resolution timers work on windows arm/arm64 by free, as the
system calls are the same in all windows platforms.

Change-Id: I41ecf78026fd7e11e85258a411ae074a77e8c7fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/471142
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

14 months agocmd/internal/obj/loong64: remove invalid branch delay slots
Guoqi Chen [Wed, 3 Aug 2022 09:45:02 +0000 (17:45 +0800)]
cmd/internal/obj/loong64: remove invalid branch delay slots

Change-Id: I222717771019f7aefa547971b2d94ef4677a42c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/420979
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
14 months agoos: correct func name in WriteFile godoc comment
Tobias Klauser [Wed, 8 Mar 2023 10:30:16 +0000 (11:30 +0100)]
os: correct func name in WriteFile godoc comment

Change-Id: Ideb70ce04f49ff676c20c2e1f0b43f1d7a6665dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/474355
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

14 months agoerrors: add ErrUnsupported
Andy Pan [Thu, 2 Mar 2023 03:57:24 +0000 (11:57 +0800)]
errors: add ErrUnsupported

Fixes #41198

Change-Id: Ib33a11d0eb311f8e2b81de24d11df49e00b2fc81
Reviewed-on: https://go-review.googlesource.com/c/go/+/473935
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/link: define correct complex types values for COFF symbols
qmuntal [Fri, 10 Mar 2023 15:19:58 +0000 (16:19 +0100)]
cmd/link: define correct complex types values for COFF symbols

This CL updates IMAGE_SYM_DTYPE_FUNCTION and IMAGE_SYM_DTYPE_ARRAY
definition and usage so their value can be set to what's defined in
the Microsoft PE docs [1], fixing a long-standing TODO.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I93c19eb78e8a770e8c72245fe9495647e2c5ae5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475355
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoos: skip TestExecutableDeleted earlier when 'go build' is not supported
Bryan C. Mills [Fri, 10 Mar 2023 19:21:01 +0000 (14:21 -0500)]
os: skip TestExecutableDeleted earlier when 'go build' is not supported

The test unconditionally calls testenv.GoToolPath, which will skip the
test anyway. Moving the skip earlier gets this test out of goroutine
dumps if the test process fails or times out, making it easier to
diagnose failures in the remaining tests.

Change-Id: Ibd39546708a83b6f15616b2c4ae7af420e2401f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/475455
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agoall: skip tests that fail on android/arm64
Bryan C. Mills [Wed, 1 Mar 2023 13:45:18 +0000 (13:45 +0000)]
all: skip tests that fail on android/arm64

Many of the tests skipped platforms that build PIE binaries by
default, but (still) lack a central function to report which platforms
those are.

Some of the tests assumed (but did not check for) internal linking
support, or invoked `go tool link` directly without properly
configuring the external linker.

A few of the tests seem to be triggering latent bugs in the linker.

For #58806.
For #58807.
For #58794.

Change-Id: Ie4d06b1597f404590ad2abf978d4c363647407ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/472455
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/compile: pass type checker error codes in the compiler
Robert Griesemer [Fri, 10 Mar 2023 00:21:22 +0000 (16:21 -0800)]
cmd/compile: pass type checker error codes in the compiler

Pass type checker error codes to base.ErrorfAt function calls
in the compiler (but don't do anything yet with the code).

Also, provide error codes to base.ErrorfAt calls in the
compiler as needed.

This opens the door towards reporting the error code and/or
providing a link/reference to more detailed explanations
(see internal/types/errors/codes.go).

Change-Id: I0ff9368d8163499ffdac6adfe8331fdc4a19b4b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475198
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: delete gentraceback
Austin Clements [Tue, 14 Feb 2023 18:54:29 +0000 (13:54 -0500)]
runtime: delete gentraceback

Printing is the only remaining functionality of gentraceback. Move
this into the traceback printing code and eliminate gentraceback. This
lets us simplify the logic, which fixes at least one minor bug:
previously, if inline unwinding pushed the total printed count over
_TracebackMaxFrames, we would print extra frames and then fail to
print "additional frames elided".

The cumulative performance effect of the series of changes starting
with "add a benchmark of Callers" (CL 472956) is:

goos: linux
goarch: amd64
pkg: runtime
cpu: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
                       │  baseline   │              unwinder               │
                       │   sec/op    │   sec/op     vs base                │
Callers/cached-48        1.464µ ± 1%   1.684µ ± 1%  +15.03% (p=0.000 n=20)
Callers/inlined-48       1.391µ ± 1%   1.536µ ± 1%  +10.42% (p=0.000 n=20)
Callers/no-cache-48      10.50µ ± 1%   11.11µ ± 0%   +5.82% (p=0.000 n=20)
StackCopyPtr-48          88.74m ± 1%   81.22m ± 2%   -8.48% (p=0.000 n=20)
StackCopy-48             80.90m ± 1%   70.56m ± 1%  -12.78% (p=0.000 n=20)
StackCopyNoCache-48      2.458m ± 1%   2.209m ± 1%  -10.15% (p=0.000 n=20)
StackCopyWithStkobj-48   26.81m ± 1%   25.66m ± 1%   -4.28% (p=0.000 n=20)
geomean                  518.8µ        512.9µ        -1.14%

The performance impact of intermediate CLs in this sequence varies a
lot as we went through many refactorings. The slowdown in Callers
comes primarily from the introduction of unwinder because that doesn't
get inlined and results in somewhat worse code generation in code
that's extremely hot in those microbenchmarks. The performance gains
on stack copying come mostly from replacing callbacks with direct use
of the unwinder.

Updates #54466.
Fixes #32383.

Change-Id: I4970603b2861633eecec30545e852688bc7cc9a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/468301
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: new API for filling PC traceback buffers
Austin Clements [Tue, 14 Feb 2023 17:25:11 +0000 (12:25 -0500)]
runtime: new API for filling PC traceback buffers

Currently, filling PC traceback buffers is one of the jobs of
gentraceback. This moves it into a new function, tracebackPCs, with a
simple API built around unwinder, and changes all callers to use this
new API.

Updates #54466.

Change-Id: Id2038bded81bf533a5a4e71178a7c014904d938c
Reviewed-on: https://go-review.googlesource.com/c/go/+/468300
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

14 months agoruntime: move cgo traceback into unwinder
Austin Clements [Tue, 14 Feb 2023 16:50:30 +0000 (11:50 -0500)]
runtime: move cgo traceback into unwinder

Currently, gentraceback's loop ends with a call to tracebackCgoContext
to process cgo frames. This requires spreading various parts of the
printing and pcbuf logic across these two functions.

Clean this up by moving cgo unwinding into unwinder and then lifting
the printing and pcbuf logic from tracebackCgoContext into
gentraceback along with the other printing and pcbuf logic.

Updates #54466.

Change-Id: Ic71afaa5ae110c0ea5be9409e267e4284e36a8c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/468299
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: simplify traceback PC back-up logic
Austin Clements [Mon, 13 Feb 2023 22:57:26 +0000 (17:57 -0500)]
runtime: simplify traceback PC back-up logic

Updates #54466.

Change-Id: If070cf3f484e3e02b8e586bff466e0018b1a1845
Reviewed-on: https://go-review.googlesource.com/c/go/+/468298
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: replace all callback uses of gentraceback with unwinder
Austin Clements [Mon, 13 Feb 2023 21:20:54 +0000 (16:20 -0500)]
runtime: replace all callback uses of gentraceback with unwinder

This is a really nice simplification for all of these call sites.

It also achieves a nice performance improvement for stack copying:

goos: linux
goarch: amd64
pkg: runtime
cpu: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
                       │   before    │                after                │
                       │   sec/op    │   sec/op     vs base                │
StackCopyPtr-48          89.25m ± 1%   79.78m ± 1%  -10.62% (p=0.000 n=20)
StackCopy-48             83.48m ± 2%   71.88m ± 1%  -13.90% (p=0.000 n=20)
StackCopyNoCache-48      2.504m ± 2%   2.195m ± 1%  -12.32% (p=0.000 n=20)
StackCopyWithStkobj-48   21.66m ± 1%   21.02m ± 2%   -2.95% (p=0.000 n=20)
geomean                  25.21m        22.68m       -10.04%

Updates #54466.

Change-Id: I31715b7b6efd65726940041d3052bb1c0a1186f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/468297
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: make unsafe.Slice usable from nowritebarrierrec
Austin Clements [Mon, 13 Feb 2023 20:55:21 +0000 (15:55 -0500)]
runtime: make unsafe.Slice usable from nowritebarrierrec

Many compiler-generated panics are dynamically changed to a "throw"
when they happen in the runtime. One effect of this is that they are
allowed in nowritebarrierrec contexts. Currently, the unsafe.Slice
panics don't have this treatment.

We're about to expose more code that uses unsafe.Slice to the write
barrier checker (it's actually already there and it just can't see
through an indirect call), so give these panics the dynamic check.

Very indirectly updates #54466.

Change-Id: I65cb96fa17eb751041e4fa25a1c1bd03246c82ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/468296
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: implement traceback iterator
Austin Clements [Thu, 14 Jul 2022 16:22:24 +0000 (12:22 -0400)]
runtime: implement traceback iterator

Currently, all stack walking logic is in one venerable, large, and
very, very complicated function: runtime.gentraceback. This function
has three distinct operating modes: printing, populating a PC buffer,
or invoking a callback. And it has three different modes of unwinding:
physical Go frames, inlined Go frames, and cgo frames. It also has
several flags. All of this logic is very interwoven.

This CL reimplements the monolithic gentraceback function as an
"unwinder" type with an iterator API. It moves all of the logic for
stack walking into this new type, and gentraceback is now a
much-simplified wrapper around the new unwinder type that still
implements printing, populating a PC buffer, and invoking a callback.
Follow-up CLs will replace uses of gentraceback with direct uses of
unwinder.

Exposing traceback functionality as an iterator API will enable a lot
of follow-up work such as simplifying the open-coded defer
implementation (which should in turn help with #26813 and #37233),
printing the bottom of deep stacks (#7181), and eliminating the small
limit on CPU stacks in profiles (#56029).

Fixes #54466.

Change-Id: I36e046dc423c9429c4f286d47162af61aff49a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458218
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

14 months agoruntime: replace cgoCtxt slice with index in traceback
Austin Clements [Thu, 9 Feb 2023 19:40:05 +0000 (14:40 -0500)]
runtime: replace cgoCtxt slice with index in traceback

Currently, gentraceback consumes the gp.cgoCtxt slice by copying the
slice header and then sub-slicing it as it unwinds. The code for this
is nice and clear, but we're about to lift this state into a structure
and mutating it is going to introduce write barriers that are
disallowed in gentraceback.

This CL replaces the mutable slice header with an index into
gp.cgoCtxt.

For #54466.

Change-Id: I6b701bb67d657290a784baaca34ed02d8247ede2
Reviewed-on: https://go-review.googlesource.com/c/go/+/466863
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: skip TestTracebackInlined if inlining is disabled
Austin Clements [Fri, 10 Mar 2023 17:33:24 +0000 (12:33 -0500)]
runtime: skip TestTracebackInlined if inlining is disabled

This should fix the noopt builders.

Change-Id: I49aa374f4d372803599cd2d2a7a29833b379ce1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475376
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Austin Clements <austin@google.com>

14 months agoruntime: use inlineUnwinder
Austin Clements [Mon, 6 Feb 2023 02:37:07 +0000 (21:37 -0500)]
runtime: use inlineUnwinder

This converts all places in the runtime that perform inline expansion
to use the new inlineUnwinder abstraction.

For #54466.

Change-Id: I48d996fb6263ed5225bd21d30914a27ae434528d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466099
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: add tests of printing inlined frames in tracebacks
Austin Clements [Mon, 6 Feb 2023 19:13:54 +0000 (14:13 -0500)]
runtime: add tests of printing inlined frames in tracebacks

We're about to rewrite this code and it has almost no test coverage
right now.

This test is also more complete than the existing
TestTracebackInlineExcluded, so we delete that test.

For #54466.

Change-Id: I144154282dac5eb3798f7d332b806f44c4a0bdf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/466098
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: use srcFunc for showframe
Austin Clements [Mon, 6 Feb 2023 03:02:03 +0000 (22:02 -0500)]
runtime: use srcFunc for showframe

Since srcFunc can represent information for either an real text
function or an inlined function, this means we no longer have to
synthesize a fake _func just to call showframe on an inlined frame.

This is cleaner and also eliminates the one case where _func values
live in the heap. This will let us mark them NotInHeap, which will in
turn eliminate pesky write barriers in the traceback rewrite.

For #54466.

Change-Id: Ibf5e24d01ee4bf384c825e1a4e2922ef444a438e
Reviewed-on: https://go-review.googlesource.com/c/go/+/466097
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: create an API for unwinding inlined frames
Austin Clements [Sun, 5 Feb 2023 20:54:33 +0000 (15:54 -0500)]
runtime: create an API for unwinding inlined frames

We've replicated the code to expand inlined frames in many places in
the runtime at this point. This CL adds a simple iterator API that
abstracts this out.

We also use this to try out a new idea for structuring tests of
runtime internals: rather than exporting this whole internal data type
and API, we write the test in package runtime and import the few bits
of std we need. The idea is that, for tests of internals, it's easier
to inject public APIs from std than it is to export non-public APIs
from runtime. This is discussed more in #55108.

For #54466.

Change-Id: Iebccc04ff59a1509694a8ac0e0d3984e49121339
Reviewed-on: https://go-review.googlesource.com/c/go/+/466096
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Austin Clements <austin@google.com>

14 months agoruntime: dedup function name logic into moduledata method
Austin Clements [Fri, 3 Feb 2023 22:49:53 +0000 (17:49 -0500)]
runtime: dedup function name logic into moduledata method

For #54466.

Change-Id: I4d8e1953703b6c763e5bd53024da43efcc993489
Reviewed-on: https://go-review.googlesource.com/c/go/+/466095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Austin Clements <austin@google.com>

14 months agoruntime: resolve caller funcInfo after processing current frame
Austin Clements [Sun, 17 Jul 2022 19:57:09 +0000 (15:57 -0400)]
runtime: resolve caller funcInfo after processing current frame

Currently, gentraceback resolves the funcInfo of the caller prior to
processing the current frame (calling the callback, printing it, etc).
As a result, if this lookup fails in a verbose context, it will print
the failure before printing the frame that it's already resolved.

To fix this, move the resolution of LR to a funcInfo to after current
frame processing.

This also has the advantage that we can reduce the scope of "flr" (the
caller's funcInfo) to only the post-frame part of the loop, which will
make it easier to stack-rip gentraceback into an iterator.

For #54466.

Change-Id: I8be44d4eac598a686c32936ab37018b8aa97c00b
Reviewed-on: https://go-review.googlesource.com/c/go/+/458217
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
14 months agoruntime: eliminate waspanic from gentraceback
Austin Clements [Sun, 17 Jul 2022 19:43:01 +0000 (15:43 -0400)]
runtime: eliminate waspanic from gentraceback

gentraceback also tracks the funcID of the callee, which is more
general. Fix this up to happen in all cases and eliminate waspanic in
favor of checking the funcID of the caller.

For #54466.

Change-Id: Idc98365a6f05022db18ddcd5b3ed8684a6872a88
Reviewed-on: https://go-review.googlesource.com/c/go/+/458216
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: don't track stack separately in gentraceback
Austin Clements [Tue, 12 Jul 2022 20:42:06 +0000 (16:42 -0400)]
runtime: don't track stack separately in gentraceback

Currently, gentraceback keeps a copy of the stack bounds of the stack
it's walking in the "stack" variable. Now that "gp" always refers to
the G whose stack it's walking, we can simply use gp.stack instead of
keeping a separate copy.

For #54466.

Change-Id: I68256e5dff6212cfcf14eda615487e66a92d4914
Reviewed-on: https://go-review.googlesource.com/c/go/+/458215
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: add a benchmark of Callers
Austin Clements [Tue, 28 Feb 2023 14:13:56 +0000 (09:13 -0500)]
runtime: add a benchmark of Callers

We're about to make major changes to tracebacks. We have benchmarks of
stack copying, but not of PC buffer filling, so add some that we can
track through these changes.

For #54466.

Change-Id: I3ed61d75144ba03b61517cd9834eeb71c99d74df
Reviewed-on: https://go-review.googlesource.com/c/go/+/472956
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agocmd/compile/internal/types2: record error code in Error struct
Robert Griesemer [Thu, 9 Mar 2023 22:44:46 +0000 (14:44 -0800)]
cmd/compile/internal/types2: record error code in Error struct

go/types already does this, if slightly differently.

Change-Id: I9cf5f493714d865deec5ad23e2ee9b5c5d3f2f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/475197
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
14 months agointernal/fuzz: avoid deadlock on duplicate entries with exec limit
Roland Shoemaker [Thu, 9 Mar 2023 23:59:17 +0000 (15:59 -0800)]
internal/fuzz: avoid deadlock on duplicate entries with exec limit

If there was a execution limit enabled, and a result put us beyond that
limit, but the result expanded coverage *and* was a duplicate of an
entry already in the cache, the check if we were passed the limit would
be skipped. Since this check was inside the result check body, and we
would no longer send any new inputs, we'd never get to that check again,
causing the coordinator to just sit in an infinite loop.

This moves the check up to the top of the coordinator loop, so that it
is checked after every result is processed. Also add a cmd/go TestScript
regression test which triggered this case much more frequently.

Updates #51484

Change-Id: I7a2181051177acb853c1009beedd334a40796177
Reviewed-on: https://go-review.googlesource.com/c/go/+/475196
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime: implement cputicks with the stable counter on loong64
Guoqi Chen [Fri, 5 Aug 2022 05:32:08 +0000 (13:32 +0800)]
runtime: implement cputicks with the stable counter on loong64

The stable counter is described in Section 2.2.10.4, LoongArch Reference Manual Volume 1.

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I160b695a8c0e38ef49b21fb8b41460fd23d9538c
Reviewed-on: https://go-review.googlesource.com/c/go/+/421656
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agocmd/compile: reorder operations in SCCs to enable more inlining
Than McIntosh [Thu, 9 Mar 2023 14:59:26 +0000 (09:59 -0500)]
cmd/compile: reorder operations in SCCs to enable more inlining

This patch changes the relative order of "CanInline" and "InlineCalls"
operations within the inliner for clumps of functions corresponding to
strongly connected components in the call graph. This helps increase
the amount of inlining within SCCs, particularly in Go's runtime
package, which has a couple of very large SCCs.

For a given SCC of the form { fn1, fn2, ... fnk }, the inliner would
(prior to this point) walk through the list of functions and for each
function first compute inlinability ("CanInline") and then perform
inlining ("InlineCalls"). This meant that if there was an inlinable
call from fn3 to fn4 (for example), this call would never be inlined,
since at the point fn3 was visited, we would not have computed
inlinability for fn4.

We now do inlinability analysis for all functions in an SCC first,
then do actual inlining for everything. This results in 47 additional
inlines in the Go runtime package (a fairly modest increase
percentage-wise of 0.6%).

Updates #58905.

Change-Id: I48dbb1ca16f0b12f256d9eeba8cf7f3e6dd853cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/474955
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
14 months agocmd/link: use only the configured C compiler in TestCGOLTO
Bryan C. Mills [Thu, 9 Mar 2023 21:17:30 +0000 (16:17 -0500)]
cmd/link: use only the configured C compiler in TestCGOLTO

The test had been assuming that any 'gcc' or 'clang' command found in
$PATH could be used to compile cgo dependencies for the target GOARCH
and GOOS. That assumption does not hold in general: for example,
the GOARCH/GOOS configuration may be cross-compiling, which will cause
the test to fail if the native 'gcc' and/or 'clang' is not configured
for the target architecture.

Instead, leave the 'CC' variable unset and assume only that the user
has configured it appropriate to the environment in which they are
running the test.

For #58829.

Change-Id: I9a1269ae3e0b4af281702114dabba844953f74bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/475155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocmd/link: use label symbols for Duff's devices on darwin/arm64
Cherry Mui [Wed, 8 Mar 2023 21:38:32 +0000 (16:38 -0500)]
cmd/link: use label symbols for Duff's devices on darwin/arm64

On darwin, the external linker generally supports CALL relocations
with addend. One exception is that for a very large binary when it
decides to insert a trampoline, instead of applying the addend to
the call target (in the trampoline), it applies the addend to the
CALL instruction in the caller, i.e. generating a call to
trampoline+addend, which is not the correct address and usually
points to unreloated functions.

To work around this, we use label symbols so the CALL is targeting
a label symbol without addend. To make things simple we always use
label symbols for CALLs with addend (in external linking mode on
darwin/arm64), even for small binaries.

Fixes #58935.

Change-Id: I38aed6b62a0496c277c589b5accbbef6aace8dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/474620
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agogo/types, types2: clean up defined type identity check/unification
Robert Griesemer [Wed, 8 Mar 2023 03:01:38 +0000 (19:01 -0800)]
go/types, types2: clean up defined type identity check/unification

Factor out check for identical origin.
Match unification code with type identity check.
Add a test case for #53692.

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

14 months agocmd/compile: remove -wrapglobalmapinit flag
Than McIntosh [Thu, 9 Mar 2023 18:20:01 +0000 (13:20 -0500)]
cmd/compile: remove -wrapglobalmapinit flag

Remove the compiler's "-wrapglobalmapinit" flag; it is potentially
confusing for users and isn't appropriate as a top level flag. Move
the enable/disable control to the "wrapglobalmapctl" debug flag
(values: 0 on by default, 1 disabled, 2 stress mode). No other changes
to compiler functionality.

Change-Id: I0d120eaf90ee34e29d5032889e673d42fe99e5dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/475035
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/compile: clarify a few redundant deletions of internal/ssagen.state.vars
Andy Pan [Sat, 25 Feb 2023 10:31:13 +0000 (18:31 +0800)]
cmd/compile: clarify a few redundant deletions of internal/ssagen.state.vars

Fixes #58729

The reason why these deletions exist is that the old state.variable method
will assign the new value to the given key of map when the key doesn't exist,
but after this commit: https://github.com/golang/go/commit/5a6e511c614a158cb58150fb62bfbc207a33922d#diff-e754f9fc8eaf878714250cfc03844eb3b58185ac806a8c1c4f9fbabd86cda921L3972
the state.variable doesn't do that anymore, thus these deletions became redundant.

Change-Id: Ie6e2471ca445f907a2bb1607c293f9301f0d73e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/471355
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
14 months agoRevert "cmd/link: establish dependable package initialization order"
Keith Randall [Thu, 9 Mar 2023 16:31:41 +0000 (16:31 +0000)]
Revert "cmd/link: establish dependable package initialization order"

This reverts commit ce2a609909d9de3391a99a00fe140506f724f933.
aka CL 462035

Reason for revert: this CL is causing some problems in some internal Google programs.

Change-Id: I4476b8d8d2c3d7b5703d1d85c93baebb4b4e5d26
Reviewed-on: https://go-review.googlesource.com/c/go/+/474976
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoRevert "cmd/internal/objabi: regenerate RelocType stringer file"
Keith Randall [Thu, 9 Mar 2023 16:30:46 +0000 (16:30 +0000)]
Revert "cmd/internal/objabi: regenerate RelocType stringer file"

This reverts commit 99914db5eea927c7694276169585f1fff9e614c8.
aka CL 473875

Reason for revert: init order change that required this CL is causing some problems in some internal Google programs.

Change-Id: I801e278ab58d542c05c0332a9f1977b9588b6151
Reviewed-on: https://go-review.googlesource.com/c/go/+/474975
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
14 months agoruntime/trace: update outdated Task and Region documentation
Nick Ripley [Thu, 2 Mar 2023 21:20:07 +0000 (16:20 -0500)]
runtime/trace: update outdated Task and Region documentation

A previous iteration of the tracer's user annotation API had different
names for tasks and regions, and used to return functions for ending
them rather than types with End methods. This CL updates the doc
comments to reflect those changes, and also fixes up the internal
documentation of the events (similar to go.dev/cl/465335, the stack
argument was in the wrong place in the list).

The User Log event internal documentation might also look wrong since
the value argument follows the stack argument. However, the User Log
event is a special case where the log message is appended immediately
following the normal event, including the stack argument. There isn't
much room to clarify this next to the event type definitions, so this CL
clarifies the comment where the event is encoded.

Change-Id: I846c709f6026ef01c0a272557d6390b2c17074e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/472955
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Nick Ripley <nick.ripley@datadoghq.com>

14 months agonet/http: use Copy in ServeContent if CopyN not needed
Leo Antunes [Sun, 30 Oct 2022 10:15:27 +0000 (10:15 +0000)]
net/http: use Copy in ServeContent if CopyN not needed

This small PR allows optimizations made in io.Copy (like the use of
io.WriterTo) to be used in one possible path of http.ServeContent
(in case of a non-Range request).
This, in turn, allows us to skip the buffer allocation in io.Copy.

Change-Id: Ifa2ece206ecd4556aaaed15d663b65e95e00bb0a
GitHub-Last-Rev: 94fc0318145ba1bd48502564f6488aade871c301
GitHub-Pull-Request: golang/go#56480
Reviewed-on: https://go-review.googlesource.com/c/go/+/446276
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>

14 months agocmd/compile: report profile open/parse errors
Michael Pratt [Thu, 9 Mar 2023 17:10:25 +0000 (12:10 -0500)]
cmd/compile: report profile open/parse errors

Currently we fail to print errors from os.Open and profile.Parse of the
PGO profile, losing context useful to understand these errors.

In fixing this, cleanup error use overall to return an error from
pgo.New and report the problematic file at the top level.

Change-Id: Id7e9c781c4b8520eee96b6f5fe8a0b757d947f7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/474995
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

14 months agointernal/bytealg: remove aix and linux build tags from ppc64 index code
Joel Sing [Thu, 2 Mar 2023 14:23:59 +0000 (01:23 +1100)]
internal/bytealg: remove aix and linux build tags from ppc64 index code

This code is generic to ppc64/ppc64le - there is no need to limit it to
aix or linux.

Updates #56001

Change-Id: I613964a90f9c5ca637720219a0260d65427f4be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/473697
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
14 months agosyscall: avoid race in plan9 while syncing Chdir across goroutines
miller [Tue, 7 Mar 2023 15:15:10 +0000 (15:15 +0000)]
syscall: avoid race in plan9 while syncing Chdir across goroutines

Because each M in Plan 9 runs in a separate OS process with its
own current working directory, a Chdir call in one goroutine needs
to be propagated to other goroutines before a subsequent syscall
with a local pathname (see #9428). This is done by function
syscall.Fixwd, but there is still a race if a goroutine is
preempted and rescheduled on a different M between calling Fixwd
and executing the syscall which it protects. By locking the
goroutine to its OS thread from the start of Fixwd to the end of
the protected syscall, this race can be prevented.

Fixes #58802.

Change-Id: I89c0e43ef4544b5bfb5db7d2158f13f24b42e1f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/474055
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agonet/http: remove arbitrary timeout in TestServerAllowsBlockingRemoteAddr
Bryan C. Mills [Wed, 8 Mar 2023 22:10:06 +0000 (17:10 -0500)]
net/http: remove arbitrary timeout in TestServerAllowsBlockingRemoteAddr

If the test actually deadlocks, we probably want a goroutine dump to
debug it anyway. Otherwise, the arbitrary timeout can only cause
spurious failures.

Fixes #36179.

Change-Id: Ic2037496959a38d3231eefdbc1dd5d45eebdf306
Reviewed-on: https://go-review.googlesource.com/c/go/+/474582
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agoruntime/cgo: add tsan sync for traceback function
Ian Lance Taylor [Wed, 8 Mar 2023 04:27:59 +0000 (20:27 -0800)]
runtime/cgo: add tsan sync for traceback function

Change-Id: Ifb8d64f18b67c8b712feec29ffb6719c6e9718ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/474198
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

14 months agotest: test for issue 53087
Keith Randall [Thu, 2 Jun 2022 16:31:30 +0000 (09:31 -0700)]
test: test for issue 53087

This issue has been fixed with unified IR, so just add a test.

Update #53087

Change-Id: I965d9f27529fa6b7c89e2921c65e5a100daeb9fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/410197
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Keith Randall <khr@google.com>

14 months agodebug/buildinfo: recognize macOS fat binary in go version
Nikola Jokic [Mon, 6 Mar 2023 08:52:12 +0000 (09:52 +0100)]
debug/buildinfo: recognize macOS fat binary in go version

buildinfo did not check for fat magic, which caused go version to report
unrecognized file format.

This change reads the fat file and passes the first arch file to machoExe.

Fixes #58796

Change-Id: I45cd26729352e46cc7ecfb13f2e9a8d96d62e0a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/473615
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agocmd/internal/obj/ppc64: add SETB instruction
Paul E. Murphy [Mon, 27 Feb 2023 22:05:34 +0000 (16:05 -0600)]
cmd/internal/obj/ppc64: add SETB instruction

This ISA 3.0 (power9) instruction is helpful for some string functions
in a future change.

Change-Id: I1a659488ffb5099f8c89f480c39af4ef9c4b556a
Reviewed-on: https://go-review.googlesource.com/c/go/+/472635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>