Commit Graph

51084 Commits

Author SHA1 Message Date
Robert Griesemer
07ed86c57b cmd/compile/internal/types2: record types for union subexpressions
This is a port of CL 371757 from go/types to types2, with
minor adjustments for different error handling and AST.

It also names the added API test cases more consistently.
The same renaming was applied to the respective go/types
file.

Updates #50093

Change-Id: Iaa132106a197a207f831525432e62e9d452b17c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/372475
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-12-15 20:26:19 +00:00
Robert Griesemer
4cda05d41a cmd/compile/internal/types2: externalize union type sets
This is a port of CL 371756 from go/types to types2 with
minor adjustments due to different error handling or AST.

Updates #50093

Change-Id: Iab6a4634f8fc917bf99df439d31098624085f52a
Reviewed-on: https://go-review.googlesource.com/c/go/+/372474
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-12-15 20:26:10 +00:00
Cherry Mui
bc0aba9717 cmd/compile: correct type identity comparison with "any"
The builtin "any" type should only be identical to an unnamed empty
interface type, not a defined empty interface type.

Fixes #50169.

Change-Id: Ie5bb88868497cb795de1fd0276133ba9812edfe4
Reviewed-on: https://go-review.googlesource.com/c/go/+/372217
Trust: Cherry Mui <cherryyz@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-15 20:26:03 +00:00
Jakub Čajka
83fc0978e5 misc/cgo/testshared: increase size limit in size check
Recently in Fedora we switched binutils ld's separate-code on. This
led to increased size of binaries, especially on 64k aligned arches.
For example trivial test binary size grew from 80k to 211k on ppc64le
tripping the size check(RHBZ#2030308). Therefore adjusting the size limit.

Change-Id: Ic722d90c338739c0b285f40b12ba4d675e9626a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/371634
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-15 20:19:05 +00:00
Jakub Čajka
d5fefbb498 misc/cgo/testshared: pass -x flag only to commands supporting it
Running testshared with the -testx flag leads to:

./testshared.test -testx -testwork
+ mkdir -p /tmp/shared_test125221103
shared_test.go:79: executing go env -x GOROOT failed exit status 2:
flag provided but not defined: -x
usage: go env [-json] [-u] [-w] [var ...]
Run 'go help env' for details.
panic: executing go env -x GOROOT failed exit status 2:
flag provided but not defined: -x
usage: go env [-json] [-u] [-w] [var ...]
Run 'go help env' for details.

Change-Id: Id299979487c021e9ad1d57f5f7088d935830a6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/371614
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-12-15 20:18:30 +00:00
ichxxx
567b177949 all: fix typo in comment
Remove duplicate 'the'

Change-Id: I3ed81c8d9c488662387e45580a3bcd462448ba44
GitHub-Last-Rev: 86443993b9
GitHub-Pull-Request: golang/go#50017
Reviewed-on: https://go-review.googlesource.com/c/go/+/372394
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-15 19:56:22 +00:00
Hana
b1c7703f26 doc/go1.18: discuss embedded build info compatibility
Fixes #50085

Change-Id: I9be8ddb983fb4fe598becbb0b93bb5b7e1f8438f
Reviewed-on: https://go-review.googlesource.com/c/go/+/372214
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-15 14:48:19 +00:00
Bryan C. Mills
b5c0dbaafc net: eliminate arbitrary timeout in TestVariousDeadlines
When we set a timeout, we don't actually have a guarantee one how long
the OS will take to notice it. Moreover, if the test deadlocks
completely (for example, due to a deadline never taking effect), it
would be more useful to get a full goroutine dump instead of the current
"client stuck in Dial+Copy" failure message.

For #37883
For #41863

Change-Id: I9f712ef1c620f97a5ab69baac45deb71134b99bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/371994
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-15 13:31:58 +00:00
Ian Lance Taylor
9d0ca262bb doc/go1.18: mention that embedding a type parameter is forbidden
For #47694

Change-Id: Ibf38eabcb78abc563fcf77e2b566175a18c06fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/372114
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-15 00:33:55 +00:00
MoZhonghua
c948823cb7 runtime/cgo: fix signature of crosscall_amd64 in comment
In CL 289192, crosscall_amd64() was changed to recieve 3
arguments, but the comment was not updated.

Change-Id: Iba36c27aa5189e50f3fcc2a50291fecb2ef722c1
GitHub-Last-Rev: e7c041f00c
GitHub-Pull-Request: golang/go#49539
Reviewed-on: https://go-review.googlesource.com/c/go/+/363442
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-15 00:14:57 +00:00
Brad Fitzpatrick
dc5a8f9647 doc/go1.18: fix an unclosed anchor
Change-Id: I432bcc6ff917d008598b2f37c6e826f588a3d6d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/372074
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-12-14 23:57:51 +00:00
Olivier Mengué
38c067d178 doc: fix typo in 1.18 release notes for package testing
In release notes for Go 1.18, fix typo in changes for package testing to
correctly document the change in CL 343883.

Change-Id: I40d92858ed3f74554a094466c06771f83dd81942
Reviewed-on: https://go-review.googlesource.com/c/go/+/371616
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-12-14 23:55:40 +00:00
Robert Findley
8108444eaa go/types: record types for union subexpressions
Prior to unions, unary and binary expressions always had a recorded
type. Preserve this by recording a type for all unary and binary
expressions encountered while parsing a union type.

Updates #50093

Change-Id: I5ba20f37854760596350d91ea325dc98e67e115a
Reviewed-on: https://go-review.googlesource.com/c/go/+/371757
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-14 23:20:01 +00:00
Robert Findley
af05064f97 go/types: externalize union type sets
Move calculated type sets for unions into a map, rather than storing
them on the Union type.

Type sets for unions only matter during calculation of interface type
sets, and to a lesser extent inside of Identical. The latter should not
be encountered during type checking, as Identical uses the precomputed
interface type set when comparing interfaces, and unions do not arise
outside of interface types.

Removing the tset field from Union potentially frees up memory, and
eliminates a source of races via calls to NewUnion and Identical. It
also sets the stage for recording Unions for every subexpression of
union terms, which preserves an existing invariant that BinaryExprs and
UnaryExprs should have a recorded type.

Updates #50093

Change-Id: I5956fa59be6b0907c3a71faeba9fa5dd8aae0d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/371756
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-14 23:18:22 +00:00
Ian Lance Taylor
1540239f48 doc/go1.18: add caution about use of generics in production
Per https://groups.google.com/g/golang-dev/c/iuB22_G9Kbo/m/7B1jd1I3BQAJ.

For #47694

Change-Id: I033cdadb2067e432f7c307d1546b4c5d0cfd5d8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/371954
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-12-14 22:42:47 +00:00
Cherry Mui
fc8ae9860a doc/go1.18: move debug/buildinfo to core library section
It is a new package and seems a major change.

Updates #47694.

Change-Id: If854e494e28bcd1e79c99e59119755b9cb6793d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/371816
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-14 21:23:43 +00:00
Austin Clements
0f05ed3b78 os: enable TestClosedPipeRace* on FreeBSD
This test has worked since CL 165801 (committed March 12, 2019), so
stop skipping it. With this, we check that Close makes concurrent I/O
operations on pipes return Errclosed on all platforms.

Updates #19093.

Change-Id: Ic090c70996c115abf80d8f9b93ca2aeaf347c9d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/371016
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-14 20:25:03 +00:00
Bryan C. Mills
d407a8c3c4 testing: retry spurious errors from RemoveAll for temp directories
This works around what appears to be either a kernel bug or a Go
runtime or syscall bug affecting certain Windows versions
(possibly all pre-2016?).

The retry loop is a simplified version of the one used in
cmd/go/internal/robustio. We use the same 2-second arbitrary timeout
as was used in that package, since it seems to be reliable in practice
on the affected builders. (If it proves to be too short, we can
lengthen it, within reason, in a followup CL.)

Since this puts a higher-level workaround in place, we can also revert
the lower-level workaround added to a specific test in CL 345670.

This addresses the specific occurrences of the bug for users of
(*testing.T).TempDir, but does not fix the underlying bug for Go users
outside the "testing" package (which remains open as #25965).

Fixes #50051
Updates #48012
Updates #25965

Change-Id: I35be7125f32f05c8350787f5ca9a22974b8d0770
Reviewed-on: https://go-review.googlesource.com/c/go/+/371296
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-14 19:53:20 +00:00
Michael Matloob
265fbaa94b doc: update go1.18 release notes with a blurb about workspace mode
For #47694

Change-Id: I79cdbdc66ea9942b597f29c9a4f428075f053466
Reviewed-on: https://go-review.googlesource.com/c/go/+/371295
Trust: 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>
2021-12-14 19:10:22 +00:00
Cherry Mui
becaeea119 api: promote next to go1.18
Change-Id: Ifc61e67413e5e56afbd0d4954f0150303d1a3a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/371755
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-14 17:43:51 +00:00
Cherry Mui
46ba32a2ca doc/go1.18: remove residual TODOs
There doesn't seem anything that still needs to de done there.

Updates #47694.

Change-Id: I7909f566638332f3904d20a34f61d371af1d2da2
Reviewed-on: https://go-review.googlesource.com/c/go/+/371754
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Alex Rakoczy <alex@golang.org>
2021-12-14 17:22:06 +00:00
Russ Cox
c1f012a0d9 cmd/compile: fix any in -G=0 mode
Fixes go test -gcflags=all=-G=0 -short std,
except for the packages with generics in their tests
(constraints, encoding/xml), and except for the
go/internal/gcimporter and go/types tests,
because the compiler does not preserve any
in its -G=0 export information.
(That's probably acceptable for now.)

Fixes cd test/; GO_BUILDER_NAME=longtest go run run.go
completely, which should fix the longtest builder.

Fixes #50159.

Change-Id: I9390972239c18831833edd6530191da2842b876b
Reviewed-on: https://go-review.googlesource.com/c/go/+/371715
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-14 16:19:51 +00:00
Robert Griesemer
1afa432ab9 go/types, types2: record (top-level) union types
Fixes #50093.

Change-Id: Ibebeda542d2a81c979670f9098c4a6d2c3e73abb
Reviewed-on: https://go-review.googlesource.com/c/go/+/371514
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-12-14 01:48:22 +00:00
Dan Scales
006d4e6278 cmd/compile: fix case where we didn't delay transformAssign in varDecl
We delay all transformations on generic functions, and only do them on
instantiated functions, for several reasons, of which one is that
otherwise the compiler won't understand the relationship between
constrained type parameters. In an instantiation with shape arguments,
the underlying relationship between the type arguments are clear and
don't lead to compiler errors.

This issue is because I missed delaying assignment transformations for
variable declarations. So, we were trying to transform an assignment,
and the compiler doesn't understand the relationship between the T and U
type parameters.

The fix is to delay assignment transformations for variable declarations
of generic functions, just as we do already for normal assignment
statements.

A work-around for this issue would be to just separate the assignment
from the variable declaration in the generic function (for this case of
an assignment involving both of the constrained type parameters).

Fixes #50147

Change-Id: Icdbcda147e5c4b386e4715811761cbe73d0d837e
Reviewed-on: https://go-review.googlesource.com/c/go/+/371534
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2021-12-14 01:18:43 +00:00
Dan Scales
5b9207ff67 cmd/compile: avoid re-instantiating method that is already imported
We can import an shape-instantiated function/method for inlining
purposes. If we are instantiating the methods of a instantiated type
that we have seen, and it happens to need a shape instantiation that we
have imported, then don't re-create the instantiation, since we will end
up with conflicting/duplicate definitions for the instantiation symbol.
Instead, we can just use the existing imported instantation, and enter
it in the instInfoMap[].

Fixes #50121

Change-Id: I6eeb8786faad71106e261e113048b579afad04fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/371414
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-12-13 22:45:26 +00:00
Cherry Mui
67917c3d78 cmd/internal/obj: fix tail call in non-zero frame leaf function on MIPS and S390X
A "RET f(SB)" wasn't assembled correctly in a leaf function with
non-zero frame size. Follows CL 371034, for MIPS(32/64)(be/le)
and S390X. Other architectures seem to do it right. Add a test.

Change-Id: I41349a7ae9862b924f3a3de2bcb55b782061ce21
Reviewed-on: https://go-review.googlesource.com/c/go/+/371214
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-12-13 22:42:08 +00:00
Bryan C. Mills
9e85dc5f18 net/http: revert h2_bundle.go formatting change from CL 368254
h2_bundle.go is automatically generated from x/net/http2. Any
formatting changes within that file need to be first made upstream.

This brings the contents of h2_bundle.go back in line with the
upstream generator, fixing the cmd/internal/moddeps test that is
currently failing on the longtest builders.

For #49884

Change-Id: I5757240b77e250e0026b8a52a0e867e1578ec2d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/371297
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 21:29:11 +00:00
Katie Hockman
7bdbc73be1 cmd/go: document -fuzzminimizetime
Change-Id: I435942ff7285d32ffbc8901d9d7e76544d5aeb61
Reviewed-on: https://go-review.googlesource.com/c/go/+/370881
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 19:40:29 +00:00
Than McIntosh
3e8aa5dd49 cmd/compile/internal/amd64: fix for coverage testing
Fix up a unit test to make it more friendly for coverage runs.
Currently on tip if you do

   cd ${GOROOT}/src ; go test -cover cmd/compile/...

it will cause a failure in the TestGoAMD64v1 testpoint of
cmd/compile/internal/amd64, the reason being that this testpoint
copies and reruns the test executable, expecting the rerun to produce
only the output "PASS", whereas if "-cover" is used, the output will
include percentage of statements covered as well. To fix, rework the
test to tolerate additional output if coverage is enabled.

Change-Id: I2512e06ca06e5f38108f2891ff84276d148c4f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/371234
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-13 19:08:31 +00:00
Katie Hockman
f909f813a0 testing: update docs for fuzzcachedir
Although most of the code seems to be already implemented
to support this for general use, it didn't make it in for
Go 1.18, so for now we should at least document that it's
only for use by the go command.

Change-Id: Id559e72d590aedeaaa50bcf880bca1a385d858dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/370954
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-13 18:55:52 +00:00
Russ Cox
2580d0e08d all: gofmt -w -r 'interface{} -> any' src
And then revert the bootstrap cmd directories and certain testdata.
And adjust tests as needed.

Not reverting the changes in std that are bootstrapped,
because some of those changes would appear in API docs,
and we want to use any consistently.
Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories
when preparing the bootstrap copy.

A few files changed as a result of running gofmt -w
not because of interface{} -> any but because they
hadn't been updated for the new //go:build lines.

Fixes #49884.

Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09
Reviewed-on: https://go-review.googlesource.com/c/go/+/368254
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 18:45:54 +00:00
Robert Griesemer
083ef54624 spec: fix conversion rules (match implementation)
As written, the conversion P(x), where P and the type
of x are type parameters with identical underlying types
(i.e., identical constraints), is valid. However, unless
the type of x and P are identical (which is covered with
the assignability rule), such a conversion is not valid
in general (consider the case where both type parameters
are different type parameters with constraint "any").

This change adjusts the rules to prohibit type parameters
in this case. The same reasoning applies and the analogue
change is made for pointer types.

The type checker already implements these updated rules.

Change-Id: Id90187900cb2820f6a0a0cf582cf26cdf8addbce
Reviewed-on: https://go-review.googlesource.com/c/go/+/371074
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-13 18:41:35 +00:00
Bryan C. Mills
acc65b47e1 net: refactor TestWriteToTimeout
The test cases for this test had listed specific errors, but the
specific error values were ignored in favor of just calling
isDeadlineExceeded.

Moreover, ENOBUFS errors (which can legitimately occur in the test if
the network interface also happens to be saturated when the timeout
occurs) were not handled at all.

Now the test relies only on the timeout: we iterate until we have seen
two of the expected timeout errors, and if we see ENOBUFS instead of
"deadline exceeded" we back off to give the queues time to drain.

Fixes #49930

Change-Id: I258a6d5c935d9635b02dffd79e197ba9caf83ac8
Reviewed-on: https://go-review.googlesource.com/c/go/+/370882
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 16:44:13 +00:00
Bryan C. Mills
4b3d8d1a39 net: create unix sockets in unique directories
This change applies the same transformation as in CL 366774,
but to the net package.

testUnixAddr was using os.CreateTemp to obtain a unique socket path,
but then calling os.Remove on that path immediately. Since the
existence of the file is what guarantees its uniqueness, that could
occasionally result in testUnixAddr returning the same path for two
calls, causing the tests using those paths to fail — especially if
they are the same test or are run in parallel.

Instead, we now create a unique, short temp directory for each call,
and use a path within that directory for the socket address.

For #34611

Change-Id: I8e13b606abce2479a0305f7aeecf5d54c449a032
Reviewed-on: https://go-review.googlesource.com/c/go/+/370694
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 16:42:31 +00:00
Bryan C. Mills
b55cbbb9e7 net: pass a testing.TB to newLocal* helpers
Passing in an explicit testing.TB gives two benefits:

1. It allows the helper to fail the test itself, instead of returning
   an error to the caller. A non-nil error invariably fails the
   calling test, and none of these callers bother to add detail to the
   error when logging it anyway so returning the error just added
   noise to the test bodies.

2. It allows the helper to use t.Cleanup to perform any needed cleanup
   tasks, which will be used in CL 370695 to clean up temp directories
   used as namespaces for unix socket paths.

For #34611

Change-Id: I805e701687c12de2caca955649369294229c10b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/370696
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13 16:42:23 +00:00
Paul E. Murphy
d198a36d8c cmd/asm,cmd/compile: fix tail call in leaf functions on PPC64
In some leaf functions using "RET foo(SB)", the jump may be incorrectly
translated into "JMP LR" instead of "JMP foo(SB)".

Such is the case when compiling the autogenerated function in k8s
k8s.io/kubernetes/pkg/kubelet/server/stats.(*resourceAnalyzer).GetPodVolumeStats.

Fixes #50048

Change-Id: Icdf65fcda6b3c5eb9d3ad5c7aad04add9419dffb
Reviewed-on: https://go-review.googlesource.com/c/go/+/371034
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Paul Murphy <murp@ibm.com>
2021-12-13 16:09:22 +00:00
Bryan C. Mills
f4ca598c9f net: don't check "invalid.invalid" lookup errors in TestLookupHostCancel
The exact error isn't actually relevant to the test,
and may depend on whether the Go or cgo resolver is used.

Also run the test in parallel, because it spends most of its time
sleeping in between lookups.

Fixes #38767
Fixes #43140

Change-Id: I2d64ffddf2eb114a69ed3242daa9a9e4a5679f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/369037
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-13 15:48:26 +00:00
Bryan C. Mills
6f42be78bb net: do not try to remove the LocalAddr of a unix socket
TestUnixAndUnixpacketServer deferred a call to os.Remove on the local
address of a dialed unix domain socket, in an attempt to remove the
socket from the server. However, that call appears to be neither
necessary nor correct.

In this test, the file that needs to be unlinked is the one attached
to the listener — but the listener's Close method already does that
(see the Unlink call in  (*UnixListener).close), so there is no need
for the test itself to do the same.

Moreover, the local address is not something that is sensible to
delete — on Linux, it is empirically always the literal string "@" —
and the Addr returned by c.LocalAddr is not reliably non-nil on all
platforms (see #34611).

Since we don't need to do anything with the local address, we shouldn't.
At best, this is a benign Remove of a file that doesn't exist anyway;
at worst, it is a nil-panic.

Fixes #34611

Change-Id: Ie072b3388d884d60e819d1df210fa7d3e2eed124
Reviewed-on: https://go-review.googlesource.com/c/go/+/370695
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-13 15:47:32 +00:00
Bryan C. Mills
36db10f3cb net: remove erroneous Dial check in TestListenerClose
TestListenerClose had been asserting that a Dial to the newly-closed
address always fails, on the assumption that the listener's address
and port would not be reused by some other listener that could then
accept the connection.

As far as I can tell, that assumption is not valid: the Dial after
Close may well connect to a Listener opened for some other test, or
even one opened by a completely different process running concurrently
on the same machine.

Fixes #38700

Change-Id: I925ed1b2ccb556135a2c5be0240d1789ed27d5fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/370666
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-13 15:47:14 +00:00
Dan Scales
9bfe09d78b cmd/compile: fix identity case relating to 'any' and shape types
In identical(), we don't want any to match a shape empty-interface type
for the identStrict option, since IdenticalStrict() is specifically not
supposed to match a shape type with a non-shape type.

There is similar code in (*Type).cmp() (TINTER case), but I don't
believe that we want to disqualify shape types from matching any in this
case, since cmp() is used for back-end code, where we don't care about
shape types vs non-shape types.

The issue mainly comes about when 'any' is used as a type argument
(rather than 'interface{}'), but only with some complicated
circumstances, as shown by the test case. (Couldn't reproduce with
simpler test cases.)

Fixes #50109

Change-Id: I3f2f88be158f9ad09273237e1d346bc56aac099f
Reviewed-on: https://go-review.googlesource.com/c/go/+/371154
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-12-13 06:35:06 +00:00
Matt Layher
49b7c9caec net/netip: make Prefix.MarshalText format 4-in-6 IPs consistently
Fixes #50115.

Change-Id: Iac76e5b486d3a2a784583345eaeb22c31cc4a36d
Reviewed-on: https://go-review.googlesource.com/c/go/+/371134
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-12 16:09:13 +00:00
Austin Clements
56817040d5 os: document error returned by pending I/O operations on Close
Currently, File.Close only documents that "an" error will be returned
by pending I/O operations. Update the documentation to say that error
is specifically ErrClosed.

Change-Id: Ica817c9196ad6cb570c826789d37a4ff15a5d13d
Reviewed-on: https://go-review.googlesource.com/c/go/+/371015
Trust: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-12 14:36:22 +00:00
Austin Clements
8692bacb6a runtime: run gdb with a timeout for TestGdbBacktrace
This sometimes times out and we don't have any useful output for
debugging it. Hopefully this will help.

For #37405.

Change-Id: I79074e6fbb9bd16a864c651109a0acbfc8aa6cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/370703
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-12 14:36:21 +00:00
Austin Clements
cc795a01dc testenv: kill subprocess if SIGQUIT doesn't do it
This makes testenv.RunWithTimeout first attempt to SIGQUIT the
subprocess to get a useful Go traceback, but if that doesn't work, it
sends a SIGKILL instead to make sure we tear down the subprocess. This
is potentially important for non-Go subprocesses.

For #37405.

Change-Id: I9e7e118dc5769ec3f45288a71658733bff30c9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/370702
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-12 14:36:20 +00:00
Austin Clements
6b89773722 testenv: abstract run-with-timeout into testenv
This lifts the logic to run a subcommand with a timeout in a test from
the runtime's runTestProg into testenv. The implementation is
unchanged in this CL. We'll improve it in a future CL.

Currently, tests that run subcommands usually just timeout with no
useful output if the subcommand runs for too long. This is a step
toward improving this.

For #37405.

Change-Id: I2298770db516e216379c4c438e05d23cbbdda51d
Reviewed-on: https://go-review.googlesource.com/c/go/+/370701
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-12 14:36:17 +00:00
Brad Fitzpatrick
9c6e8f63c0 net/netip: make AddrPort.MarshalText format 4-in-6 IPs consistently
Thanks again to @capnspacehook.

Fixes #50110

Change-Id: I1973bdea68eac9842b45f9524f62152e4f5342cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/371114
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-12 06:14:07 +00:00
Brad Fitzpatrick
1c1998ea08 net/netip: fix formatting of IPv4-in-6 address with zone
Weird, but don't drop the zone when stringifying.

Fixes #50111

Change-Id: I5fbccdfedcdc77a77ee6bafc8d82b8ec8ec7220c
Reviewed-on: https://go-review.googlesource.com/c/go/+/371094
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
2021-12-12 02:02:17 +00:00
Tim King
766f89b5c6 doc: document cmd/vet changes for 1.18 release
cmd/vet has several precision improvements for the checkers copylock, printf, sortslice, testinggoroutine, and tests. Adds a high level mention in the release notes and an example of string constant concatenation.

Updates #47694

Change-Id: I7a342a57ca3fd9e2f3e8ec99f7b647269798317f
Reviewed-on: https://go-review.googlesource.com/c/go/+/370734
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-10 19:26:50 +00:00
Bryan C. Mills
c473ca0877 net: ignore EADDRINUSE errors when dialing to IPv4 from IPv6 on FreeBSD
The failure mode in #34264 appears to match
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210726.

That bug was supposed to have been fixed in FreeBSD 12, but we're
still observing failures specifically for the 6-to-4 case on FreeBSD
12.2. It is not clear to me whether FreeBSD 13.0 is also affected.

For #34264

Change-Id: Iba7c7fc57676ae628b13c0b8fe43ddf2251c3637
Reviewed-on: https://go-review.googlesource.com/c/go/+/369157
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-10 18:20:08 +00:00
Hossein Zolfi
13d15d147d go/types: remove TODO that is no longer relevant
Change-Id: Ie897b7b9c0a61c837245642c608129108e28423e
Reviewed-on: https://go-review.googlesource.com/c/go/+/370582
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Nooras Saba‎ <saba@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-10 18:02:44 +00:00