Michael Matloob [Mon, 5 Feb 2024 17:20:45 +0000 (12:20 -0500)]
internal/goroot: in IsStandardPackage check for go source files
Be more strict in IsStandardPackage: before this change we'd just
check for the existence of the directory, but now we check to see that
there's at least one .go file in the directory.
Also update some comments in the modindex package to reflect the fact
that an IndexPackage might represent a directory that does not contain
any source files.
Meng Zhuo [Mon, 5 Feb 2024 12:49:16 +0000 (20:49 +0800)]
test/codegen: add float max/min codegen test
As CL 514596 and CL 514775 adds hardware implement of float
max/min, we should add codegen test for these two CL.
Change-Id: I347331032fe9f67a2e6fdb5d3cfe20203296b81c
Reviewed-on: https://go-review.googlesource.com/c/go/+/561295 Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: M Zhuo <mengzhuo1203@gmail.com> Reviewed-by: David Chase <drchase@google.com>
Ian Lance Taylor [Wed, 7 Feb 2024 21:36:46 +0000 (13:36 -0800)]
slices: document that BinarySearch[Func] return earliest position
Fixes #65446
Change-Id: I08dc512fb1f0101eb8aac8767cdf582360699559
Reviewed-on: https://go-review.googlesource.com/c/go/+/562345 Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Ian Lance Taylor [Tue, 13 Dec 2022 22:51:17 +0000 (14:51 -0800)]
net: don't return errno from _C_res_nsearch
We ignore the value anyhow.
Change-Id: I1b1db7831c42bf852652236212812fd5cf258530
Reviewed-on: https://go-review.googlesource.com/c/go/+/457439 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Dominik Honnef [Sat, 20 Jan 2024 16:34:06 +0000 (17:34 +0100)]
internal/trace/v2: store stacks as PCs, not frames
Most stacks share some frames, especially prefixes, and deduplicating
them can save significant amounts of memory.
This will be especially true when we convert traces from the old to the
new format. Here, all stacks exist in a single generation and will be
live together.
For busy traces, such as one of running Staticcheck on std, with CPU
profiling enabled, this change saves ~400 MiB of memory.
Change-Id: Ie676f628dd2715e1c6077747dd4e08acf3331e5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/557355 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
qmuntal [Thu, 19 Oct 2023 16:06:27 +0000 (18:06 +0200)]
runtime,internal/syscall/windows: remove long path support check
The runtime currently enables long path support process-wide by updating
the process environment block (PEB). It then tries to create a file
using a long path to check if the PEB update made any difference.
There hasn't been any report that the PEB update was not effective,
and the check itself is quite tricky, so it's time to remove it.
While here, linkname `runtime.canUseLongPaths` to a variable in
internal/syscall/windows instead of the os package so it is easier to
consume from other packages.
Change-Id: I549380b7f2c242dc4db20d5be603840282de69b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/536495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com>
Andy Pan [Sat, 18 Nov 2023 10:59:51 +0000 (18:59 +0800)]
net: support benchmark testing for sendfile on various platforms
When I introduced the benchmark test code for sendfile(2) in CL 425878,
I only did it on Linux while the sendfile system call is also available
on other Unix-like and Windows platforms, this CL will pick up where I left out.
David Chase [Tue, 6 Feb 2024 17:48:15 +0000 (12:48 -0500)]
doc: move Go 1.22 release notes to x/website
Now that the development of the Go 1.22 release is almost done, its
release notes are moved to their eventual long-term home in x/website
in CL 562195. Delete the initial development copy here.
Change-Id: Ic8e44ee5d95ff121f96a53f6093fd8764abea004
Reviewed-on: https://go-review.googlesource.com/c/go/+/562155
Auto-Submit: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Robert Griesemer [Wed, 7 Feb 2024 17:12:05 +0000 (09:12 -0800)]
spec: fix typo in year (it's 2024 now)
While at it, set the date to the Go 1.22 release date.
Change-Id: I03872626e500433eb63786d24c67810c8c6289f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/562337
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Robert Griesemer [Wed, 7 Feb 2024 05:57:06 +0000 (21:57 -0800)]
go/types, types2: optimize Named type method lookup
Because methods associated with named types are in the
same package as the type, when looking up a method we
don't need to check the package repeatedly.
Rename the global lookupMethod function to methodIndex,
to match the corresponding fieldIndex function (cleanup).
Implement Named.methodIndex, optimized for method lookup
on named types (optimization).
Adjust call sites.
Change-Id: Ifa05306126773262b1af3ce73365b5742b470eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/562297
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Robert Griesemer [Wed, 31 Jan 2024 23:02:31 +0000 (15:02 -0800)]
go/types, types2: better errors for non-existing fields or methods
This CL improves the error messages reported when a field or method
name is used that doesn't exist. It brings the error messges on par
(or better) with the respective errors reported before Go 1.18 (i.e.
before switching to the new type checker):
Make case distinctions based on whether a field/method is exported
and how it is spelled. Factor out that logic into a new function
(lookupError) in a new file (errsupport.go), which is generated for
go/types. Use lookupError when reporting selector lookup errors
and missing struct field keys.
Add a comprehensive set of tests (lookup2.go) and spot tests for
the two cases brought up by the issue at hand.
Adjusted existing tests as needed.
Fixes #49736.
Change-Id: I2f439948dcd12f9bd1a258367862d8ff96e32305
Reviewed-on: https://go-review.googlesource.com/c/go/+/560055
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Bryan C. Mills [Thu, 1 Feb 2024 15:24:25 +0000 (10:24 -0500)]
cmd/go: avoid copying a binary to be exec'd in TestScript/gotoolchain_path
Runinng 'go build' writes the binary in a separate process, so avoids
the race described in #22315. However, the script engine's 'cp'
command currently executes in-process, so it does not avoid that bug
and may retain stale file descriptors when running tests in parallel.
Avoid the race in this particular test by giving the final binary
location in the '-o' argument instead of copying it there after the
fact.
Fixes #64019.
Change-Id: I96d276f33c09e39f465e9877356f1d8f2ae55062
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560415
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Than McIntosh [Mon, 5 Feb 2024 16:58:35 +0000 (11:58 -0500)]
dog/go1.22: tweak coverage testing notes
Clarify the section in the "go" command notes that deals with the
changes to "go test -cover" for packages without tests, adding a note
that if a package has not tests and no executable code, you still get
a "package has no test files" diagnostic.
Fixes #65262.
Change-Id: Ie960871f9d5c1a1965090738644eace28fc3e156
Reviewed-on: https://go-review.googlesource.com/c/go/+/561337 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Jonathan Amsterdam [Sat, 3 Feb 2024 16:48:50 +0000 (11:48 -0500)]
archive/zip: reduce memory held by Writer.Copy
Make a copy of the argument File's FileHeader, and pass a pointer
to the copy to CreateRaw.
Passing the pointer directly causes the entire `File` to be referenced
by the receiver. The `File` includes a reference to the `ReaderAt`
underlying the `Reader`, so all its memory, which may be the entire
contents of the archive, is prevented from being garbage-collected.
Also, explain the issue in the doc comment for CreateRaw. We
cannot change its behavior because someone may depend on the
preserving the identity of its argument pointer.
For #65499.
Change-Id: Ieb4963a0ea30539d597547d3511accbd8c6b5c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/560238
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
Jonathan Amsterdam [Mon, 5 Feb 2024 18:44:05 +0000 (13:44 -0500)]
doc/next: add release note file for api/next file
Change-Id: I3003968d9d7e543c25d4b0ab1d1cd924a1efd3ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/561456
Auto-Submit: Jonathan Amsterdam <jba@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Robert Griesemer [Tue, 30 Jan 2024 00:34:16 +0000 (16:34 -0800)]
go/types, types2: bail early if we want a type but don't have one
If we do know whether we need a type or not, make use of the
information when we know that we don't have a type and bail out.
Fixes the issue at hand and also improves some other error messages
which now report that we don't have a type instead of reporting a cycle.
For #65344.
Change-Id: I11182efd452c485d89e6c09ead8a647ea05d7318
Reviewed-on: https://go-review.googlesource.com/c/go/+/559335
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Jonathan Amsterdam [Thu, 1 Feb 2024 21:00:51 +0000 (16:00 -0500)]
cmd/relnote: fix API relnote check
Fix the check for release note files that correspond to API files
to look in the right directory, doc/next/*stdlib/*minor. Previously
the test looked in doc/next.
Improve the error messages when the test fails to explain the problem
better and refer to further documentation.
(These changes are actually in the x/build repo; this CL vendors
the latest version.)
Lastly, re-enable the check.
For #64169.
Change-Id: I8bba845e9bd12afbe269ce42d6d4b17b1e3c0252
Reviewed-on: https://go-review.googlesource.com/c/go/+/560516 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Bryan C. Mills [Thu, 1 Feb 2024 20:56:05 +0000 (15:56 -0500)]
cmd/go: fix tests that fail when running a cross-compiled GOARCH
In CL 356611 I changed cmd/go to run most of its tests (instead of
skipping them all) when cross-compiled, such as with GOARCH=386 on an
amd64 host. Unfortunately, since we don't have a CI builder that runs
long tests in a cross-compiled configuration, some of the tests have
rotted since then.
This fixes 'GOARCH=386 go test cmd/go' on my workstation.
For #64963.
Updates #53936.
Change-Id: If7f4bc8e8d1ace7d36010d7a1b652fc7b2ceb276
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560782
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@golang.org>
Ian Lance Taylor [Mon, 23 Oct 2023 21:32:44 +0000 (14:32 -0700)]
go/internal/gccgoimporter: recognize "any" as a builtin type
In CL 536715 we're changing the gofrontend export data to report
"any" as a builtin type. This permits us to distinguish the builtin
type from some other package-level type "any". That requires an update
to this code.
Change-Id: I91d75a056a155fa9892c4b25ab396cb4d39cc8e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/537195 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
Michael Pratt [Wed, 31 Jan 2024 22:56:47 +0000 (17:56 -0500)]
cmd/compile: avoid reading entire PGO profile just to check the header
isPreProfileFile reads the entire file into memory just to check the
first few bytes, and then throws it all away. We can avoid this by just
peeking at the beginning.
For #58102.
Change-Id: Id2c2844e5e44a2f3a9c7cdb9a027d94d26bdf71d
Reviewed-on: https://go-review.googlesource.com/c/go/+/560035 Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Michael Pratt [Fri, 2 Feb 2024 18:00:02 +0000 (13:00 -0500)]
runtime: initialize crashFD to -1
crashFD defaults to the zero value of (surprise!) zero. Zero is a valid
FD, so on the first call to SetCrashOutput we actually close FD 0 since
it is a "valid" FD.
Initialize crashFD to -1, the sentinel for "no FD".
Change-Id: I3b108c60603f2b83b867cbe079f035c159b6a6ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/560776 Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
cui fliter [Fri, 2 Feb 2024 09:30:03 +0000 (17:30 +0800)]
cmd/compile/internal: fix function names
Change-Id: Id9103aa4bda221f5eb34a0ede8676364c574b696
Reviewed-on: https://go-review.googlesource.com/c/go/+/560616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Michael Matloob [Wed, 31 Jan 2024 16:17:58 +0000 (11:17 -0500)]
cmd: update golang.org/x/telemetry to 1cb064e and vendor it
This brings in CL 559505 which adds a stub for counter.CountFlags so
it can be depended on and still build on Go 1.18 and earlier. This
will allow the go command to use counter.CountFlags and still be able
to build as the bootstrap command with an earlier version of Go.
Ehden Sinai [Thu, 1 Feb 2024 18:38:56 +0000 (13:38 -0500)]
cmd/go: fix build config before creating actions for 'go list -cover'
When -covermode is set to atomic, instrumented packages need to import
sync/atomic. If this is not already imported by a package being
instrumented, the build needs to ensure that sync/atomic is compiled
whenever 'go list' is run in a way that triggers package builds.
The build config was already being made to ensure the import, but only
after the action graph had been created, so there was no guarantee that
sync/atomic would be built when needed.
Michael Anthony Knyszek [Thu, 1 Feb 2024 05:32:03 +0000 (05:32 +0000)]
runtime: traceAcquire and traceRelease across all P steals
Currently there are a few places where a P can get stolen where the
runtime doesn't traceAcquire and traceRelease across the steal itself.
What can happen then is the following scenario:
- Thread 1 enters a syscall and writes an event about it.
- Thread 2 steals Thread 1's P.
- Thread 1 exits the syscall and writes one or more events about it.
- Tracing ends (trace.gen is set to 0).
- Thread 2 checks to see if it should write an event for the P it just
stole, sees that tracing is disabled, and doesn't.
This results in broken traces, because there's a missing ProcSteal
event. The parser always waits for a ProcSteal to advance a
GoSyscallEndBlocked event, and in this case, it never comes.
Fixes #65181.
Change-Id: I437629499bb7669bf7fe2fc6fc4f64c53002916b
Reviewed-on: https://go-review.googlesource.com/c/go/+/560235 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Michael Anthony Knyszek [Thu, 1 Feb 2024 05:10:32 +0000 (05:10 +0000)]
runtime: clear trace map without write barriers
Currently the trace map is cleared with an assignment, but this ends up
invoking write barriers. Theoretically, write barriers could try to
write a trace event and eventually try to acquire the same lock. The
static lock ranking expresses this constraint.
This change replaces the assignment with a call to memclrNoHeapPointer
to clear the map, removing the write barriers.
Note that technically this problem is purely theoretical. The way the
trace maps are used today is such that reset is only ever called when
the tracer is no longer writing events that could emit data into a map.
Furthermore, reset is never called from an event-writing context.
Therefore another way to resolve this is to simply not hold the trace
map lock over the reset operation. However, this makes the trace map
implementation less robust because it needs to be used in a very
specific way. Furthermore, the rest of the trace map code avoids write
barriers already since its internal structures are all notinheap, so
it's actually more consistent to just avoid write barriers in the reset
method.
Fixes #56554.
Change-Id: Icd86472e75e25161b2c10c1c8aaae2c2fed4f67f
Reviewed-on: https://go-review.googlesource.com/c/go/+/560216 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Michael Anthony Knyszek [Thu, 1 Feb 2024 04:47:22 +0000 (04:47 +0000)]
runtime: model wakeableSleep.lock in the race detector
Currently the flight recorder tests are failing in race mode because the
race detector doesn't see s.lock, leading to false positives. This has
also appeared in the trace tests. Model the lock in the race detector.
Fixes #65207.
Fixes #65283.
Change-Id: I1e9a5c9606536f55fdfc46b5f8443e9c7213c23d
Reviewed-on: https://go-review.googlesource.com/c/go/+/560215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Michael Anthony Knyszek [Thu, 21 Dec 2023 20:26:38 +0000 (20:26 +0000)]
runtime: fix trace EvGoStop Gosched reason to match function
Currently the stop reason for runtime.Gosched is labeled
"runtime.GoSched" which doesn't actually match the function name. Fix
the label to match the function name.
This change doesn't regenerate the internal/trace/v2 tests, because
regenerating the tests breaks summarization tests in internal/trace that
rely on very specific details in the example traces that aren't
guaranteed. Also, go122-gc-trace.test isn't generated at all, as it
turns out. I'll fix this all up in a follow-up CL. For now, just replace
runtime.GoSched with runtime.Gosched in the traces so we don't have a
problem later if a test wants to look for that string.
This change does regenerate the cmd/trace/v2 test, but it turns out the
cmd/trace/v2 tests are way too strict about network unblock events, and
3 usually pop up instead of 1 or 2, which is what the test expects.
AFAICT this looks plausible to me, so just lift the restriction on
"up to 2" events entirely.
Change-Id: Id7350132be19119c743c259f2f5250903bf41a04
Reviewed-on: https://go-review.googlesource.com/c/go/+/552275
TryBot-Bypass: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Bryan C. Mills [Thu, 1 Feb 2024 18:53:46 +0000 (13:53 -0500)]
cmd/go: limit GOMAXPROCS in TestScript/test_fuzz_.*
This limits the throughput and resource consumption of the fuzz
workers in the tests, which also reduces the likelihood of running out
of address space in the fuzz coordinator during the test.
(Ideally the coordinator should not be limited by address space;
this just works around the failure mode in the tests for now.)
For #65434.
Change-Id: I3086c6278d6803a3dbf17a46ed01b68cedc92ad9
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/560515 Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Michael Pratt [Wed, 6 Dec 2023 19:20:49 +0000 (14:20 -0500)]
internal/profile: remove legacy profile support
internal/profile.Parse is only used in two places: cmd/compile for
parsing PGO profiles, and net/http/pprof for parsing runtime/pprof
profiles for delta profiles. Neither case ever encounters legacy
profiles, so we can remove support entirely from the package.
Dmitri Shuralyov [Wed, 31 Jan 2024 18:30:50 +0000 (13:30 -0500)]
doc/go1.22: move go/version package mention into a separate heading
It's a new package in the standard library,
not a minor change to an existing package.
For #62039.
For #61422.
Change-Id: I7488304cd2bd6353f535cab192d015796840ba4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/559799
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
codesoap [Wed, 31 Jan 2024 18:31:56 +0000 (18:31 +0000)]
container/heap: remove confusing claim of memory leak
The term "memory leak" was misused here, as the memory is still referenced
by the slice.
Fixes #65403
Change-Id: Id102419d4c798fb2a4ec8be86be9ec9b5cdd98e6
GitHub-Last-Rev: 3febcd0ba4ab5897bef8f2d7ded594ef09932771
GitHub-Pull-Request: golang/go#65404
Reviewed-on: https://go-review.googlesource.com/c/go/+/559775
Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Robert Griesemer [Wed, 31 Jan 2024 01:16:12 +0000 (17:16 -0800)]
go/token: correct out-of-bounds token offsets and positions
Per the discussion on the issue, make methods that depend on
incoming offsets or positions tolerant in the presence of
out-of-bounds values by adjusting the values as needed.
Add an internal flag debug that can be set to enable the old
(not fault-tolerant) behavior.
Fixes #57490.
Change-Id: I8a7d422b9fd1d6f0980fd4e64da2f0489056d71e
Reviewed-on: https://go-review.googlesource.com/c/go/+/559436 Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Russ Cox [Wed, 24 Jan 2024 21:29:20 +0000 (16:29 -0500)]
go/version: fix package to accept go1.21.0-bigcorp
The proposal discussion made clear that suffixes should be accepted,
so that people who use custom VERSION files can still pass runtime.Version()
to this code. But we forgot to do that in the CL. Do that.
Note that cmd/go also strips space- and tab-prefixed suffixes,
but go.dev/doc/toolchain only mentions dash, so this code only
strips dash.
Fixes #65061.
Change-Id: I6a427b78f964eb41c024890dae30223beaef13eb
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/559796
TryBot-Bypass: Russ Cox <rsc@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Alan Donovan [Thu, 7 Dec 2023 23:02:40 +0000 (18:02 -0500)]
runtime/debug: SetCrashOutput sets the FD for fatal panics
This feature makes it possible to record unhandled panics
in any goroutine through a watchdog process (e.g. the same
application forked+exec'd as a child in a special mode)
that can process the panic report, for example by sending
it to a crash-reporting system such as Go telemetry
or Sentry.
Fixes #42888
Change-Id: I5aa7be8f726bbc70fc650540bd1a14ab60c62ecb
Reviewed-on: https://go-review.googlesource.com/c/go/+/547978 Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
Cherry Mui [Thu, 30 Nov 2023 00:17:22 +0000 (19:17 -0500)]
runtime: preempt more aggressively when panicking
When we are crashing from an unrecovered panic, we freeze the
world, and print stack traces for all goroutines if GOTRACEBACK is
set to a high enough level. Freezing the world is best effort, so
there could still be goroutines that are not preempted, and so its
stack trace is unavailable and printed as "goroutine running on
other thread".
As we're crashing and not resuming execution on preempted
goroutines, we can make preemption more aggressive, preempting
cases that are not safe for resumption or stack scanning. This may
make goroutines more likely to be preempted in freezing the world
and have their stacks available.
Change-Id: Ie16269e2a05e007efa61368b695addc28d7a97ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/546135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Russ Cox [Mon, 29 Jan 2024 17:00:10 +0000 (12:00 -0500)]
fmt: revert "don't pad strings with zeros"
This reverts CL 555776 (commit 704401ffa06).
Scores of tests break inside Google, and there was a test for the old behavior,
so clearly we thought it was correct at one point.
// IPv4toISO create ISO address base on a given IPv4 address.
func IPv4toISO(v4 string) (string, error) {
if net.ParseIP(v4).To4() == nil {
return "", fmt.Errorf("invalid IPv4 address")
}
s := strings.Split(v4, ".")
var ss string
for _, n := range s {
ss = ss + fmt.Sprintf("%03s", n)
}
if len(ss) != 12 {
return "", fmt.Errorf("invalid IPv4 address")
}
return fmt.Sprint("49.0001." + ss[0:4] + "." + ss[4:8] + "." + ss[8:12] + ".00"), nil
}
This is doing the weird but apparently standard conversion from
IPv4 to ISO ISIS Area 1 (see for example [1]).
Here is an example from github.com/netbirdio/netbird:
base62.Encode returns a string no leading zeros; the %06s adds leading zeros.
Are there other ways to write these examples? Yes.
Has all this code worked until now? Also yes.
The change to this behavior observed that right padding doesn't
add zeros, only left padding, but that makes sense: in numbers
without decimal points, zeros on the left preserve the value
while zeros on the right change it.
Since we agree that this case is probably not important either way,
preserve the long-time behavior of %0s.
Will document it in a followup CL: this is a clean revert.
Andy Pan [Wed, 24 Jan 2024 03:22:14 +0000 (11:22 +0800)]
net/textproto: reject HTTP requests with empty header keys
According to RFC 7230, empty field names in HTTP header are invalid.
However, there are no specific instructions for developers to deal
with that kind of case in the specification. CL 11242 chose to skip
it and do nothing about it, which now seems like a bad idea because
it has led `net/http` to behave inconsistently with the most widely-used
HTTP implementations: Apache, Nginx, Node with llhttp, H2O, Lighttpd, etc.
in the case of empty header keys.
There is a very small chance that this CL will break a few existing HTTP clients.
Fixes #65244
Change-Id: Ie01e9a6693d27caea4d81d1539345cf42b225535
Reviewed-on: https://go-review.googlesource.com/c/go/+/558095 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Alan Donovan [Fri, 26 Jan 2024 16:19:22 +0000 (11:19 -0500)]
doc/README: clarify instructions
- State that new markdown files belong in doc/next.
- Give hints on correct markdown syntax.
For #64169
Change-Id: Ied70e7ac443530c910eea2992ca6e303bbc10499
Reviewed-on: https://go-review.googlesource.com/c/go/+/558855 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Matthew Dempsky [Thu, 25 Jan 2024 23:51:22 +0000 (15:51 -0800)]
cmd/compile/internal/noder: preserve alias uses in export data
This CL changes the export data format to preserve alias uses.
Previously they were stripped away with types2.Unalias. For backwards
compatibility, we use pkgbits.TypeNamed, which is already used for the
predeclared aliases byte, rune, and any.
While here, remove unnecessary uses of types2.Unalias, and add a
missing one in recvBase to handle:
type T int
type A = T
func (*A) m() {}
Change-Id: I62ddb0426080a44436054964a90ab250bcd8df12
Reviewed-on: https://go-review.googlesource.com/c/go/+/558577 Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Keith Randall [Mon, 3 Jul 2023 20:49:26 +0000 (13:49 -0700)]
runtime: print exported methods from the runtime in tracebacks
We currently suppress runtime frames in tracebacks, except for
exported functions.
This CL also prints exported methods of exported types
in tracebacks, for consistency.
Change-Id: Ic65e7611621f0b210de5ae0c02b9d0a044f39fd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/507736 Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Michael Pratt [Tue, 30 Jan 2024 16:01:05 +0000 (11:01 -0500)]
runtime: avoid new linkname for goroutine profiles
CL 464349 added a new linkname to provide gcount to runtime/pprof to
avoid a STW when estimating the goroutine profile allocation size.
However, adding a linkname here isn't necessary for a few reasons:
1. We already export gcount via NumGoroutines. I completely forgot about
this during review.
2. aktau suggested that goroutineProfileWithLabelsConcurrent return
gcount as a fast path estimate when the input is empty.
The second point keeps the code cleaner overall, so I've done that.
For #54014.
Change-Id: I6cb0811a769c805e269b55774cdd43509854078e
Reviewed-on: https://go-review.googlesource.com/c/go/+/559515
Auto-Submit: Michael Pratt <mpratt@google.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com> Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Alessandro Arzilli [Wed, 24 Jan 2024 17:10:47 +0000 (18:10 +0100)]
cmd/link: add DW_AT_go_runtime_type to unsafe.Pointer and fix it for
uintptr
Adds the DW_AT_go_runtime_type attribute to the debug_info entry for
unsafe.Pointer (which is special) and fixes the debug_info entry of
uintptr so that its DW_AT_go_runtime_type attribute has the proper
class (it was accidentally using DW_CLS_ADDRESS instead of
DW_CLS_GO_TYPEREF)
Change-Id: I52e18593935fbda9bc425e849f4c7f50e9144ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/558275 Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
Michael Pratt [Mon, 29 Jan 2024 23:57:14 +0000 (23:57 +0000)]
Revert "runtime: disable use of runnext on wasm"
This reverts CL 557437.
Reason for revert: Appears to have broken wasip1 builders.
For #65178.
Change-Id: I59c1a310eb56589c768536fe444c1efaf862f8b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/559237
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Michael Pratt [Mon, 22 Jan 2024 22:50:44 +0000 (17:50 -0500)]
runtime: disable use of runnext on wasm
When readying a goroutine, the scheduler typically places the readied
goroutine in pp.runnext, which will typically be the next goroutine to
run in the schedule.
In order to prevent a set of ping-pong goroutines from simply switching
back and forth via runnext and starving the rest of the run queue, a
goroutine scheduled via runnext shares a time slice (pp.schedtick) with
the previous goroutine.
sysmon detects "long-running goroutines", which really means Ps using
the same pp.schedtick for too long, and preempts them to allow the rest
of the run queue to run. Thus this avoids starvation via runnext.
However, wasm has no threads, and thus no sysmon. Without sysmon to
preempt, the possibility for starvation returns. Avoid this by disabling
runnext entirely on wasm. This means that readied goroutines always go
on the end of the run queue and thus cannot starve via runnext.
Note that this CL doesn't do anything about single long-running
goroutines. Without sysmon to preempt them, a single goroutine that
fails to yield will starve the run queue indefinitely.
For #65178.
Cq-Include-Trybots: luci.golang.try:gotip-js-wasm,gotip-wasip1-wasm_wasmtime,gotip-wasip1-wasm_wazero
Change-Id: I7dffe1e72c6586474186b72f8068cff77b661eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/557437
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
Michael Pratt [Thu, 25 Jan 2024 20:39:09 +0000 (15:39 -0500)]
net/http: allow nothingWrittenError in TestTransportPersistConnReadLoopEOF
Flakes in #64317 are a result of a race where the server shutdown
schedules ahead of the client read loop. Normal network latency usually
hides this, but wasm's net_fake.go has very low latency.
Explicitly allow the results of this race in the test.
For #64317.
Change-Id: I9c2572fb44643762fe3f3d7cb133d7e7a8a47881
Reviewed-on: https://go-review.googlesource.com/c/go/+/558595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Bryan C. Mills [Fri, 26 Jan 2024 17:23:01 +0000 (12:23 -0500)]
net: in the fake implementation, allow writes to buffer on closed connections
This mimics the apparent behavior of writes on linux/amd64, in which a
write on an already-closed connection silently succeeds — even if the
connection has already been closed by the remote end — provided that
the packet fits in the kernel's send buffer.
I tested this by patching in CL 557437 and running the test on js/wasm
and wasip1/wasm locally.
Fixes #64317.
Change-Id: I43f6a89e5059115cb61e4ffc33a8371057cb67a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/558915
Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Michael Matloob [Wed, 3 Jan 2024 19:23:49 +0000 (14:23 -0500)]
cmd/go/internal/list: make a copy of the package before zeroing fields
go list -json=<fields> zeroes out the fields in the package struct
that aren't specified. The problem with this is that some of the fields
have references into other fields: specifically, the NoGoError's
Error() function accesses the package struct's Dir field, so if we
clear it out the error will just print out "no Go files in" without a
directory. Instead, make a copy of the package struct before we zero
out the fields so the original values are still there.
Michael Pratt [Tue, 23 Jan 2024 18:29:23 +0000 (13:29 -0500)]
runtime: use channels in gcBgMarkStartWorkers
gcBgMarkStartWorkers currently starts workers one at a time, using a
note to communicate readiness back from the worker.
However, this is a pretty standard goroutine, so we can just use a
channel to communicate between the goroutines.
In addition to being conceptually simpler, using channels has the
additional advantage of coordinating with the scheduler. Notes use OS
locks and sleep the entire thread, requiring other threads to run the
other goroutines. Waiting on a channel allows the scheduler to directly
run another goroutine. When the worker sends to the channel, the
scheduler can use runnext to run gcBgMarkStartWorker immediately,
reducing latency.
We could additionally batch start all workers and then wait only once,
however this would defeate runnext switching between the workers and
gcBgMarkStartWorkers, so in a heavily loaded system, we expect the
direct switches to reduce latency.
Change-Id: Iedf0d2ad8ad796b43fd8d32ccb1e815cfe010cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/558535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Robert Griesemer [Wed, 24 Jan 2024 20:42:11 +0000 (12:42 -0800)]
go/types, types2: use existing case-insensitive lookup (remove TODO)
Rather than implementing a new, less complete mechanism to check
if a selector exists with different capitalization, use the
existing mechanism in lookupFieldOrMethodImpl by making it
available for internal use.
Pass foldCase parameter all the way trough to Object.sameId and
thus make it consistently available where Object.sameId is used.
From sameId, factor out samePkg functionality into stand-alone
predicate.
Do better case distinction when reporting an error for an undefined
selector expression.
Cleanup.
Change-Id: I7be3cecb4976a4dce3264c7e0c49a320c87101e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/558315 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>