qmuntal [Tue, 8 Oct 2024 16:10:17 +0000 (18:10 +0200)]
runtime: reduce syscall.SyscallX stack usage
syscall.SyscallX consumes a lot of stack space, which is a problem
because they are nosplit functions. They used to use less stack space,
but CL 563315, that landed in Go 1.23, increased the stack usage by a
lot.
This CL reduces the stack usage back to the previous level.
Fixes #69813.
Change-Id: Iddedd28b693c66a258da687389768055c493fc2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/618497 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cmd/go: make sure the linker for shared doesn't include tempdir path
This is similar to CL 478196 and CL 477296,
but this is for -buildmode=shared.
When using "go install -buildmode=shared std",
because the gold linker is used by default on Linux arm64,
it will cause temporary paths to be included in libstd.so.
Based on the changes of CL 478196,
I speculate that this may also have issues on other platforms.
So, this change is for all platform.
Fixes #69464
Change-Id: I4493c82be030186e61aef597ea0e6f43bcf95a32
GitHub-Last-Rev: ee40cf81acf70f553bfc63a21a41ce0174857043
GitHub-Pull-Request: golang/go#69394
Reviewed-on: https://go-review.googlesource.com/c/go/+/612396 Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
qmuntal [Thu, 10 Oct 2024 09:56:56 +0000 (11:56 +0200)]
syscall: support more flags when opening directories on Windows
syscall.Open was artificially limiting the flags that were eligible
to open directories on Windows. This change extend the cases where we
pass FILE_FLAG_BACKUP_SEMANTICS to all flag combinations allowed by
Unix.
Change-Id: Ia7c083bcba070f92ea61c6d67487bdefd0d99546
Reviewed-on: https://go-review.googlesource.com/c/go/+/619295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com>
qmuntal [Thu, 10 Oct 2024 09:09:13 +0000 (11:09 +0200)]
syscall: fix Open param names
syscall.Open param names are confusing, mainly because what should be
named flag is named mode and what should be named mode is named perm.
The name perm is used as synonym for mode in other places, so keep
it as is. Rename mode to flag to match the real meaning of the
parameter. Also, rename path to name for consistency with other
usage of the same parameter.
Change-Id: Ideed09839d80c0383584c2268afbb6cc09ffda8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/619276 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cuishuang [Wed, 9 Oct 2024 03:56:25 +0000 (11:56 +0800)]
net/url: add example for JoinPath
Change-Id: Ibbd2bda7ff2ea3c782ad41f6f00ad62849a4f066
Reviewed-on: https://go-review.googlesource.com/c/go/+/618756
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
qmuntal [Thu, 10 Oct 2024 09:01:16 +0000 (11:01 +0200)]
syscall,os: move flags validation from os.OpenFile to syscall.Open
syscall.Open is the functions that maps Unix/Go flags into Windows
concepts. Part of the flag validation logic was still implemented
in os.OpenFile, move it to syscall.Open for consistency.
A nice side effect is that we don't have to translate the file name
twice in case of an access denied error.
Change-Id: I32c647a9a2a066277c78f53bacb45fb3036f6353
Reviewed-on: https://go-review.googlesource.com/c/go/+/619275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Thu, 10 Oct 2024 17:19:12 +0000 (10:19 -0700)]
doc: reference language version in pre-generic spec for easier recognition
This matches the style we use for the current spec.
Change-Id: I82ad8e9994da1c74801f3c18f32f21fdd7ac355a
Reviewed-on: https://go-review.googlesource.com/c/go/+/619476 Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Ian Lance Taylor [Wed, 9 Oct 2024 21:32:21 +0000 (14:32 -0700)]
os: handle umask comparing execute mode in verifyCopyFS
Fixes #69788
Change-Id: I43cc4c0dc3c8aa2474cba26c84714d00828de08e
Reviewed-on: https://go-review.googlesource.com/c/go/+/619176
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
cuishuang [Wed, 9 Oct 2024 03:23:11 +0000 (11:23 +0800)]
net/mail: add example for ParseDate
Change-Id: Id22d199ea4b0a9795dc3d9e5f7a74be13ff0cf58
Reviewed-on: https://go-review.googlesource.com/c/go/+/618755
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Keith Randall [Wed, 9 Oct 2024 16:36:41 +0000 (09:36 -0700)]
cmd/compile: use call block instead of entry block for tail call expansion
The expand-calls pass assumed that tail calls were always done in the
entry block. That used to be true, but with tail calls in wrappers
(enabled by CL 578235) and libfuzzer instrumentation, that is no
longer the case. Libfuzzer instrumentation adds an IF statement to the
start of the wrapper function.
Fixes #69825
Change-Id: I9ab7133691d8235f9df128be39bff154b0b8853b
Reviewed-on: https://go-review.googlesource.com/c/go/+/619075 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com>
qmuntal [Wed, 9 Oct 2024 08:48:07 +0000 (10:48 +0200)]
syscall: simplify O_TRUNC handling on Windows
The current implementation of O_TRUNC in syscall.Open on Windows is
prone to TOCTOU issues, as it opens the file twice if the first open
detects that the file doesn't exist. The file could
be created in between the two open calls, leading to the creation
of a new file with the undesired readonly attribute.
This CL implements O_TRUNC by just calling CreateFile once without
taking O_TRUNCATE into account, and then using Ftruncate if O_TRUNC is
set to truncate the file.
Updates #38225.
Change-Id: Ic3ad1bab75c9a1c16f99c8c5bed867c5dbc3a23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/618836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
qmuntal [Wed, 9 Oct 2024 08:12:57 +0000 (10:12 +0200)]
syscall: implement Ftruncate using a single syscall on Windows
Ftruncate can be implemented on Windows using a single syscall. This
makes the implementation more efficient and less prone to races when
used in combination with other Seek calls.
Change-Id: I5d9f780fba2710403fce89d3325e519f33ad9ae8
Reviewed-on: https://go-review.googlesource.com/c/go/+/618835 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Add a new package that will contain a new "Swiss Table"
(https://abseil.io/about/design/swisstables) map implementation, which
is intended to eventually replace the existing runtime map
implementation.
This implementation is based on the fabulous
github.com/cockroachdb/swiss package contributed by Peter Mattis.
This CL adds an hash map implementation. It supports all the core
operations, but does not have incremental growth.
For #54766.
Change-Id: I52cf371448c3817d471ddb1f5a78f3513565db41
Reviewed-on: https://go-review.googlesource.com/c/go/+/582415 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
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>
Tobias Klauser [Tue, 8 Oct 2024 08:18:22 +0000 (10:18 +0200)]
cmd/go/internal/modload: use slices.Contains
Change-Id: I9d39984b6b15d415189592b592de471f50b43d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/618495 Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cmd/internal/obj: optimize the function stacksplit on loong64
In the process of stack split checking, loong64 uses the following
logic: if SP > stackguard then goto done, else morestack
The possible problem here is that the probability of morestack
execution is much lower than done, while static branch prediction
is more inclined to obtain morestack, which will cause a certain
probability of branch prediction error.
Change the logic here to:
if SP <= stackguard then goto morestack, else done
Damien Neil [Fri, 4 Oct 2024 21:30:31 +0000 (14:30 -0700)]
syscall, internal/syscall/unix: add Openat support for wasip1
The syscall package is mostly frozen, but wasip1 file syscall
support was added to syscall and the Open and Openat
implementations overlap. Implement Openat in syscall for
overall simplicity.
We already have syscall.Openat for some platforms, so this
doesn't add any new functions to syscall.
For #67002
Change-Id: Ia34b12ef11fc7a3b7832e07b3546a760c23efe5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/617378
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Damien Neil [Fri, 4 Oct 2024 21:19:05 +0000 (14:19 -0700)]
internal/syscall/unix: add Mkdirat and Readlinkat
For #67002
Change-Id: I460e02db33799c145c296bcf0668fa555199036e
Reviewed-on: https://go-review.googlesource.com/c/go/+/617376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Paul E. Murphy [Wed, 2 Oct 2024 18:31:37 +0000 (13:31 -0500)]
cmd/compile: add internal/runtime/atomic.Xchg8 intrinsic for PPC64
This is minor extension of the existing support for 32 and
64 bit types.
For #69735
Change-Id: I6828ec223951d2b692e077dc507b000ac23c32a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/617496 Reviewed-by: Rhys Hiltner <rhys.hiltner@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
The two tests confused a nil pointer panic with the panic from a double
call to yield.
Change-Id: I0040e60cf4b702a92825d308db1201a85f164009
Reviewed-on: https://go-review.googlesource.com/c/go/+/617917 Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
If the expression type is a single compile-time known type, use that
type instead of the dynamic one, so the later passes of the compiler
could skip un-necessary runtime calls.
Thanks Youlin Feng for writing the original test case.
Change-Id: I3f65ab90f041474a9731338a82136c1d394c1773
Reviewed-on: https://go-review.googlesource.com/c/go/+/616975
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Sean Liao [Sun, 6 Oct 2024 10:20:50 +0000 (11:20 +0100)]
io/fs: document need to call File.Close
Fixes #69723
Change-Id: Id081f68cd30abfa77a971a2370f4a0ebf330eb8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/618095 Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
xieyuschen [Sat, 5 Oct 2024 07:52:21 +0000 (15:52 +0800)]
os: remove t.Parallel in TestMkdirStickyUmask
The TestMkdirStickyUmask modifies the umask for testing purpose.
When run in parallel with TestCopyFS, this temporary umask change can cause TestCopyFS to create files with unintended permissions, leading to test failures.
This change removes the t.Parallel call in TestMkdirStickyUmask to prevent interference with TestCopyFS, ensuring it doesn't run concurrently with the other tests that require umask.
Fixes #69788
Change-Id: I9cf1da9f92283340ff85d2721781760a750d124c
Reviewed-on: https://go-review.googlesource.com/c/go/+/618055
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
qmuntal [Thu, 3 Oct 2024 08:36:36 +0000 (10:36 +0200)]
internal/coverage: use 128-bit FNV-1a hash instead of MD5
This change replaces the MD5 hash used to identify coverage files with a
128-bit FNV-1a hash. This change is motivated by the fact that MD5
should only be used for legacy cryptographic purposes.
The 128-bit FNV-1a hash is sufficient for the purpose of identifying
coverage files, it having the same theoretical collision resistance as
MD5, but with the added benefit of being faster to compute.
Change-Id: I7b547ce2ea784f8f4071599a10fcb512b87ee469
Reviewed-on: https://go-review.googlesource.com/c/go/+/617360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Filippo Valsorda [Mon, 26 Aug 2024 18:00:10 +0000 (20:00 +0200)]
runtime: overwrite startupRand instead of clearing it
AT_RANDOM is unfortunately used by libc before we run (so make sure it's
not cleared) but also is available to cgo programs after we did. It
would be unfortunate if a cgo program assumed it could use AT_RANDOM but
instead found all zeroes there.
Change-Id: I82eff34d8cf5a499b439052b7827b8ef7cabc21d
Reviewed-on: https://go-review.googlesource.com/c/go/+/608437 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
Filippo Valsorda [Mon, 26 Aug 2024 17:57:43 +0000 (19:57 +0200)]
runtime: use arc4random_buf() for readRandom
readRandom doesn't matter on Linux because of startupRand, but it does
on Windows and macOS. Windows already uses the same API as crypto/rand.
Switch macOS away from the /dev/urandom read.
Updates #68278
Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_14
Change-Id: Ie8f105e35658a6f10ff68798d14883e3b212eb3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/608436 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Filippo Valsorda [Mon, 26 Aug 2024 17:37:15 +0000 (19:37 +0200)]
crypto/rand: add randcrash=0 GODEBUG
For #66821
Change-Id: I525c308d6d6243a2bc805e819dcf40b67e52ade5
Reviewed-on: https://go-review.googlesource.com/c/go/+/608435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
Filippo Valsorda [Mon, 26 Aug 2024 15:53:46 +0000 (17:53 +0200)]
crypto/rand: improve TestReadLoops
As suggested by Russ Cox, making sure we see all byte values doesn't
take long and is a superset of the existing test.
Change-Id: Ifc7f18ca4189c89a3d06d0408150a2464ce5e590
Reviewed-on: https://go-review.googlesource.com/c/go/+/608397
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Filippo Valsorda [Sun, 25 Aug 2024 12:00:18 +0000 (14:00 +0200)]
crypto/rand: use runtime.getRandomData on js/wasm
This mechanism ultimately calls the same JavaScript method, but being
consistent between runtime and crypto/rand lets us reuse test coverage
across them. Also, no allocations.
Cq-Include-Trybots: luci.golang.try:gotip-js-wasm
Change-Id: I035da1ed603fbcdad61945f2b57f3fb527a959fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/608396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Filippo Valsorda [Sat, 24 Aug 2024 19:44:23 +0000 (21:44 +0200)]
crypto/rand: reintroduce urandom fallback for legacy Linux kernels
Reintroduce the urandom fallback, but this time with a robust set of
tests all pointing guns at each other, including a seccomp'd respawn
simulating the lack of getrandom, to make sure the fallback both works
and is never hit unexpectedly.
Unlike the Go 1.23 fallback, the new one only triggers on ENOSYS (which
is cached by unix.GetRandom) and doesn't handle the EAGAIN errors we
never got an explanation for.
We still crash the program from Read if we have to go to /dev/urandom
and we fail to open it.
For #67001
Updates #66821
Tested on legacy SlowBots (without plan9 and illumos, which don't work):
TRY=aix-ppc64,dragonfly-amd64,freebsd-amd64,freebsd-386,netbsd-amd64
Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_14,gotip-solaris-amd64,gotip-js-wasm,gotip-wasip1-wasm_wasmtime,gotip-wasip1-wasm_wazero,gotip-windows-amd64,gotip-windows-386,gotip-linux-386,gotip-linux-amd64-longtest-race,gotip-linux-amd64-boringcrypto
Change-Id: Idecc96a18cd6363087f5b2a4671c6fd1c41a3b0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/608175 Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Filippo Valsorda [Thu, 1 Aug 2024 17:59:07 +0000 (19:59 +0200)]
crypto/rand: prevent Read argument from escaping to heap
Mateusz had this idea before me in CL 578516, but it got much easier
after the recent cleanup.
It's unfortunate we lose the test coverage of batched, but the package
is significantly simpler than when we introduced it, so it should be
easier to review that everything does what it's supposed to do.
Fixes #66779
Co-authored-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Change-Id: Id35f1172e678fec184efb0efae3631afac8121d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/602498 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Filippo Valsorda [Thu, 1 Aug 2024 17:07:32 +0000 (19:07 +0200)]
crypto/rand: crash program if Read would return an error
Fixes #66821
Fixes #54980
Change-Id: Ib081f4e4f75c7936fc3f5b31d3bd07cca1c2a55c
Reviewed-on: https://go-review.googlesource.com/c/go/+/602497 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Filippo Valsorda [Thu, 1 Aug 2024 14:28:24 +0000 (16:28 +0200)]
crypto/rand: remove /dev/urandom fallback and improve getrandom batching
The fallback was reachable on
- Linux, where starting in Go 1.24 we require a kernel with
getrandom(2), see #67001.
- FreeBSD, which added getrandom(2) in FreeBSD 12.0, which we
require since Go 1.19.
- OpenBSD, which added getentropy(2) in OpenBSD 5.6, and we only
support the latest version.
- DragonFly BSD, which has getrandom(2) and where we support only
the latest version.
- NetBSD, where we switched to kern.arandom in CL 511036, available
since NetBSD 4.0.
- illumos, which has getrandom(2). (Supported versions unclear.)
- Solaris, which had getrandom(2) at least since Oracle
Solaris 11.4.
- AIX, which... ugh, fine, but that code is now in rand_aix.go.
At the end of the day the platform-specific code is just a global
func(b []byte) error, so simplified the package around that assumption.
This also includes the following change, which used to be a separate CL.
crypto/rand: improve getrandom batching and retry logic
The previous logic assumed getrandom never returned short, and then
applied stricter-than-necessary batch size limits, presumably to
avoid short returns.
This was still not sufficient because above 256 bytes getrandom(2)
can be interrupted by a signal and return short *or* it can simply
return EINTR if the pool is not initialized (regardless of buffer
size).
Whether this ever failed in practice is unknown: it would have been
masked by the /dev/urandom fallback before.
Instead, we apply buffer size limits only where necessary (really,
only Solaris in practice and FreeBSD in theory) and then handle
gracefully short returns and EINTR.
It turns out that we now know that large getrandom calls *did* fail in
practice, falling back on /dev/urandom, because when we removed the
fallback TestBidiStreamReverseProxy with its 4KiB read started failing.
Change-Id: Iaca62997604f326501a51401cdc2659c2790ff22
Reviewed-on: https://go-review.googlesource.com/c/go/+/602495 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
David Chase [Fri, 27 Sep 2024 23:15:03 +0000 (19:15 -0400)]
cmd/go: adjust test with tricky ld flags to not run on Darwin
normally this would not run on darwin anyway, but if there
happens to be a "pkg-config" binary, then it will. Darwin's
clang/linker does not have this flag.
Change-Id: I61929cf193c95b420441187beb8b237fa1037807
Reviewed-on: https://go-review.googlesource.com/c/go/+/616376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Ian Lance Taylor [Fri, 30 Aug 2024 22:44:02 +0000 (15:44 -0700)]
cmd/cgo: avoid endless recursion on recursive type
Fixes #69176
Change-Id: I2e3b2a7cf7699697b957fc69ecf5200ebb137bc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/609975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
internal/cpu: add CPU feature LAMCAS and LAM_BH detection on loong64
Change-Id: Ic5580c4ee006d87b3152ae5de7b25fb532c6a33f
Reviewed-on: https://go-review.googlesource.com/c/go/+/612976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Martin Möhrmann <moehrmann@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Martin Möhrmann <martin@golang.org>
CopyFS stipulates the permissions of the created files,
we should test them in the unit test.
* chmod x for testdata/x to test CopyFS for executable
* check the files permissions to ensure CopyFS follows the stipulated
convention
Change-Id: Id13a8ad920ad0c1ff4b801dec3bfa6869cb3101f
Reviewed-on: https://go-review.googlesource.com/c/go/+/616615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Thu, 3 Oct 2024 20:51:25 +0000 (13:51 -0700)]
go/types, types2: always try inference over methods when possible
During type inference, when comparing type parameters against their
constraints, if a type argument is completely known it must implement
its constraint. In this case, always unify the type argument's methods
against the constraint methods, if any.
Before this CL, this step was only attempted if the constraint had no
core type. That left information unused which led to type inference
failures where it should have succeeded.
Fixes #66751.
Change-Id: I71e96b71258624212186cf17ec47e67a589817b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/617896 Reviewed-by: Tim King <taking@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Robert Griesemer [Thu, 3 Oct 2024 19:29:40 +0000 (12:29 -0700)]
go/types, types2: add additional tracing output in type inference
To support analyzing type inference failures.
Change-Id: I47882f6b634d5fcf1834923ec372313323d31a9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/617895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Change-Id: Icad625065fb1f30b2a4094f3f1e58b4e9b3d841e
Reviewed-on: https://go-review.googlesource.com/c/go/+/616137 Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
cmd/go: relax the regular expression of TestScript/list_pkgconfig_error
Fixes #68283
Change-Id: I63bd128bd10565ce16a13b5a60d813368db26f26
Reviewed-on: https://go-review.googlesource.com/c/go/+/616339
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Damien Neil [Thu, 3 Oct 2024 17:00:20 +0000 (10:00 -0700)]
net/netip: clarify Addr.Is4In6 documentation
For #65635
Change-Id: I4e4b0309d9139f970d6fd6b41303dfd2e0ec6236
Reviewed-on: https://go-review.googlesource.com/c/go/+/617835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Reason for revert: This CL breaks gotip-linux-amd64-noopt builder.
Change-Id: I3950211f05c90e4955c0785409b796987741a9f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/617715 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
qmuntal [Thu, 3 Oct 2024 07:34:42 +0000 (09:34 +0200)]
archive/tar: use hash/crc32 instead of crypto/md5 for test checksums
Using MD5 for checksums in tests is an overkill, as MD5 is designed for
cryptographic purposes. Use hash/crc32 instead, which is designed for
detecting random data corruptions, aka checksums.
Change-Id: I03b30ed7f38fba2a2e59d06bd4133b495f64a013
Reviewed-on: https://go-review.googlesource.com/c/go/+/617675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com>
Michael Pratt [Wed, 2 Oct 2024 21:20:12 +0000 (17:20 -0400)]
syscall: use SYS_EXIT_GROUP in CLONE_PIDFD feature check child
Inside Google we have seen issues with QEMU user mode failing to wake a
parent waitid when this child exits with SYS_EXIT. This bug appears to
not affect SYS_EXIT_GROUP.
It is currently unclear if this is a general QEMU or specific to
Google's configuration, but SYS_EXIT and SYS_EXIT_GROUP are semantically
equivalent here, so we can use the latter here in case this is a general
QEMU bug.
For #68976.
Change-Id: I34e51088c9a6b7493a060e2a719a3cc4a3d54aa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/617417 Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Ian Lance Taylor [Wed, 2 Oct 2024 20:38:25 +0000 (13:38 -0700)]
runtime: clear isSending bit earlier
I've done some more testing of the new isSending field.
I'm not able to get more than 2 bits set. That said,
with this change it's significantly less likely to have even
2 bits set. The idea here is to clear the bit before possibly
locking the channel we are sending the value on, thus avoiding
some delay and some serialization.
For #69312
Change-Id: I8b5f167f162bbcbcbf7ea47305967f349b62b0f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/617497 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Wed, 2 Oct 2024 00:04:51 +0000 (17:04 -0700)]
go/types, types: always record a type for inner composite literals
Ensure that inner composite literals get a (possibly invalid) type
if something goes wrong with the enclosing composite literal.
Fixes #69092.
Change-Id: Ib1d2d529c4683ea3ab1799a818b43538e152ae8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/616616
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Nick Ripley [Tue, 1 Oct 2024 17:51:09 +0000 (13:51 -0400)]
runtime/pprof: make TestBlockMutexProfileInlineExpansion stricter
While working on CL 611241 and CL 616375, I introduced a bug that wasn't
caught by any test. CL 611241 added more inline expansion at sample time
for block/mutex profile stacks collected via frame pointer unwinding.
CL 616375 then changed how inline expansion for those stacks is done at
reporting time. So some frames passed through multiple rounds of inline
expansion, and this lead to duplicate stack frames in some cases. The
stacks from TestBlockMutexProfileInlineExpansion looked like
after those two CLs, and in particular after CL 616375. Note the extra
inlineD frame. The test didn't catch that since it was only looking for
a few frames in the stacks rather than checking the entire stacks.
This CL makes that test stricter by checking the entire expected stacks
rather than just a portion of the stacks.
Change-Id: I0acc739d826586e9a63a081bb98ef512d72cdc9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/617235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Michael Matloob [Tue, 1 Oct 2024 19:29:36 +0000 (15:29 -0400)]
cmd/go/internal/security: add -ftls-model to valid compiler flags
Allow -ftls-model to be passed in to a system compiler. It does not
allow arbitrary code execution. See
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-ftls-model
for documentation for the -ftls-model flag.
Fixes #69711
Change-Id: I842a96832e6858e62c171401d13baa3391d6d00a
Reviewed-on: https://go-review.googlesource.com/c/go/+/617136
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Jason A. Donenfeld [Tue, 1 Oct 2024 20:19:23 +0000 (22:19 +0200)]
runtime: don't acquirem() in vgetrandom unless necessary
I noticed in pprof that acquirem() was a bit of a hotspot. It turns out
that we can use the same trick that runtime.rand() does, and only
acquirem if we're doing something non-nosplit -- in this case, getting a
new state -- but otherwise just do getg().m, which is safe because we're
inside runtime and don't call split functions.
cpu: 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
│ sec/op │ sec/op vs base │
ParallelGetRandom-16 2.651n ± 4% 2.416n ± 7% -8.87% (p=0.001 n=10)
│ B/s │ B/s vs base │
ParallelGetRandom-16 1.406Gi ± 4% 1.542Gi ± 6% +9.72% (p=0.001 n=10)
Change-Id: Iae075f4e298b923e499cd01adfabacab725a8684
Reviewed-on: https://go-review.googlesource.com/c/go/+/616738 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Rhys Hiltner [Mon, 19 Aug 2024 20:58:42 +0000 (13:58 -0700)]
cmd/compile/internal/ssa: intrinsify atomic.Xchg8 on amd64
For #68578
Change-Id: Ia9580579bfc4709945bfcf6ec3803d5d11812187
Reviewed-on: https://go-review.googlesource.com/c/go/+/606901 Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Rhys Hiltner [Mon, 19 Aug 2024 20:51:59 +0000 (13:51 -0700)]
internal/runtime/atomic: add Xchg8 for amd64
For #68578
Change-Id: Idecfdbb793f46560dd69287af9170c07cf4ee973
Reviewed-on: https://go-review.googlesource.com/c/go/+/606900 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Default, use hash function in the runtime package.
If the build tag is purego or raw memory cannot be hash directly,
use reflect get each field to hash separately.
Fixes #54670
Change-Id: Ic968864c9c3c51883967d4f6dc24432385c7dc79
GitHub-Last-Rev: 5ae8a28834c8b809a52c74617e2a8530acec8095
GitHub-Pull-Request: golang/go#69166
Reviewed-on: https://go-review.googlesource.com/c/go/+/609761 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
Tobias Klauser [Wed, 2 Oct 2024 10:34:45 +0000 (12:34 +0200)]
syscall: gofmt after CL 592078
Change-Id: I328760f7752f1f5ec100f151c7e13e3f804c0e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/617355
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Jes Cok [Tue, 1 Oct 2024 03:15:08 +0000 (03:15 +0000)]
encoding/json: add omitzero option
Fixes #45669
Change-Id: Ic13523c0b3acdfc5b3e29a717bc62fde302ed8fd
GitHub-Last-Rev: 57030f26b0062fa8eda21b3a73b7665deab88c76
GitHub-Pull-Request: golang/go#69622
Reviewed-on: https://go-review.googlesource.com/c/go/+/615676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Jes Cok [Mon, 30 Sep 2024 15:04:36 +0000 (15:04 +0000)]
text/template: use correct verbs for reflect.Value
Fixes #69708.
Change-Id: I7a0347aff75cc8dad3f6c36966b1d03822a78dc9
GitHub-Last-Rev: fcc15513e48ceae68b846e1dff69b459defb2614
GitHub-Pull-Request: golang/go#69713
Reviewed-on: https://go-review.googlesource.com/c/go/+/616695
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Robert Griesemer [Tue, 1 Oct 2024 22:03:25 +0000 (15:03 -0700)]
spec: document that alias declarations can have type parameters with 1.24
For #46477.
Change-Id: Id02d8f67fe82228bab3f26b1cb4ebd6ee67c4634
Reviewed-on: https://go-review.googlesource.com/c/go/+/616816 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Robert Griesemer [Mon, 30 Sep 2024 22:55:14 +0000 (15:55 -0700)]
spec: clarify that identical structs must have identical field embeddings
The existing prose for struct identity did only require that two structs
"have the same sequence of fields, and if corresponding fields have the
same names, and identical types, and identical tags" for the structs to
be identical.
The implementation (forever) has also required that two corresponding
fields are either both embedded or not embedded. This is arguably part
of a struct's structure but is not explicitly specified.
This CL makes a minor change to the prose to address that.
Fixes #69472.
Change-Id: Ifa4ca69717986675642a09d03ce683ba8235efcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/616697 Reviewed-by: Rob Pike <r@golang.org>
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Ian Lance Taylor [Tue, 1 Oct 2024 16:57:52 +0000 (09:57 -0700)]
cmd/cgo: add srcdir & trimpath docs, sort options
Update the package docs:
* The -srcdir docs were accidentally lost in CL 68590.
* The -trimpath option was added in CL 266358 but not documented.
* The options were not sorted correctly.
Fixes #69730
Change-Id: I97320e0f4fb6aa47cb03d451f028d3d9d9b560f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/616699
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> Reviewed-by: Michael Knyszek <mknyszek@google.com>
favonia [Tue, 1 Oct 2024 10:49:19 +0000 (05:49 -0500)]
net: document possible networks that can be passed to Control
Before this patch, the documentation of Dialer.Control and
ListenConfig.Control did not specify what networks would be
passed to the Control function other than the "tcp" case.
It was thus challenging to use the Control function to filter
out certain networks. This patch documents all known networks.
Fixes #69693
Change-Id: I2ab10d68c4e4fac66d51d2cc232f02cf3b305e89
Reviewed-on: https://go-review.googlesource.com/c/go/+/617055
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> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Brian Palmer [Fri, 27 Sep 2024 20:09:11 +0000 (14:09 -0600)]
cmd/cgo: document errno value semantics
Added a section about errno values vs normal go
error value semantics, and checking the return
value of C functions for error before looking at
errno.
Fixes #63485
Change-Id: Id0132a9f11e4127f4adc14e010b7e17f57a0f7d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/616264 Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Michael Pratt [Tue, 1 Oct 2024 17:12:39 +0000 (13:12 -0400)]
runtime/pprof: add context to short stack panic
Over the years we've had various bugs in pprof stack handling resulting
in appendLocsForStack crashing because stk is too short for a cached
location. i.e., the cached location claims several inlined frames. Those
should always appear together in stk. If some frames are missing from
stk, appendLocsForStack.
If we find this case, replace the slice out of bounds panic with an
explicit panic that contains more context.
Change-Id: I52725a689baf42b8db627ce3e1bc6c654ef245d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/617135
Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Sam Thanawalla [Tue, 13 Aug 2024 16:48:11 +0000 (16:48 +0000)]
cmd/go: add GOAUTH mechanism for HTTP authentication
This change adds a new environment variable GOAUTH which takes a semicolon-separated list of commands to run for authentication during go-import resolution and HTTPS module mirror protocol interactions.
This CL only supports netrc and off. Future CLs to follow will extend support to git and a custom authenticator command.
For #26232
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I6cfa4c89fd27a7a4e7d25c8713d191dc82b7e28a
Reviewed-on: https://go-review.googlesource.com/c/go/+/605256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
Davis Goodin [Mon, 30 Sep 2024 17:08:24 +0000 (10:08 -0700)]
README.vendor: add note about GOROOT, recommend fresh go
Using a different build of Go (specifically, a different GOROOT) to
maintain the vendor directory doesn't always reproduce the same results.
This can result in unknowingly creating a vendor directory that isn't
able to build Go.
Add a note to README.vendor to point this out. Specifically, mention
that a mismatched GOROOT is an issue, and recommend using a fresh build
of Go to maintain the vendor directory.
Updates #69235
Change-Id: Id80c7607bf28bd76e43e1fdc672811c50f2bffb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/616815 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Matt T. Proud [Sun, 29 Sep 2024 05:23:33 +0000 (05:23 +0000)]
context: link to context and structs blog post
This commit amends the package documentation for the context package
and links the https://go.dev/blog/context-and-structs where the package
documentation dissuades one against embedding a context into a struct.
This is to help close the gap in understanding why this otherwise
cryptic piece of guidance is provided. The other referenced blog
article now points to go.dev instead of golang.org.
Change-Id: I0844a57bde1c03b6dddd1dd2dab2d20557d791fb
GitHub-Last-Rev: 4b039fba90f385a6ca8e44e8a34fbc339dbc21f0
GitHub-Pull-Request: golang/go#69696
Reviewed-on: https://go-review.googlesource.com/c/go/+/616515
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Ian Lance Taylor [Fri, 27 Sep 2024 17:17:48 +0000 (10:17 -0700)]
net: use correct address family when testing for MPTCP support
Before this patch, on a system that only supports IPv6, we would
get EAFNOSUPPORT and decide that MPTCP might be available later.
The effect is that every socket tries to get MPTCP. If the system
does not support MPTCP, every socket call turns into two system calls.
Also avoid the uname if MPTCP is not supported.
For #56539
Change-Id: I628b44eda83b455f5493a9dd59076f1acea2f65b
Reviewed-on: https://go-review.googlesource.com/c/go/+/616335 Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
runtime, internal/syscall/unix: mark getrandom vDSO as non-escaping
Updates #66779
Updates #69577
Change-Id: I0dea5a30aab87aaa443e7e6646c1d07aa865ac1c
GitHub-Last-Rev: 1cea46deb345369346efb2cb320fae1644466322
GitHub-Pull-Request: golang/go#69719
Reviewed-on: https://go-review.googlesource.com/c/go/+/616696
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Matt T. Proud [Sat, 28 Sep 2024 14:25:38 +0000 (14:25 +0000)]
errors: reference Go 1.13 article about errors
This commit amends package errors' documentation to include a reference
to the https://go.dev/blog/go1.13-errors blog article. The motivation
is multi-fold, but chiefly the article includes good information about
error philosophy (e.g., when to wrap), and developers who have come to
Go in the intervening five years are likely not have seen this article
at all given the nature of blog publishing and post fanfare. The
material deserves a promotion in visibility.
Change-Id: Ia6f8307784521dd59de3a3d638dbc0a7fcd445e6
GitHub-Last-Rev: 20980dd5070cde495ebb08386ae7b4cd78ccc612
GitHub-Pull-Request: golang/go#69698
Reviewed-on: https://go-review.googlesource.com/c/go/+/616341 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Jason A. Donenfeld [Mon, 30 Sep 2024 16:47:34 +0000 (18:47 +0200)]
runtime: use canonical wireguard-go repo for procyield() linkname usage
The source code quoted tailscale's development fork, which is only a
development fork. The canonical github url is actually
github.com/wireguard/wireguard-go, but that's really just a mirror of
git.zx2c4.com/wireguard-go, and in any case, the proper go package name
is golang.zx2c4.com/wireguard, so just use that.
Change-Id: Ifa63c1c538989b3fcebcf06d1c238469bc73724d
Reviewed-on: https://go-review.googlesource.com/c/go/+/616736
Auto-Submit: Jason Donenfeld <Jason@zx2c4.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Jason A. Donenfeld [Sun, 29 Sep 2024 02:24:00 +0000 (04:24 +0200)]
runtime: align vgetrandom states to cache line
This prevents false sharing, which makes a large difference on machines
with several NUMA nodes, such as this dual socket server:
cpu: Intel(R) Xeon(R) Gold 6338 CPU @ 2.00GHz
│ sec/op │ sec/op vs base │
ParallelGetRandom-128 0.7944n ± 5% 0.4503n ± 0% -43.31% (p=0.000 n=10)
│ B/s │ B/s vs base │
ParallelGetRandom-128 4.690Gi ± 5% 8.272Gi ± 0% +76.38% (p=0.000 n=10)
Change-Id: Id4421e9a4c190b38aff0be4c59e9067b0a38ccd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/616535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jason Donenfeld <Jason@zx2c4.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Sam Thanawalla [Wed, 28 Aug 2024 16:26:30 +0000 (16:26 +0000)]
cmd/go: add Mercurial based version stamping for binaries
This CL adds a local only VCS lookup for Mercurial.
It fixes a bug in pkg.go by passing in the repo directory to
the LookupLocal function instead of the module directory. It could be
the case that a binary is built in a subdirectory of the repo.
For: #50603
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ic36b5a361a8ba3b0ba1a6968cde5f5263c9c8dd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/609155
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
internal/testlog: use atomic.Pointer instead of atomic.Value
We know the type (*Interface), so we can use the generic atomic.Pointer.
This change also makes sure that concurrent use of SetLogger also
causes a panic, currently it races (Load, then Store).
Change-Id: I6fae5ce0587b37eede2060342c3fcd0cde4386ff
GitHub-Last-Rev: 0c053be03e22d4afcee235a247a377d7bd4d5aea
GitHub-Pull-Request: golang/go#69701
Reviewed-on: https://go-review.googlesource.com/c/go/+/616516 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change-Id: I73b0506c7a3245ba282cffabe47543f5fce86692
GitHub-Last-Rev: 4c6a1a4c706f39d2756c65b72b78896cd4881302
GitHub-Pull-Request: golang/go#69684
Reviewed-on: https://go-review.googlesource.com/c/go/+/616263
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
net,os: use os.LookupEnv instead of syscall.Getenv
The os package already has a function for retrieving an environment
variable with a ok boolean, we don't need to use syscall directly.
Change-Id: Ife873e7245261ec765b628e31a0e7a7bc4dff934
GitHub-Last-Rev: bc5f30bf56c87a94e0f17dd67a15aa4b2d7e3fd4
GitHub-Pull-Request: golang/go#69700
Reviewed-on: https://go-review.googlesource.com/c/go/+/616342 Reviewed-by: Michael Knyszek <mknyszek@google.com>
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>
net: improve documentation of netgo/netcgo build tags
Updates #69680
Change-Id: If80d43da493cb035164ede4a2cadcbec5831feaf
GitHub-Last-Rev: b3853e9487da1006ecece9dd378e3de299d0b1da
GitHub-Pull-Request: golang/go#69682
Reviewed-on: https://go-review.googlesource.com/c/go/+/616262
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
slices: prevent Clone keeping alive the array when cloning empty slices
Fixes #68488
Change-Id: I39aba22cdfe8ca0bbe69db7c64f1bca75fa067fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/598875 Reviewed-by: Keith Randall <khr@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Jason A. Donenfeld [Sun, 22 Sep 2024 01:45:29 +0000 (03:45 +0200)]
runtime: use vDSO for getrandom() on linux
Linux 6.11 supports calling getrandom() from the vDSO. It operates on a
thread-local opaque state allocated with mmap using flags specified by
the vDSO.
Opaque states are allocated in chunks, ideally ncpu at a time as a hint,
rounding up to as many fit in a complete page. On first use, a state is
assigned to an m, which owns that state, until the m exits, at which
point it is given back to the pool.
Performance appears to be quite good:
│ sec/op │ sec/op vs base │
Read/4-16 222.45n ± 3% 27.13n ± 6% -87.80% (p=0.000 n=10)
│ B/s │ B/s vs base │
Read/4-16 17.15Mi ± 3% 140.61Mi ± 6% +719.82% (p=0.000 n=10)
Fixes #69577.
Change-Id: Ib6f44e8f2f3940c94d970eaada0eb566ec297dc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/614835 Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Jason Donenfeld <Jason@zx2c4.com> Reviewed-by: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Change-Id: I780c5ed63561eb8fa998bb0e6cdc77a904ff29c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/615915 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Robert Griesemer [Fri, 27 Sep 2024 18:03:58 +0000 (11:03 -0700)]
go/types, types2: remove Checker.pos from types2 code - not needed anymore
In go/types, move field down in environment struct, rename it to
exprPos, and document use.
Updates #69673.
Change-Id: I355af1237f8cd731ad9706e6a5fce34b314978cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/616316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>