1
0
mirror of https://github.com/golang/go synced 2024-11-06 09:26:18 -07:00
Commit Graph

45222 Commits

Author SHA1 Message Date
Ian Lance Taylor
351e0f4083 runtime: avoid fma in mkfastlog2table
This lets us generate identical copies of fastlog2table.go on all hosts.

Tested by regenerating fastlog2table.go on linux-amd64 and darwin-arm64.

Fixes #49891

Change-Id: I279d6b5abb5a5290c049d9658050fd9c8d0c0190
Reviewed-on: https://go-review.googlesource.com/c/go/+/413976
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-26 22:12:19 +00:00
Robert Griesemer
666d736ecb cmd/compile: do branch/label checks only once
The previous change implemented the missing fallthrough checking
in the parser. Therefore we can now disable the duplicate check
in the type checker:

- rename (types2.Config.)IngoreLabels to IgnoreBranches to more
  accurately reflect its functionality

- now also ignore break/continue/fallthroughs, not just labels

The IgnoreBranches flag only exists for types2, for use with
the compiler. There's no need to port this code to go/types.

Note: An alternative (and perhaps better) approach would be
to not use the the parser's CheckBranches mode and instead
enable (i.e. not disable) the branch/label checking in the
type checker. However, this requires a bit more work because
the type checker's error messages about goto's jumping over
variables don't have access to the variable names, which are
desired in the error messages.

Fixes #51456.

Change-Id: Ib2e71e811d4e84e4895b729646e879fd43b12dcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/414135
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-26 00:21:33 +00:00
Robert Griesemer
6b309be7ab cmd/compile/internal/syntax: check fallthrough in CheckBranches mode
The parser CheckBranches mode checked correct use of break, continue,
and labels, but not of fallthrough statements.

This CL adds checking of fallthrough statements as well.

For #51456.

Change-Id: I5000388011973724f80c59a6aaf015e3bb70faea
Reviewed-on: https://go-review.googlesource.com/c/go/+/414134
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-26 00:21:29 +00:00
Khaled Yakdan
1821639b57 runtime: mark string comparison hooks as no split
These functions can be inserted by the compiler into the code to be
instrumented. This may result in these functions having callers that
are nosplit. That is why they must be nosplit.

This is a followup for CL 410034 in order to fix #53190.

Change-Id: I03746208a2a302a581a1eaad6c9d0672bb1e949a
GitHub-Last-Rev: 6506d86f22
GitHub-Pull-Request: golang/go#53544
Reviewed-on: https://go-review.googlesource.com/c/go/+/413978
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-06-25 21:33:56 +00:00
HowJMay
3b594b9255 io: clarify SeekEnd offset value
fixes #53474

Change-Id: I14c3dc800dc27233630a54592328bb0df1bbaa5d
GitHub-Last-Rev: 46f93cfbd4
GitHub-Pull-Request: golang/go#53505
Reviewed-on: https://go-review.googlesource.com/c/go/+/413614
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-25 19:08:51 +00:00
qmuntal
4f45ec5963 cmd/go: prepend builtin prolog when checking for preamble errors
Fixes #50710

Change-Id: I62feddbe3eaae9605d196bec60d378614436603a
Reviewed-on: https://go-review.googlesource.com/c/go/+/379754
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-06-25 19:07:01 +00:00
Rémy Oudompheng
41e1d9075e strconv: avoid panic on invalid call to FormatFloat
Calling FormatFloat with an invalid value of fmt is expected
to return a string containing '%' and the input fmt character.
Since even before Go 1.0, the code has been panicking in the
case where prec=0.

Fixes #52187

Change-Id: I74fec601eedb7fe28efc5132c4253674661452aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/402817
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-24 23:50:20 +00:00
Rhys Hiltner
bd4753905d internal/trace: add Go 1.19 test data
Update instructions to match what seems to be the historical practice:
to generate canned traces when a version is finalized, rather than
waiting until it is superseded.

Follow rename of trace-internal tests from "Span" to "Region". Update
the net/http test invocation to match the apparent intent and the actual
http_1_5_good behavior (about 7ms of total run time and trace file size
under 50kB).

Change-Id: Ifd4c85882159478852e0b8f0d771b6f16b8f3c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/413776
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-24 22:08:17 +00:00
Bryan C. Mills
6b6c64b1cc cmd/internal/archive: don't rely on an erroneous install target in tests
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.
This change switches the 'go install' command to instead use
'go build -buildmode=archive' with an explicit archive path.

For #37015.

Change-Id: Ib0c8f213100b6473a7657af96f31395703e28493
Reviewed-on: https://go-review.googlesource.com/c/go/+/414055
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-06-24 21:22:43 +00:00
Michael Matloob
5a1c5b8ae7 cmd/go: add per-package indexing for modules outside mod cache
Packages outside the module cache including the standard library will be
indexed individually rather than as a whole module.

For #52876

Change-Id: I142dad6a790e9e8eb4dc6430a588fbfa86552e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/413815
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-24 19:58:23 +00:00
Sean Liao
b9c4d94fdb cmd/go/internal/list: update help info with Deprecated field
Also align Retracted documentation with actual type of []string

Fixes #51876

Change-Id: I3b34e53424aa7ee5330eb71adac23510fff91798
Reviewed-on: https://go-review.googlesource.com/c/go/+/394677
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-06-24 18:54:27 +00:00
Robert Griesemer
73475ef035 go/types, types2: print qualified object names in cycle errors
Fixes #50788.

Change-Id: Id1ed7d9c0687e3005e28598373fd5634178c78ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/413895
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-24 17:48:24 +00:00
Robert Griesemer
3e58ef6cc7 go/types, types2: better errors for == when type sets are empty
For #51525.

Change-Id: I3762bc4a48a1aaab3b006b1ad1400f866892243c
Reviewed-on: https://go-review.googlesource.com/c/go/+/413934
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-24 17:45:41 +00:00
Than McIntosh
de5329f1de debug/dwarf: handle malformed line table with bad program offset
Touch up the line table reader to ensure that it can detect and reject
an invalid program offset field in the table header.

Fixes #53329.

Change-Id: Ia8d684e909af3aca3014b4a3d0dfd431e3f5a9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/413814
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-23 19:05:29 +00:00
tulip
15605ca827 embed: document additional file name restrictions
For #44486

Change-Id: I66af9f7a9f95489a41fd6710e50bdd7878f78b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/413494
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-23 16:32:40 +00:00
Wayne Zuo
ff17b7d0d4 cmd/compile: don't use dictionary convert to shaped empty interface
Fixes: #53254

Change-Id: I3153d6ebb9f25957b09363f45c5cd4651ee84c2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410655
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-06-22 22:14:02 +00:00
Dmitri Goutnik
2a3b467d5f cmd/go: make module .zip files group/world readable
os.CreateTemp in downloadZip leaves downloaded .zip files readable only
by the owner. Make them group/world readable.

Fixes #52765

Change-Id: Iace13e4ad813201a533a1a5fc0c6d9b2e5349a42
Reviewed-on: https://go-review.googlesource.com/c/go/+/404854
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-06-22 21:27:19 +00:00
Ian Lance Taylor
bdab4cf47a cmd/go, cmd/link: support failure to create _cgo_import.go
For a package that uses cgo, the file _cgo_import.go is created to
record information required for internal linking: the non-Go dynamic
symbols and libraries that the package depends on. Generating this
information sometimes fails, because it can require recreating all the
dependencies of all transitively imported packages. And the
information is rarely needed, since by default we use external linking
when there are packages outside of the standard library that use cgo.

With this CL, if generating _cgo_import.go fails, we don't report an
error. Instead, we mark the package as requiring external linking, by
adding an empty file named "dynimportfail" into the generated archive.
If the linker sees a file with that name, it rejects an attempt to use
internal linking.

Fixes #52863

Change-Id: Ie586e6753a5b67e49bb14533cd7603d9defcf0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/413460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-22 20:56:07 +00:00
Bryan C. Mills
aca37d16a5 cmd/go: avoid indexing modules in GOROOT
Scanning GOROOT modules for changes appears to be causing Windows
builders to time out in x/tools tests. We may try a per-package index
instead, but for now just skip GOROOT modules (as we do for main
modules).

Fixes #53493.

Change-Id: Ic5bb90b4ce173a24fc6564e85fcde96e1f9b975f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-06-22 19:56:09 +00:00
Guoqi Chen
111cdb5848 all: update to current golang.org/x/sys revision
go get -d golang.org/x/sys@6c1b26c55098eae66ce95ab7c3712ab6cbfff2b7
go mod tidy
go mod vendor

This fixes the problem of the second return value in syscall on linux/loong64.

Change-Id: I8018ae96f4e5ca9779b2c053cdccc6b2866bf0de
Reviewed-on: https://go-review.googlesource.com/c/go/+/412274
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-22 16:47:18 +00:00
Wayne Zuo
4045b1bc3f cmd/compile: fix assert condition in generic method call
Fixes #53406.

Change-Id: If7ae39ec1042a792d82a0a2de96d168c22d8ab71
Reviewed-on: https://go-review.googlesource.com/c/go/+/412614
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
Auto-Submit: Alex Rakoczy <alex@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
2022-06-22 16:25:18 +00:00
Ian Lance Taylor
6bad7e8243 compress/gzip: always close bodyReader in Example_compressingReader
For #53362
Fixes #53414

Change-Id: I352164e70c136eed210c7ee4ceba5dc631f81f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/412955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-22 16:24:14 +00:00
shaoliming
606c6c371a encoding/xml: check nil pointer in DecodeElement
Fixes #53350

Change-Id: Id5e1f4016db5f1d4349ee1a76a9dfe3aeae83cee
GitHub-Last-Rev: 45add12161
GitHub-Pull-Request: golang/go#53407
Reviewed-on: https://go-review.googlesource.com/c/go/+/412634
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
2022-06-22 16:23:59 +00:00
kkHAIKE
f571518139 cmd/cgo: dont override declared struct type
Fixes #52611

Change-Id: I835df8d6a98a37482446ec00af768c96fd8ee4fe
GitHub-Last-Rev: ea54dd69ee
GitHub-Pull-Request: golang/go#52733
Reviewed-on: https://go-review.googlesource.com/c/go/+/404497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dexter Ouyang <kkhaike@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-22 16:21:49 +00:00
Ian Lance Taylor
92c9b81447 net: don't set netGo = true on Windows with no cgo
Windows can call the C DNS lookup routines even without cgo,
so don't force it to use the Go routines in that scenario.

No test because the test requires building the tools with CGO_ENABLED=0.

For #33097
Fixes #53490

Change-Id: I3595a68e788be0d3bbd1bbd431836aca20a7d757
Reviewed-on: https://go-review.googlesource.com/c/go/+/413458
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-22 16:18:44 +00:00
Alan Donovan
be0b2a393a cmd/trace: add basic documentation to main page
This change adds rudimentary explanation of the various
visualizations to main page of the trace server.
There is clearly a vast amount one could write here,
especially in the form of tutorials, but I've tried to
restrict it to just basic conceptual overview.

Change-Id: Id4dfe9d47f9b31ed5f8fe39f8b3a7c60c0ae8d5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/412876
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-22 02:40:04 +00:00
Robert Griesemer
b004c739b5 go/types, types2: fix parameter order dependence in type inference
If we have more than two function arguments to a generic function,
we may have arguments with named and unnamed types. If that is the
case, permutate params and args such that the arguments with named
types are first in the list. This way, independent of parameter
ordering, the type inference will produce the same result.

This extra step is not explicitly outlined in the spec yet but we
all agree that (parameter) order independence is an invariant that
we should uphold for type inference. As we move towards less
operational and more descriptive rules for type inference, we will
incorporate this property as well.

The actual fix for this bug existed before 1.18 but was not enabled.
This CL merely enables the fix (switches a flag) and adjusts some
tests.

Fixes #43056.

Change-Id: Ie4e40cf8438dfd82fa94b78068e4f6f6f53f83e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/413459
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-22 00:14:46 +00:00
Rhys Hiltner
ab422f2749 runtime/trace: ignore fallback stacks in test
When runtime.sigprof encounters a stack that gentraceback is unable to
process, it synthesizes a call stack with a sentinel function (such as
runtime._System) at the leaf.

The test to confirm that runtime/trace and runtime/pprof have similar
views of CPU profile samples has trouble with those stacks. The test
confirms that the samples match by confirming that their symbolized
forms match, and the symbolization procedure is very different for the
two packages.

Skip the samples that the CPU profiler's view symbolizes to include one
of runtime.sigprof's sentinel functions at the leaf. (The test design
expects the CPU profiler to under-report samples relative to the
execution tracer.)

Fixes #53378

Change-Id: I60c27de4c69b454057d28a3b6e12d70369de4c4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/413457
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-21 22:05:17 +00:00
Michael Anthony Knyszek
4b236b45d0 runtime: convert flaky semaphore linearity test into benchmark
Also, add a benchmark for another case that was originally tested.

Also also, remove all the dead code this now creates.

Fixes #53428.

Change-Id: Idbba88d3d31d38a8854fd5ed99001e394da27300
Reviewed-on: https://go-review.googlesource.com/c/go/+/412878
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2022-06-21 19:37:22 +00:00
Bryan C. Mills
530511bacc cmd/go/internal/modindex: avoid walking modules when not needed
Due to a missed condition in CL 412394, we were walking all modules
(instead of just the ones contained in GOROOT) at each invocation of a
devel version of cmd/go.

Moreover, while we were running cmd/go tests, we were re-walking
GOROOT at each 'go' invocation in the test even though we expect
GOROOT to be stable within a test run.

This change always avoids walking non-GOROOT modules, and also adds a
salt (configurable via GODEBUG) and uses it to avoid walking GOROOT
modules when GOROOT is known to be stable (such as over the course of
a 'cmd/go' test run).

This should fix the cmd/go test timeouts that are currently occurring
on the dragonfly-amd64 builder, such as this one:
https://build.golang.org/log/21c01c3ae5490d387d84abeaf872b3a0a76ab8e5

Updates #53290.

Change-Id: Ic807d215831a3cd21c63e0bccd3d7acd10d8f2b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/412779
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-06-21 17:32:57 +00:00
Keith Randall
c2d373d5d1 cmd/compile: allow 128-bit values to be spilled
We sometimes use 16-byte load+store to move values around in memory.
In rare circumstances, the loaded value must be spilled because the
store can't happen yet.

In that case, we need to be able to spill the 16-byte value.

Fixes #53454

Change-Id: I09fd08e11a63c6ba3ef781d3f5ede237e9b0132e
Reviewed-on: https://go-review.googlesource.com/c/go/+/413294
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-06-21 17:23:40 +00:00
Matthew Dempsky
19ed442807 test: add regress test for #53477
This test already passes for GOEXPERIMENT=unified; add regress test to
ensure it stays that way.

Updates #53477.

Change-Id: Ib7aa7428260595077052207899edcc044a6ab1c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/413394
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-06-21 15:00:37 +00:00
Cuong Manh Le
527ace0ffa cmd/compile: skip substituting closures in unsafe builtins arguments
For unsafe.{Alignof,Offsetof,Sizeof}, subster will transform them them
to OLITERAL nodes, and discard their arguments. However, any closure in
their children nodes were already processed and added to declaration
queue. Thus, we lack of information for generating instantiation for
the closure.

To fix it, just skip substituting the closures if we are going to edit
the children nodes of unsafe builtins.

Fixes #53390

Change-Id: Ia815cd05af9dc0491f10faac4399f378ac53dec6
Reviewed-on: https://go-review.googlesource.com/c/go/+/412794
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-06-18 00:48:50 +00:00
Matthew Dempsky
ec58e3f327 test: add regress test for #53419
This currently works with GOEXPERIMENT=unified. Add a regress test to
make sure it stays that way.

Updates #53419.

Change-Id: I2ea1f9039c59807fbd497d69a0420771f8d6d035
Reviewed-on: https://go-review.googlesource.com/c/go/+/413014
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-17 22:44:22 +00:00
Josh Powers
103cc661f1 cmd/go/internal/modfetch: prevent duplicate hashes in go.sum
To write go.sum, each module and then each hash is looped through. The
hashes are kept in a slice and there is no check to ensure that hashes
were not added or already exist in the file. Therefore, unique the
hashes of each module before writing to prevent duplicates.

Fixes: #28456

Change-Id: I1cf7e7cdee3e7530a0ee605cd76d738627be1e0d
GitHub-Last-Rev: 0ed02e9591
GitHub-Pull-Request: golang/go#53291
Reviewed-on: https://go-review.googlesource.com/c/go/+/411154
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-17 21:38:40 +00:00
Kevin Burke
d42a48828f sync: add more notes about Cond behavior
Cond is difficult to use correctly (I was just bitten by it in
a production app that I inherited). While several proposals have come
up to improve or remove sync.Cond, no action has so far been taken.

Update the documentation to discourage use of sync.Cond, and point
people in the direction of preferred alternatives. I believe this will
help encourage behavior we want (less use of sync.Cond and more use of
channels), while also paving the way for, potentially, removing Cond
in a future version of the language.

Thanks very much to Bryan Mills and Sean Liao for discussion and
recommendations.

Updates #20491.
Updates #21165.

Change-Id: Ib4d0631c79d4c4d0a30027255cd43bc47cddebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412237
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-17 21:35:36 +00:00
Bryan C. Mills
9e2f289754 cmd/go/internal/work: log clearer detail for subprocess errors in (*Builder).toolID
For #52647.

Change-Id: Ic12123769d339c2df677500ed59f15a4ee5037d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412954
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-17 21:21:58 +00:00
Dmitri Goutnik
dd2d00f9d5 net: fix flaky *TimeoutMustNotReturn tests
The tester goroutine doesn't always gets a chance to run before the
timeout expires. Wait for the goroutine to start and set deadlines
before staring the timer.

Fixes #36796

Change-Id: Iffed6259de31340c3f66e34da473826a1d09fcde
Reviewed-on: https://go-review.googlesource.com/c/go/+/412858
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-17 21:21:26 +00:00
Alan Donovan
6c25ba624f go/token: delete unused File.set field
This field is only used for a sanity check in a test.

Change-Id: I868ed10131ec33994ebb1b1d88f6740956824bd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/409834
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-17 15:02:55 +00:00
Bryan C. Mills
9068c6844d cmd/dist: add package . to 'go test' commands
This suppresses verbose output if the test passes,
eliminating some "hello from C" noise for the ../misc/cgo test.

Change-Id: I6324bfb4b3633c20e0eb0ae03aa25d40fab9fcfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/412776
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-16 21:58:40 +00:00
Michael Anthony Knyszek
7bad61554e runtime: write much more direct test for semaphore waiter scalability
This test originally existed as two tests in test/locklinear.go, but
this checked against actual locks and was flaky. The test was checking
a property of a deep part of the runtime but from a much higher level,
and it's easy for nondeterminism due to scheduling to completely mess
that up, especially on an oversubscribed system.

That test was then moved to the sync package with a more rigorous
testing methodology, but it could still flake pretty easily.

Finally, this CL makes semtable more testable, exports it in
export_test.go, then writes a very direct scalability test for exactly
the situation the original test described. As far as I can tell, this is
much, much more stable, because it's single-threaded and is just
checking exactly the algorithm we need to check.

Don't bother trying to bring in a test that checks for O(log n) behavior
on the other kind of iteration. It'll be perpetually flaky because the
underlying data structure is a treap, so it's only _expected_ to be
O(log n), but it's very easy for it to get unlucky without a large
number of iterations that's too much for a simple test.

Fixes #53381.

Change-Id: Ia1cd2d2b0e36d552d5a8ae137077260a16016602
Reviewed-on: https://go-review.googlesource.com/c/go/+/412875
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-16 21:25:35 +00:00
Michael Matloob
f38a580a51 cmd/go: add more tracing
Change-Id: I26ed64c097533ee9276e598653db72efc053c4e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/403156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-06-16 20:59:51 +00:00
Russ Cox
635b1244aa cmd/go: pass GOEXPERIMENT through to subtests
This fixes:

	export GOEXPERIMENT=unified
	go install cmd
	go install std cmd
	go install std cmd
	go test -short cmd/go -run=TestScript/test_relative_import_dash_i

That script test checks that runtime is non-stale, but whether it's stale
depends on the setting of GOEXPERIMENT. Stop filtering that variable out.

Change-Id: I71bdbca495c16981cdcddf4ab4d87a38ca72a389
Reviewed-on: https://go-review.googlesource.com/c/go/+/412874
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-06-16 20:01:10 +00:00
Ian Lance Taylor
ef808ae1d4 expvar: don't crash if map value set to nil
Fixes #52719

Change-Id: Ib032193d00664090c47ae92e7d59674ec2d0165a
Reviewed-on: https://go-review.googlesource.com/c/go/+/408677
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2022-06-16 18:29:19 +00:00
Robert Griesemer
32510eea74 go/parser: remove unused method checkBinaryExpr
Change-Id: Ica981657e50e30cbfa1757e8457819a479f11c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/412775
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-16 18:25:05 +00:00
Michael Matloob
74f1fa6ecb cmd/go: parallelize matchPackages work in each module
In each module matchPackages looks in, when doing the walk, do the
scanDir call in a par.Queue so all the read work can be done in
parallel.

Change-Id: I27153dbb3a2ed417ca24972f47134e9e914a55d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/404097
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-06-16 16:44:35 +00:00
Cherry Mui
1d9d99b7ce cmd/link: consider alignment in carrier symbol size calculation
Currently, when we calculate the size of a carrier symbol, we use
the previous symbol's end address as the start. But the symbol
actually starts after applying the alignment. Do this in the
size calculation.

Should fix AIX build.

Updates #53372.

Change-Id: I17942b1fe8027dce12b78c8e8c80ea6cebcee240
Reviewed-on: https://go-review.googlesource.com/c/go/+/412734
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-06-16 16:27:17 +00:00
Ian Lance Taylor
b6c1606889 internal/goarch, internal/goos: update generators for syslist.go
Update the generator programs for the changes to syslist.go in CL
390274 and the changes to the generated files in CL 344955.

Tested by running the programs and verifying that the files did not
change.

Fixes #53299

Change-Id: I2b2c5769f7e9283aa05c803256d2ea1eb9ad1547
Reviewed-on: https://go-review.googlesource.com/c/go/+/411334
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-15 21:31:23 +00:00
Koichi Shiraishi
91baf5cecc reflect: fix reference comment to runtime/map.go
Change-Id: Icb552dc7106afbf6bd4bd3660d632f174153f834
Reviewed-on: https://go-review.googlesource.com/c/go/+/408914
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-06-15 21:24:24 +00:00
Vojtěch Boček
0e3d0c9581 syscall: clarify Pdeathsig documentation on Linux
This is a rather large footgun, so let's mention that it sends the signal on thread termination and not process termination in the documentation.

Updates #27505

Change-Id: I489cf7136e34a1a7896067ae24187b0d523d987e
GitHub-Last-Rev: c8722b25d1
GitHub-Pull-Request: golang/go#53365
Reviewed-on: https://go-review.googlesource.com/c/go/+/412114
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-15 21:18:07 +00:00
Robert Griesemer
74bf90c779 go/types, types2: add test case for issue for coverage
The specific error doesn't occur anymore.
Add a test to prevent regressions.

For #50729.

Change-Id: Ibf6ef6009b3d226b4f345b5a5657939915f19633
Reviewed-on: https://go-review.googlesource.com/c/go/+/412235
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-15 21:18:06 +00:00
Guoqi Chen
97bfc77f38 syscall, runtime/internal/syscall: always zero the higher bits of return value on linux/loong64
All loong64 syscalls return values only via R4/A0, and R5/A1 may contain unrelated
content. Always zero the second return value.

Change-Id: I62af59369bece5bd8028b937c74f4694150f7a55
Reviewed-on: https://go-review.googlesource.com/c/go/+/411615
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-06-15 20:49:30 +00:00
subham sarkar
937fa5000a net/netip: add missing ) in ParsePrefix errors
The existing error messages didn't add right parenthesis ')' properly
leading to improper formation of error messages.

Fixes #53283

Change-Id: Iadf9b8059403efa07e39716a81fab68cd10b7f87
Reviewed-on: https://go-review.googlesource.com/c/go/+/411015
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-06-15 20:07:10 +00:00
Cherry Mui
c2c76c6f19 cmd/link: set alignment for carrier symbols
For carrier symbols like type.*, currently we don't set its
alignment. Normally it doesn't actually matter as we still align
the inner symbols. But in some cases it does make the symbol table
a bit weird, e.g. on darwin/arm64,

0000000000070000 s _runtime.types
0000000000070001 s _type.*

The address of the symbol _type.* is a bit weird. And the new
darwin linker from Xcode 14 beta doesn't like that (see issue
53372).

This CL aligns them.

Fixes #53372.

Change-Id: I1cb19dcf172e9a6bca248d85a7e54da76cbbc8a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/411912
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-15 17:37:53 +00:00
Bryan C. Mills
36147dd1e8 cmd/go/internal/modindex: disable indexing for modules outside GOROOT and the module cache
Since CL 410821 we were indexing these modules with a cache key based
on the mtimes of the files within the module. However, that seems to
be causing test failures (#53269 and maybe #53371).

In addition, indexing these modules caused a potentially-expensive
operation (re-indexing a whole module) whenever any individual file
within the module is changed, even if it isn't relevant to the
package(s) being loaded from that module. In some cases, that could
cause a significant performance regression for 'go' commands invoked
on a small subset of the packages in the module (such as running 'go
test' on a single changed package — a common case during development).

Instead, we now index only those modules found within the module cache
and within GOROOT.

In addition, we now check mtimes when indexing GOROOT modules if the
Go version begins with the string "devel ", which indicates a
non-released Go version that may include local file edits within GOROOT.

For #53371.
For #53269.

Change-Id: Id3aa81b55ecfc478e47dd420148d39d2cf476f2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/412394
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-06-15 17:13:55 +00:00
Ian Lance Taylor
f9c0264107 net: avoid infinite recursion in Windows Resolver.lookupTXT
For #33097

Change-Id: I6138dc844f0b29b01c78a02efc1e1b1ad719b803
Reviewed-on: https://go-review.googlesource.com/c/go/+/412139
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-06-15 00:03:12 +00:00
Keith Randall
c22a6c3b90 reflect: when StructOf overflows computing size/offset, panic
Fixes #52740

Change-Id: I849e585deb77cfcfc1b517be4a171eb29b30c5f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/412214
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-06-14 23:23:04 +00:00
Keith Randall
e1e66a03a6 cmd/compile,runtime,reflect: move embedded bit from offset to name
Previously we stole a bit from the field offset to encode whether
a struct field was embedded.

Instead, encode that bit in the name field, where we already have
some unused bits to play with. The bit associates naturally with
the name in any case.

This leaves a full uintptr to specify field offsets. This will make
the fix for #52740 cleaner.

Change-Id: I0bfb85564dc26e8c18101bc8b432f332176d7836
Reviewed-on: https://go-review.googlesource.com/c/go/+/412138
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-06-14 23:22:11 +00:00
Ian Lance Taylor
cb9bf93078 cmd/go: quote package directory when calling glob
Fixes #53314

Change-Id: I4933b59ee247daec5cf96eb15c52ff54d3ec26a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/411696
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-06-14 21:55:52 +00:00
ag9920
cad477c922 cpu: fix typos in test case
Change-Id: Id6a27d0b3f3fc4181a00569bacc578e72b04ce09
GitHub-Last-Rev: 85c063d1a2
GitHub-Pull-Request: golang/go#53359
Reviewed-on: https://go-review.googlesource.com/c/go/+/411916
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Zhang <binbin36520@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-06-14 14:49:40 +00:00
Austin Clements
c29be2d41c runtime: add HACKING section on nosplit functions
Change-Id: I247874d5c49d2c0d8db2a3d227aa848093551d9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/401759
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-13 21:24:54 +00:00
Michael Anthony Knyszek
56bc3098f4 sync: improve linearity test robustness
This change improves the robustness of the locklinear test in the
following ways:

* It removes allocations from the timing, which may be very variable if
  we're unlucky.
* It ensures that goroutines are properly cleaned up before the test
  function returns, reducing the chance that they bleed into repeat
  attempts. It also stops timing before this cleanup.

Fixes #32986.

Change-Id: I3a8096e6922f23d899ad602e2845bdfc639ed742
Reviewed-on: https://go-review.googlesource.com/c/go/+/409894
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-13 20:16:01 +00:00
Michael Anthony Knyszek
1fe2810f9c sync: move lock linearity test and treat it like a performance test
This change moves test/locklinear.go into the sync package tests, and
adds a bit of infrastructure since there are other linearity-checking
tests that could benefit from it too. This infrastructure is also
different than what test/locklinear.go does: instead of trying really
hard to get at least one success, we instead treat this like a
performance test and look for a significant difference via a t-test.

This makes the methodology behind the tests more rigorous, and should
reduce flakiness as transient noise should produce an insignificant
result. A follow-up CL does more to make these tests even more robust.

For #32986.

Change-Id: I408c5f643962b70ea708930edb4ac9df1c6123ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/411396
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-13 20:15:55 +00:00
Michael Anthony Knyszek
6130461149 internal/testmath: add two-sample Welch's t-test for performance tests
This CL copies code from github.com/aclements/go-moremath/stats and
github.com/aclements/go-moremath/mathx for Welch's t-test. Several
existing tests in the Go repository check performance and scalability,
and this import is part of a move toward a more rigorous measurement of
both.

Note that the copied code is already licensed to Go Authors, so there's
no need to worry about additional licensing considerations.

For #32986.

Change-Id: I058630fab7216d1a589bb182b69fa2231e6f5475
Reviewed-on: https://go-review.googlesource.com/c/go/+/411395
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-13 20:15:50 +00:00
Ian Lance Taylor
fbc75dff2f cmd/cgo: remove -fsanitize=hwaddress hardware tags
No test because this isn't support on any of the builders.

Fixes #53285

Change-Id: If8d17bdcdac81a6ce404a35a289bf83f07f02855
Reviewed-on: https://go-review.googlesource.com/c/go/+/411698
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-13 19:09:14 +00:00
Damien Neil
2c52465cb3 net: avoid darwin_arm64 bug in TestDialParallelSpuriousConnection
On darwin_arm64, reading from a socket at the same time as the other
end is closing it will occasionally hang for 60 seconds before
returning ECONNRESET. (This is a macOS issue, not a Go issue.)

Work around this condition by adding a brief sleep before the read.

Fixes #37795.

Change-Id: I63f92b91fb297cd66f89cdab707583afd50ab9c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/411155
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2022-06-13 19:00:03 +00:00
Cuong Manh Le
7eeec1f6e4 cmd/compile: fix missing dict pass for type assertions
For type assertions, if either src or dst type has shape, we must
convert them to dynamic type assertions.

Fixes #53309

Change-Id: Ia3362fa67c011febcbdb5b26f856d081b5c366de
Reviewed-on: https://go-review.googlesource.com/c/go/+/411617
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-06-13 16:53:11 +00:00
Louis PORTAY
55590f3a2b net/http: doc: update RFC reference for appropriate HTTP codes
This documentation commit points to the latest RFC documenting HTTP codes

Change-Id: Ia7640664637f0c7846e2182353b787474bac7b4f
GitHub-Last-Rev: 5fb544ee32
GitHub-Pull-Request: golang/go#53318
Reviewed-on: https://go-review.googlesource.com/c/go/+/411475
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-10 23:30:35 +00:00
Cherry Mui
fb75c2da91 cmd/dist, cmd/internal/metadata: don't install metadata binary
It is only needed by cmd/dist, no need to build and install the
binary.

Change-Id: I6aba6b81496406077a0efba255c35020cff9d351
Reviewed-on: https://go-review.googlesource.com/c/go/+/411534
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-06-10 20:39:12 +00:00
Khaled Yakdan
386245b68e runtime: fix stack split at bad time when fuzzing
Fix #53190

Change-Id: I6c1f9c3ab58818d3a9f05ddaa02fc247e53677d3
GitHub-Last-Rev: 13b0749c13
GitHub-Pull-Request: golang/go#53191
Reviewed-on: https://go-review.googlesource.com/c/go/+/410034
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-10 15:00:45 +00:00
Dmitri Goutnik
2cfbef4380 cmd/cgo: recognize clang 14 DWARF type names
Fixes #53013

Change-Id: I169d4eb2420a6da52cc9abe17da98c3092a91be6
Reviewed-on: https://go-review.googlesource.com/c/go/+/407514
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09 19:31:37 +00:00
Michael Pratt
c7ccabf3fe runtime/cgo: retry _beginthread on EACCES
We occassionally see _beginthread failing with EACCES, meaning
"insufficient resources" according to the Microsoft documentation.
Exactly which resources is unclear.

Similar to pthread_create on unix systems, we can wait a bit and retry
to try to get success. The alternative is to abort, so we may as well
give it a try.

Fixes #52572.

Change-Id: I6e05add53b4ae36c61e53b1ee3fed6bc74e17dfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/410355
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09 18:17:45 +00:00
Michael Pratt
91019cc13d runtime/cgo: merge bodies of cgo_sys_thread_start on windows
The bodies of cgo_sys_thread_start (and x_cgo_sys_thread_create) are
nearly identical on all of the windows ports.

Create a single _cgo_beginthread implementation that contains the body
and is used on all ports. This will reduce churn in an upcoming CL to
add retry logic.

We could theoretically have a single implementation of
_cgo_sys_thread_start shared by all ports, but I keep them separate for
ease of searching. Right now every single port implements this function
in their gcc_GOOS_GOARCH.c file, so it is nice to keep this symmetry.

_cgo_dummy_export must move out of libcgo_windows.h because it is a
definition and the inclusion of libcgo_windows.h in multiple files
creates duplicate definitions.

For #52572.

Change-Id: I9fa22009389349c754210274c7db2631b061f9c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/410354
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09 18:17:39 +00:00
Robert Findley
1a2ca95ad2 go/types, types2: only set instance context if packages match
In CL 404885, we avoid infinite expansion of type instances by sharing a
context between the expanding type and new instances created during
expansion. This ensures that we do not create an infinite number of
identical but distinct instances in the presence of reference cycles.
This pins additional memory to the new instance, but no more
(approximately) than would be pinned by the original expanding instance.

However, we can do better: since type cycles are only possible within a
single package, we only need to share the local context if the two types
are in the same package. This reduces the scope of the shared local
context, and in particular can avoid pinning the package of the
expanding type to the package of the newly created instance.

Updates #52728

Change-Id: Iad2c85f4ecf60125f1da0ba22a7fdec7423e0338
Reviewed-on: https://go-review.googlesource.com/c/go/+/410416
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-09 01:07:11 +00:00
Michael Matloob
b51d44c6dd cmd/go/testdata/script: fix skip on list_replace_absolute_windows
The test should skip if it's not on windows *or* it's a short test, but
instead is now skipping if it's not on windows *and* it's a short test,
causing it to be run on non-windows longtest builders.

Change-Id: Ica011bab632b713b0564fefabd5b42878d401844
Reviewed-on: https://go-review.googlesource.com/c/go/+/411122
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Auto-Submit: Michael Matloob <matloob@golang.org>
2022-06-08 23:36:35 +00:00
Michael Pratt
13f6be2833 runtime: use pidleget for faketime jump
In faketime mode, checkdead is responsible for jumping time forward to
the next timer expiration, and waking an M to handle the newly ready
timer.

Currently it pulls the exact P that owns the next timer off of the pidle
list. In theory this is efficient because that P is immediately eligible
to run the timer without stealing. Unfortunately it is also fraught with
peril because we are skipping all of the bookkeeping in pidleget:

* Skipped updates to timerpMask mean that our timers may not be eligible
  for stealing, as they should be.
* Skipped updates to idlepMask mean that our runq may not be eligible
  for stealing, as they should be.
* Skipped updates to sched.npidle may break tracking of spinning Ms,
  potentially resulting in lost work.
* Finally, as of CL 410122, skipped updates to p.limiterEvent may affect
  the GC limiter, or cause a fatal throw when another event occurs.

The last case has finally undercovered this issue since it quickly
results in a hard crash.

We could add all of these updates into checkdead, but it is much more
maintainable to keep this logic in one place and use pidleget here like
everywhere else in the runtime. This means we probably won't wake the
P owning the timer, meaning that the P will need to steal the timer,
which is less efficient, but faketime is not a performance-sensitive
build mode. Note that the M will automatically make itself a spinning M
to make it eligible to steal since it is the only one running.

Fixes #53294
For #52890

Change-Id: I4acc3d259b9b4d7dc02608581c8b4fd259f272e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/411119
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-06-08 21:56:02 +00:00
Michael Matloob
1292176bc9 cmd/go: clean paths before using them form index functions
We use str.TrimFilePathPrefix to trim the module root prefix and get the
relative path of each package in the module when scanning the module
and in the RelPath function.  Make sure to clean the path before
indexing and in RelPath to ensure that each path starts with that
prefix, because walk will clean the root path before joining each
subdirectory path to it.

Change-Id: I1dc1eddbd42030eb6d5d8e76a8675f94216447c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/411118
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2022-06-08 21:00:49 +00:00
Tobias Klauser
1858ea5d85 syscall: remove unused setgroups on linux/loong64
Setgroups in syscall_linux.go already wraps the setgroups(2) syscall
with correct POSIX semantics (ref. CL 210639).

Change-Id: I961cd7c7fce1d70d23bf13cc82cad17854bbf40e
Reviewed-on: https://go-review.googlesource.com/c/go/+/411214
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-08 20:41:37 +00:00
Austin Clements
bdde41e3ba runtime: skip TestGdbBacktrace on gdb bug
Very rarely, GDB will successfully run the whole test and the inferior
will exit successfully, and then GDB itself hangs and never exits.
Detect this and skip the test as flaky. We could just continue the
test since all of the output we need is there, but by skipping it
we're less likely to notice serious regressions in this test.

Fixes #37405.

Change-Id: I016cbb06f48673f064733da3e3f1ddcbefd58159
Reviewed-on: https://go-review.googlesource.com/c/go/+/411117
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-08 19:41:54 +00:00
Damien Neil
432158b69a net: fix testHookDialTCP race
CL 410754 introduces a race accessing the global testHookDialTCP hook.
Avoiding this race is difficult, since Dial can return while
goroutines it starts are still running. Add a version of this
hook to sysDialer, so it can be set on a per-test basis.

(Perhaps other uses of this hook should be moved to use the
sysDialer-local hook, but this change fixes the immediate data race.)

For #52173.

Change-Id: I8fb9be13957e91f92919cae7be213c38ad2af75a
Reviewed-on: https://go-review.googlesource.com/c/go/+/410957
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-08 17:11:00 +00:00
Michael Matloob
899f0a29c7 cmd/go: enable module index by default
This changes the module index to be enabled by default, rather than
disabled by default. The index can still be disabled by setting
GODEBUG=index=0.

Fixes #53290.

Change-Id: Ic3728fc69d96bb6ef56b56e8c9f2dce35f2923cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/410821
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-06-08 16:53:29 +00:00
Michael Matloob
f862280e30 cmd/go: properly call PackageModuleRoot to get modroot for index
PackageModuleRoot needs to be called with the package's path, not
its directory on disk.

Change-Id: I080fe8ce2aeb72e1466624db81595a00915606bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/410820
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
2022-06-08 16:27:53 +00:00
Michael Matloob
d65166024f cmd/go: set Root and target fields for packages in GOPATH
This change replicates the behavior filed in issue #37015 for packages
imported from the module index. That behavior is that packages that
happen to exist in a GOPATH src directory have p.Root and p.Target set
even when the packages are loaded from modules. This is likely
unintentional behavior because in module mode, packages shouldn't behave
differently depending on whether their directories exist in GOPATH. But
for uniformity, (and because two of our tests depend on this behavior),
this CL will implement this behavior. We can remove it from the module
index when we remove it from the go/build logic.

Change-Id: I3f501c92fbb76eaf86b6b9275539f2129b67f884
Reviewed-on: https://go-review.googlesource.com/c/go/+/410822
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-06-08 16:27:42 +00:00
Michael Pratt
3426b7201d runtime: gofmt
libfuzzerHookStrCmp is manually reformatted into a proper go doc list.

We don't always format testdata, but these test programs are standard Go
programs that can be formatted.

Change-Id: I4dde398bca225ae8c72e787e4d43fd0ccfd0a90b
Reviewed-on: https://go-review.googlesource.com/c/go/+/411114
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-08 15:44:05 +00:00
Tobias Klauser
2882786bf4 runtime: remove unused pipe and setNonblock on linux/loong64
CL 389354 removed the fallback to pipe on all platforms with pipe2. This
is the case for linux. Thus, pipe and setNonblock are no longer needed
on linux/loong64 too.

Change-Id: I089adf918d0fd8de5d4d61a893707a2660f89183
Reviewed-on: https://go-review.googlesource.com/c/go/+/410736
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-08 01:54:08 +00:00
Dan Kortschak
b72a6a7b86 os: document that Chdir affects fs.FS returned by DirFS with a relative path
Fixes #47214.

Change-Id: I6fdc1c4340c0943b825ac22e311179ad1cf30915
Reviewed-on: https://go-review.googlesource.com/c/go/+/410334
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-07 23:09:21 +00:00
Tobias Klauser
30b929b1ef syscall: remove unused accept on linux/loong64
accept is no longer used on Linux since CL 346849 changed Accept to use
accept4 only.

This follows CL 386415 which already removed accept on all other Linux
platforms before the linux/loong64 port was submitted.

For #45964

Change-Id: I26945ff780e71174a0b0c2f5313c4bc1e1cbf786
Reviewed-on: https://go-review.googlesource.com/c/go/+/410737
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-07 23:00:27 +00:00
Damien Neil
a7551fe245 net: use synthetic network in TestDialParallel
TestDialParallel is testing the Happy Eyeballs algorithm implementation,
which dials IPv4 and IPv6 addresses in parallel with the preferred
address family getting a head start. This test doesn't care about
the actual network operations, just the handling of the parallel
connections.

Use testHookDialTCP to replace socket creation with a function that
returns successfully, with an error, or after context cancellation
as required.

Limit tests of elapsed times to a check that the fallback deadline
has been exceeded in cases where this is expected.

This should fix persistent test flakiness.

Fixes #52173.

Change-Id: Ic93f270fccb63b24a91105a4d541479fc33a2de4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410754
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-07 22:24:02 +00:00
Robert Griesemer
3507805bcd go/types, types2: better error message for invalid use of constraint type
Fixes #42881.

Change-Id: If800c5f90c0034d192bf8b6649e5cfda96df48cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/410954
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-07 21:37:21 +00:00
Robert Griesemer
269bf7e855 go/types, types2: better error message if type is not in type set
Fixes #40350.

Change-Id: Ia654d6b854971700ca618692a864265557122b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/410876
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-07 21:37:18 +00:00
Robert Griesemer
d4fb93be87 go/types, types2: use | rather than ∪ when printing term lists
With this change, the termlist String() function prints termlists
in the usual Go notation and thus we can use it in error reporting.
Preparation for fixing #40350.

For #40350.

Change-Id: Ia28318841305de234a71af3146ce0c59f5e601a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/410894
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-07 21:37:14 +00:00
Michael Pratt
f3e051a184 runtime: document GOMEMLIMIT in environment variables section
For #48409.

Change-Id: Ia6616a377bc4c871b7ffba6f5a59792a09b64809
Reviewed-on: https://go-review.googlesource.com/c/go/+/410734
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-06-07 18:47:38 +00:00
Will Hawkins
69bb7c6ef5 sync/atomic: clarify that 8-byte alignment of variables is due to escape
For #53223.

Change-Id: I79e9b920488581a4d850e4051ee0dd600b5bbcb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/410102
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-06-07 17:44:51 +00:00
Khaled Yakdan
77d9252ddf runtime: fix inline assembly trampoline for arm64
Use the program counter to compute the address of the first instruction
of the ret sled. The ret sled is located after 5 instructions from the
MOVD instruction saving the value of the program counter.

Change-Id: Ie7ae7a0807785d6fea035cf7a770dba7f37de0ec
GitHub-Last-Rev: 2719208c6a
GitHub-Pull-Request: golang/go#53039
Reviewed-on: https://go-review.googlesource.com/c/go/+/407895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-06-07 14:47:46 +00:00
Motiejus Jakštys
38607c5538 cmd/link: specify -Wl,-z params as documented
Both GNU and LLVM linkers de facto accept `-zPARAM`, and Go sometimes
does it. Inconsistently: there are more uses of `-z PARAM` than
`-zPARAM`:

    $ git grep -E -- '-Wl,-z[^,]' master | wc -l
    4
    $ git grep -E -- '-Wl,-z,' master | wc -l
    7

However, not adding a space between `-z` and the param is not
documented:

llvm-13:

    $ man ld.lld-13 | grep -E -A1 -w -- "^ +-z"
         -z option
                 Linker option extensions.

gnu ld:

    $ man ld | grep -E -A1 -w -- "^ +-z"
           -z keyword
               The recognized keywords are:
    --
           -z defs
               Report unresolved symbol references from regular object files.  This is done even if the linker is creating a non-symbolic
    --
           -z muldefs
               Normally when a symbol is defined multiple times, the linker will report a fatal error. These options allow multiple definitions
    --
           -z
           --imagic

... and thus should be avoided.

`zig cc`, when used as the C compiler (`CC="zig cc" go build ...`), will
bark, because `zig cc` accepts only `-z PARAM`, as documented.

Closes ziglang/zig#11669

Change-Id: I758054ecaa3ce01a72600bf65d7f7b5c3ec46d09
GitHub-Last-Rev: e068e007da
GitHub-Pull-Request: golang/go#53030
Reviewed-on: https://go-review.googlesource.com/c/go/+/407834
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-06-07 14:45:47 +00:00
Russ Cox
a71ca3dfbd runtime, sync, sync/atomic: document happens-before guarantees
A few of these are copied from the memory model doc.
Many are entirely new, following discussion on #47141.
See https://research.swtch.com/gomm for background.

The rule we are establishing is that each type that is meant
to help synchronize a Go program should document its
happens-before guarantees.

For #50859.

Change-Id: I947c40639b263abe67499fa74f68711a97873a39
Reviewed-on: https://go-review.googlesource.com/c/go/+/381316
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-06-06 20:48:03 +00:00
Russ Cox
3651a6117e go/doc/comment: add heuristics for common badly formatted comments
In a set of 55M Go doc comments drawn from the latest version of
all public Go modules known to the module proxy in spring 2020,
the current Go 1.19 gofmt reformats about 1.57M of them.
Out of those 1.57M comments, inspection of random samples
shows that around 5% of the changed comments contain
unindented code snippets, multiline shell commands, or lists.
For example:

	// Here is a greeting:
	//
	// func main() {
	//	fmt.Println("hello, world")
	// }

	// Run this command:
	//
	// path/to/your/program -flag1=longargument1 \
	//	-flag2=longargument2 \
	//	-flag3

	// There are three possibilities:
	//
	// - Unindented code snippets (or JSON objects)
	//    in which the first and last line are unindented
	//    but end in { and start with }, respectively.
	// - Unindented multiline shell commands
	//    in which the lines end in \
	// - Unindented lists, in which wrapped lines are indented.

All three of these cases involve unindented lines next to indented
lines that would according to the usual rules begin a pre block.
Before this CL, they'd be reformatted to:

	// Here is a greeting:
	//
	// func main() {
	//
	//	fmt.Println("hello, world")
	//
	// }

	// Run this command:
	//
	// path/to/your/program -flag1=longargument1 \
	//
	//	-flag2=longargument2 \
	//	-flag3

	// There are three possibilities:
	//
	// - Unindented code snippets (or JSON objects)
	//
	//	in which the first and last line are unindented
	//	but end in { and start with }, respectively.
	//
	// - Unindented multiline shell commands
	//
	//	in which the lines end in \
	//
	// - Unindented lists, in which wrapped lines are indented.

The fact that they are not already in canonical format gives us
a signal that they might not mean what the usual rules would say.

This CL takes advantage of that opening to apply a few heuristics
to better handle these cases:

 1. If an indented code block immediately follows (without a blank line)
    an unindented line ending in { or \, include the unindented line
    in the code block.

 2. If an indented code block immediately precedes (without a blank line)
    an unindented line beginning with }, include the unindented line
    in the code block.

 3. If an indented line immediately follows (without a blank line)
    an unindented line that starts with a list marker, assume this is
    an unindented list with a wrapped indented line, and treat all
    adjacent unindented lines starting with list markers as part of
    the list, stopping at any surrounding blank lines.

This raises the fraction of “correctly” reformatted doc comments
in the corpus from approximately 87% to approximately 93%.

Change-Id: I7ac542eb085032d607a7caf3ba9020787b2978b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/410360
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-06-06 20:47:52 +00:00
Michael Matloob
11195c60e6 cmd/go: use index to match packages in dependency modules
If we're trying to search in a module in the module cache, instead
iterate over the packages in the index.
Change-Id: Ia94cbe6e9690110c28b93dbb33810680e3010381
Reviewed-on: https://go-review.googlesource.com/c/go/+/403756
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 19:32:49 +00:00
Russ Cox
ea5d7cbc26 all: boringcrypto post-merge cleanup
This CL addresses the comments on CL 403154.

For #51940.

Change-Id: I99bb3530916d469077bfbd53095bfcd1d2aa82ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/403976
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-06 19:10:07 +00:00
Russ Cox
6c7b223c2b go/doc/comment: do not turn `` into “
``` is Markdown, not Go doc comment, but some small fraction of users get confused.

In a set of 55M Go doc comments drawn from the latest version of
all public Go modules known to the module proxy in spring 2020,
the current Go 1.19 gofmt reformats about 1.57M of them.
Out of those 1.57M comments, 8k of them (about 0.5%) contain ```.

Instead of rewriting ``` to “`, leave it alone.

For #51082.

Change-Id: I1c8c88aac7ef75ec03e1a396b84ffe711c46f941
Reviewed-on: https://go-review.googlesource.com/c/go/+/410359
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-06-06 19:06:16 +00:00