1
0
mirror of https://github.com/golang/go synced 2024-11-17 14:04:48 -07:00
Commit Graph

50808 Commits

Author SHA1 Message Date
Katie Hockman
5d24203c39 internal/fuzz: set timeout for each exec of fuzz target
This change sets a timeout of 10 seconds on each
execution of the fuzz target, both during fuzzing
and during minimization. This is not currently
customizable by the user, but issue #48157 tracks
this work.

Deadlocks will be considered non-recoverable errors,
and as such, will not be minimizable.

Fixes #48591

Change-Id: Ic86e8e9e9a0255e7860f7cbf5654e832785d1cbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/363134
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-12 18:48:59 +00:00
Robert Findley
8b66b3d49f cmd/compile/internal/types2: unexport Context.TypeHash
Context.TypeHash is not being used outside of the type checker, so
unexport it.

The TypeHash method is meant to hash instances, not arbitrary types, and
will soon be modified to differentiate origin types by pointer identity
(even if they are *Signature types).

Change-Id: Ia8d4a7c6350ce7f278b70630585efb0009fef63a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363516
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-12 18:14:22 +00:00
Robert Findley
ede97290ed go/types: re-use type hashing logic in Context.typeHash
The special handling for *Named types is not necessary. The hash of an
instance is simply the hash of its type followed by its type argument
list.

Change-Id: I7aa58e73b81731c3cad3a2fd14124f63cfb685a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/362800
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-12 18:11:51 +00:00
Robert Findley
2dbf37045c go/types: refactor the Context type map to accept arbitrary types
In preparation for storing *Signature types in Context, refactor the
type map to not depend on the *Named type API.

Change-Id: I0439d43aa4cc3a60a78f409a773a343a4fffd0fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/362799
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-12 18:11:18 +00:00
Robert Findley
0c6a6cd4d8 go/types: use Identical to verify type identity in the Context map
We don't have guarantees that our type hash is perfect, and in fact
fuzzing found cases where identical types hashed to different values. In
case non-identical types hash to the same value, we should ensure that
we de-duplicate using Identical.

Adjust the type map to keep a slice of distinct type identities, so that
we can guarantee that type identity is preserved by de-duplication.

To allow look-up of instances by their identity, before they are
actually instantiated, add a Context.lookup method that accepts origin
type and type arguments. Replace the multi-function typeForHash method
with an update method that requires its argument be non-nil.

Change-Id: I8fe6fb2955f508db608161b7285b02d0a2fa0e46
Reviewed-on: https://go-review.googlesource.com/c/go/+/362798
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-12 18:10:48 +00:00
Michael Anthony Knyszek
95d0657670 test/recover4.go: use mprotect to create a hole instead of munmap
Currently the recover4 test, which recovers from a panic created from a
fault, generates a fault by creating a hole in a mapping. It does this
via munmap. However, it's possible the runtime can create a new mapping
that ends up in that hole, for example if the GC executes, causing the
test to fail.

In fact, this is the case now with a smaller minimum heap size.

Modify the test to use mprotect, and clean up the code a little while
we're here: define everything in terms of the length of original
mapping, deduplicate some constants and expressions, and have the test
recover properly even if recover() returns nil (right now it panics
because it fails to type assert nil as error).

Fixes #49381.

Change-Id: If399eca564466e5e8aeb2dc6f86a246d0fce7b5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/363534
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-12 16:58:34 +00:00
Cherry Mui
23adc139bf reflect: keep pointer in aggregate-typed args live in Call
When register ABI is used, reflect.Value.Call prepares the call
arguments in a memory representation of the argument registers.
It has special handling to keep the pointers in arguments live.
Currently, this handles pointer-typed arguments. But when an
argument is an aggregate-type that contains pointers and passed
in registers, it currently doesn't keep the pointers live. Do
so in this CL.

May fix #49363.

Change-Id: Ic6a0c5fdf9375ef02f7c03fbe9345e2e98c9353d
Reviewed-on: https://go-review.googlesource.com/c/go/+/363358
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-11-12 14:56:58 +00:00
Cherry Mui
e9f0381a80 cmd/link: don't unmap output file at error exit
When the link exits on error it currently calls Out.Close, which
will munmap the output buffer and close the file. This may be
called in concurrent phase where other goroutines may be writing
to the output buffer. The munmap can race with the write, causing
it to write to unmapped memory and crash. This CL changes it to
just close the file without unmapping. We're exiting on error
anyway so no need to unmap.

Fixes #47816.

Change-Id: I0e89aca991bdada3d017b7d5c8efc29e46308c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/363357
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-11-12 14:55:44 +00:00
Mikhail Faraponov
7bed3c7975 net: use Done rather than comparing with context.Background
Fixes #49023

Change-Id: I3de70f8a25f4ba8a0fb8bb96581371e33fde2f7a
GitHub-Last-Rev: b7ec9405ad
GitHub-Pull-Request: golang/go#49024
Reviewed-on: https://go-review.googlesource.com/c/go/+/356471
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Damien Neil <dneil@google.com>
2021-11-12 00:16:15 +00:00
Pedro Lopez Mareque
c3c4a2bf65 math/bits: add examples for Add, Sub, Mul and Div
Change-Id: I2f3619aa827e18f356871511c20cf2c712f496b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/353189
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Keith Randall <khr@golang.org>
2021-11-11 21:27:05 +00:00
Katie Hockman
9d89a5eb64 all: update terminology for fuzzing
This change doesn't modify any functionality.
It also doesn't update all of the comments and
variable names of the internal code, but everything
user facing should be correct.

Updates #49185

Change-Id: Ia8b2c94b89ba45897c4085ea0c17a3d8896f7ec7
Reviewed-on: https://go-review.googlesource.com/c/go/+/362794
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-11-11 21:06:07 +00:00
Robert Griesemer
ccd41cc05e go/types, types2: document nil scope for imported and instantiated Func objects
Also, don't set the scope anymore when instantiating (substituting)
a signature.

Per discussion with rfindley.

Change-Id: I560d4571c7ff14b0df3e15fece634cb5f9f94a99
Reviewed-on: https://go-review.googlesource.com/c/go/+/363435
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-11 20:45:40 +00:00
Keith Randall
10d3b13551 cmd/compile: ensure stenciled function bodies are nonempty
Our compiler gets confused between functions that were declared
with no body, and those which have a body but it is empty.

Ensure that when stenciling, we generate a nonempty body.

The particular test that causes this problem is in
cmd/compile/internal/gc/main.go:enqueueFunc. It thinks that if
a function has no body, then we need to generate ABI wrappers for
it, but not compile it.

Fixes #49524

Change-Id: Id962666a2098f60a2421484b6a776eafdc4f4a63
Reviewed-on: https://go-review.googlesource.com/c/go/+/363395
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-11-11 20:34:56 +00:00
Ian Lance Taylor
c622d1d3f6 go/build: skip rune literals when looking for go:embed
Fixes #49514

Change-Id: Id687eead731ba49974f11d2e5b489f11eff7d07b
Reviewed-on: https://go-review.googlesource.com/c/go/+/363275
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-11 20:25:49 +00:00
cuiweixie
eb68e3367b runtime: fix typo
Change filepath reference from cmd/internal/ld/symtab.go to
cmd/link/internal/ld/symtab.go.

Change-Id: Icb207a2e2c82d3976787d2d5cfb0f8005696f738
GitHub-Last-Rev: 428d99c6ca
GitHub-Pull-Request: golang/go#49518
Reviewed-on: https://go-review.googlesource.com/c/go/+/363276
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-11 20:25:07 +00:00
Michael Anthony Knyszek
46b2fc05a2 runtime: adjust TestPhysicalMemoryUtilization to handle large page sizes
Currently TestPhysicalMemoryUtilization can fail on systems with large
physical page sizes like 64 KiB because all the of the holes to be
scavenged are not aligned to the page size. The holes themselves are 64
KiB so this is actually quite likely.

Bump the size of the allocations for systems with larger physical page
sizes, and add additional slack to the threshold for unaligned pieces of
the holes that may be unaligned.

Fixes #49411.

Change-Id: Iafb35b8761dc9cdc53d3745c4771b1a64c5c97b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/363415
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-11-11 20:20:50 +00:00
Michael Anthony Knyszek
3e94140465 runtime/debug: make TestFreeOSMemory more robust
FreeOSMemory relies on the function FreeOSMemory increasing HeapReleased
as opposed to the background scavenger, because it reads memory stats
*after* the free of a large allocation. However, before that even
happens, the background scavenger can swoop in and release all that
memory, making it appear as if FreeOSMemory didn't do anything.

This change modifies the test to just make sure that the large
allocation's memory is returned to the OS *somehow*, by the end of the
test. It doesn't really care which happens. It also increases the size
of that large allocation to increase the likelihood that the test isn't
relying 100% on the background scavenger, and that FreeOSMemory is doing
some of the work.

Fixes #49478.

Change-Id: Ief1d839753720ebb88cbb616c46302293ee2d19c
Reviewed-on: https://go-review.googlesource.com/c/go/+/363414
Reviewed-by: David Chase <drchase@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-11-11 20:20:42 +00:00
Pavel
48f1cde942 database/sql: prevent closes slices from assigning to free conn
In function connectionCleanerRunLocked append to closing slice affects db.freeConns and vise versa. Sometimes valid connections are closed and some invalid not.

Change-Id: I5282f15be3e549533b7d994b17b2060db3c0e7da
GitHub-Last-Rev: b3eb3ab6f4
GitHub-Pull-Request: golang/go#49429
Reviewed-on: https://go-review.googlesource.com/c/go/+/362214
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 19:46:03 +00:00
Robert Griesemer
d60a4e69f1 spec: fix a broken link
Thanks for jtagcat@ for finding this.

Change-Id: If7324808edbae19ec8bf503b04e0426f3fb3b47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363394
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 19:44:13 +00:00
hasheddan
f1935c5270 obj/riscv: fix link to risc-v dwarf register numbers
The repository name and structure in the RISC-V GitHub org has been
modified, rendering the existing link invalid. This updates to point at
the new location of the RISC-V DWARF specification.

Change occured in https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/208

Change-Id: I8ca4c390bee2d7ce20418cdd00e4945a426cf5f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/363355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Than McIntosh <thanm@google.com>
2021-11-11 19:41:06 +00:00
jiahua wang
8ce1a953fb io: add error check to TeeReader Example
Change-Id: I0b94bdced47483c6412e9979ce2d103fbfc52afb
Reviewed-on: https://go-review.googlesource.com/c/go/+/353729
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
2021-11-11 19:34:23 +00:00
Cherry Mui
84277bfd07 runtime: fix C compilation error in TestCgoTracebackGoroutineProfile
Use C89 declaration. Also fix indentation.

Change-Id: Ib974eb32ac95610d0b0eca00ca3b139b388c73bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/363356
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-11 18:32:21 +00:00
Cuong Manh Le
73a4bbb0df cmd/compile: fix missing ddd when building call for function instantiation closure
When building a call expression for function instantiation closure, if
it's a variadic function, the CallExpr.IsDDD must be set for typecheck
to work properly. Otherwise, there will be a mismatch between the
arguments type and the function signature.

Fixes #49516

Change-Id: I0af90ee3fcc3e6c8bba8b20e331e044cbce17985
Reviewed-on: https://go-review.googlesource.com/c/go/+/363314
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-11-11 17:18:13 +00:00
Neil Alexander
666fc173c0 doc/go1.18: document http.Transport.Dial* being used in js/wasm
This PR adds a note into the Go 1.18 changelog for CL 330852.

Updates #46923.

Change-Id: I99150e9275ce23fcf3697d6a22ac216818223c74
GitHub-Last-Rev: b2772ce68b
GitHub-Pull-Request: golang/go#49258
Reviewed-on: https://go-review.googlesource.com/c/go/+/360297
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-11 16:17:21 +00:00
Cherry Mui
8c73f80400 runtime: bypass scheduler when doing traceback for goroutine profile
When acquire a goroutine profile, we stop the world then acquire a
stack trace for each goroutine. When cgo traceback is used, the
traceback code may call the cgo traceback function using cgocall.
As the world is stopped, cgocall will be blocked at exitsyscall,
causing a deadlock. Bypass the scheduler (using asmcgocall) to fix
this.

Change-Id: Ic4e596adc3711310b6a983d73786d697ef15dd72
Reviewed-on: https://go-review.googlesource.com/c/go/+/362757
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 15:34:02 +00:00
Bryan C. Mills
47b3ab5ede doc/go1.18: add a release note for 'go mod vendor -o'
For #47327

Change-Id: I50418c0d017c4e90a2c13d26945ee639079e4e33
Reviewed-on: https://go-review.googlesource.com/c/go/+/363174
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paschalis Tsilias <paschalistsilias@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 14:57:18 +00:00
Than McIntosh
d76b1ac3e1 net: skip new testpoint TestUDPIPVersionReadMsg on plan9
Skip TestUDPIPVersionReadMsg on plan9, since it does things
not supported on that OS.

Change-Id: Icd1716fb5ed4e8877e57acb8c851ec3be72e83e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/363354
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-11 13:58:28 +00:00
Than McIntosh
c49627e81b cmd/compile: use canonical stringslice/ representations in abiutils
A chunk of code in abiutils was synthesizing the internals of a Go
string type as "struct { unsafe.Pointer, uintptr }" instead of the
more canonical representation "struct { *uint8, int }" used elsewhere
in the compiler. The abiutils type was being pulled into the code
during late call expansion, which resulted in two different entries in
the SSA named value table for the same variable piece, each with
different types; this then confused DWARF location list generation.
This patch changes the abiutils synthesized type to be consistent with
other parts of the back end, and makes a similar change for
synthesized slice types (use "struct { *uint8, int, int }").

Fixes #47354.

Change-Id: If789031cdc7abaf215bc75ee6eb863defbe530be
Reviewed-on: https://go-review.googlesource.com/c/go/+/362715
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-11 11:47:33 +00:00
Than McIntosh
79e03a9281 cmd/compile: include register-resident output params in DWARF-gen
During the register ABI work, a change was made in CL 302071 to
"stackframe" to treat register-resident output parameter (PARAMOUT)
variables that same as locals, which meant that if they were unused,
we'd delete them from the "Dcl" slice. This has the effect of making
them invisible to DWARF generation later on in the pipeline, meaning
that we don't get DIEs for them in the debug info. This patch fixes
the problem by capturing these params prior to optimization and then
adding them back in for consideration when we're processing the
params/locals of a function during DWARF generation.

Fixes #48573.

Change-Id: I2b32882911c18f91c3e3d009486517522d262685
Reviewed-on: https://go-review.googlesource.com/c/go/+/362618
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-11-11 11:47:18 +00:00
Than McIntosh
e9ef931e06 cmd/compile/internal/ssa: fix debug location gen issue with zero width ops
Revamp the way that buildLocationLists() handles zero-width
operations, to fix a couple of problems that result in bad debug
locations.

The problematic scenario in this specific bug is where you have a
parameter arriving in a register X, then a spill of register X to
memory as the first non-zero-width instruction in the function.
Example:

    v68 = ArgIntReg <unsafe.Pointer> {ctx+0} [1] : BX (ctx[unsafe.Pointer])
    v67 = ArgIntReg <unsafe.Pointer> {ctx+8} [2] : CX (ctx+8[unsafe.Pointer])
    ...
    v281 = StoreReg <unsafe.Pointer> v67 : ctx+8[unsafe.Pointer]

The existing buildLocationLists implementation effectively buffers or
bundles changes from zero-width instructions until it it sees a
non-zero-width instruction, but doing that in this case winds up
making it look as though the parameter is live into the function in
memory, not in a register.

The fix for this to separate out zero-width ops into two distinct
categories: those that whose lifetimes begin at block start (ex:
OpArg, Phi) and those whose effects are taking place at the nearest
non-zero-width instruction (ex: OpSelect0). In this patch we now
handle the first category of ops in an initial pre-pass for each
block, and leave the second category for the main pass through the
block. See the notes on the issue below for a more detailed
explanation of the failure mode.

Fixes #46845.

Change-Id: I27488d4c041019d5a0b897b7cf53000f63aab1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/362244
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2021-11-11 11:47:08 +00:00
Jason A. Donenfeld
a01a6d6efe net: add conversion from AddrPort to TCPAddr to complement existing inverse
We already have various member functions of TCPAddr that return an
AddrPort, but we don't have a helper function to go from a AddrPort to a
TCPAddr. UDP has this, but it was left out of TCP. This commit adds the
corresponding function.

Updates #49298.

Change-Id: I85732cf34f47c792fe13a6b4af64fd4b0e85d06a
Reviewed-on: https://go-review.googlesource.com/c/go/+/362596
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-11 11:00:33 +00:00
Dmitry Vyukov
1ec51087e5 cmd/link/internal/loadelf: better error message for ignored symbols
Currently it's quite hard to debug these error messages about ignored symbols
because there are only some numbers and no symbol name. Add symbol name. Before:
135029: sym#952: ignoring symbol in section 11 (type 0)
After:
135029: sym#952 (_ZN11__sanitizer9SpinMutexC5Ev): ignoring symbol in section 11 (type 0)

Change-Id: I7fec50b5798068c74827376613be529803838c5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363034
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitry Vyukov <dvyukov@google.com>
2021-11-11 07:03:15 +00:00
Ian Lance Taylor
99fa49e4b7 lib/time, time/tzdata: update to 2021e
Doing this a little early in the release cycle as there have been some
changes in the handling of old timezones. They should continue to
work as expected, but more testing time may be useful.

For #22487

Change-Id: I3686fed79a052c46112445055044cff5842f2a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/362874
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-11 05:16:39 +00:00
Ian Lance Taylor
4b27d40b50 misc/cgo/testshared: correct test of gccgo version number
We still don't run the gccgo tests, because they don't run in module mode.
But now we at least get the version number check right.

Change-Id: Ifde4512c30605d1cb7e3a521f381a05c783549b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/362996
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-11 04:54:05 +00:00
Changkun Ou
d5a5a13ad9 sync: clarify the validity to call Map methods inside Range
This change clarifies that calling all Map methods inside the callback
of Range is allowed. For further assurance, a nested range call test
is also added.

Fixes #46399

Change-Id: I0a766a5c1470e6b573ec35df1ccd62b2e46f1561
Reviewed-on: https://go-review.googlesource.com/c/go/+/337389
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-11-11 04:41:56 +00:00
Ian Lance Taylor
3949faf72e test: add test that was miscompiled by gccgo
For #49512

Change-Id: Ic08652a4ec611b27150bf10b1118c1395715e5d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/363156
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-11-11 04:02:33 +00:00
Jason A. Donenfeld
4d0683965b net: do more faithful conversion from AddrPort to UDPAddr
A UDPAddr with a nil IP is a valid state, representing an AF-agnostic
unspecified address, so checking for addr.IsValid() isn't correct;
remove that, as it's only needed in the UDP rx path where it can be
added. Secondly, forcing everything to be IPv6 also is not correct, and
was likely done when the missing .AsSlice() made doing the right thing
less ergonomic. Fix this by using .AsSlice(), which properly preserves
IP version.

Change-Id: Idd1eaecd4076f32a843f859a0a9802ef98f956d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/361478
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-11-10 22:16:25 +00:00
Robert Griesemer
23f653df96 cmd/compile/internal/types2: remove structuralString in favor of inlined code
structuralString was used only in one place (for built-in copy).
Remove it in favor of custom and more efficient inlined code.

Follow-up on feedback received for CL 363075.

Change-Id: Ic5857c47255c5c712be7971aae4542fef9960fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/363154
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 21:59:24 +00:00
Robert Griesemer
96c94c2c83 cmd/compile/internal/types2: slightly relax notion of structural type
If we have all channel types in a constraint, there is no structural type
if they don't all have the same channel direction (and identical element
types, of course). By allowing different channel types for the purposes of
the structural type, as long as there is not a send-only _and_ a receive-
only channel in the type set, we make it possible to find a useful, if
restricted by channel direction, structural type where before there was
none.

So if we have unrestricted and send-only channels, the structural type is
the send-only channel, and vice versa.

For all operations on channels that rely on a structural type, it's always
ok to have an unrestricted channel, so this is not affecting their behavior.
But it makes those operations more flexible in the presence of type parameters
containing mixed channel types.

For constraint type inference, where we currently may not infer a channel
at all, this change allows us to infer a more restricted channel (send- or
receive-only). If the inferred channel type is a valid type argument we win;
if not we haven't lost anything.

Use structuralType for send and receive operations and adjust related
error messages (the error message that change are the ones involving
type parameters, so historic error messages are preserved).

Fixes #45920.

Change-Id: If3a64d29c37e7734d3163df330f8b02dd032bc60
Reviewed-on: https://go-review.googlesource.com/c/go/+/363075
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-10 21:59:23 +00:00
Dan Scales
229b909313 cmd/compile: don't do Resolve on OKEY identifiers during import
For generic functions, we can export untransformed OKEY nodes, and the
key identifier is written as an ONONAME. But in this case, we do not
want to call Resolve() on the identifier, since we may resolve to a
global type (as happens in this issue) or other global symbol with the
same name, if it exists. We just want to keep the key identifier as an
Ident node.

To solve this, I added an extra bool when exporting an ONONAME entry,
which indicates if this entry is for a key or for a global (external)
symbol. When the bool is true (this is for a key), we avoid calling
Resolve().

Fixes #49497

Change-Id: Ic8fa93d37bcad2110e0e0d060080b733e07e35d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/363074
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-11-10 21:53:03 +00:00
Paschalis Tsilias
f410786c5f cmd/go: add 'go mod vendor -o' flag
Adds a new flag to 'go mod vendor' which overrides the default
'vendor' destination directory. This can be helpful for writing the
vendor tree to a temporary location for use by other tools.
The argument can be a relative or an absolute path.
This flag has no other influence on how the command behaves.

Fixes #47327

Change-Id: I4502931127616b181dc90a2066d2fb57bfe48f96
Reviewed-on: https://go-review.googlesource.com/c/go/+/338149
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 21:32:50 +00:00
Michael Anthony Knyszek
a881409960 runtime: rewrite TestPhysicalMemoryUtilization
This test changes TestPhysicalMemoryUtilization to be simpler, more
robust, and more honest about what's going on.

Fixes #49411.

Change-Id: I913ef055c6e166c104c62595c1597d44db62018c
Reviewed-on: https://go-review.googlesource.com/c/go/+/362978
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-11-10 20:45:04 +00:00
emahiro
b2d826c09f internal/cache: document 'go clean -fuzzcache' in README
Fixes: #48900

Change-Id: I9235441886ed7cbdfdcbd283480f52d9216c3ea2
Reviewed-on: https://go-review.googlesource.com/c/go/+/357233
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
2021-11-10 20:04:06 +00:00
Robert Griesemer
23dd389ac6 cmd/compile/internal/types2: refer to structural rather than single underlying type in errors
This brings the error messages in sync with the terminology that
will be used it the spec.

Change-Id: Ia05993776c649be9eb2cdf948a583b9a49f9b192
Reviewed-on: https://go-review.googlesource.com/c/go/+/362997
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
2021-11-10 18:24:20 +00:00
Robert Griesemer
6406e09f69 cmd/compile/internal/types2: move some functions into different files (cleanup)
- move structuralType/structuralString into type.go
- move functions exported for the compiler into compilersupport.go
- updated/added comments
- removed AsNamed and AsInterface - not needed by compiler

No semantic changes.

Change-Id: Ia454a49edafd627c2a25b0b71db4aa93ddd7f1f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/362995
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-10 18:24:14 +00:00
Robert Findley
097aaa9cd6 go/doc: don't treat functions returning type parameters as constructors
Functions returning type parameters were erroneously being interpreted
as 'constructors' of their type parameter, resulting in them being
excluded from documentation. Fix this by explicitly excluding type
parameters when looking for defined type names among function results.

Fixes #49477

Change-Id: I22510f655f47e192a852332df5b91740f46c51eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/362758
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 18:06:32 +00:00
Robert Griesemer
8a3be15077 cmd/compile/internal/types2: rename structure to structuralType
And rename structureString to structuralString.

Now that we have an updated definition for structural types in
the (forthcoming) spec, name the corresponding function accordingly.

No semantic changes.

Change-Id: Iab838f01a37075bedf2d8bc4f166b0217672b85f
Reviewed-on: https://go-review.googlesource.com/c/go/+/362994
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 17:15:54 +00:00
Robert Griesemer
0aa194f758 cmd/compile/internal/types2: use type variables consistently in Checker.conversion
We have V and T and Vu and Tu. When calling the various isX predicates
consistently use Vu and Tu.

(We could also use V an T because the predicates call under anyway,
but using Vu and Tu removes an unnecessary call to Named.under if
V or T are *Named.)

Also, removed some outdated comments.

Change-Id: I6fcd9ce5f6292e89ac2afd597b72fd0790e84ff1
Reviewed-on: https://go-review.googlesource.com/c/go/+/362895
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-10 17:15:52 +00:00
Robert Griesemer
17980dff36 doc: make a copy of the latest Go 1.17 spec
This will allow us to compare the changes made for Go 1.18.

Change-Id: I1456270b201967f5cb05e66cec556939e6e33265
Reviewed-on: https://go-review.googlesource.com/c/go/+/362894
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-10 05:08:25 +00:00
Hajime Hoshi
e984240d31 runtime: fix unworkable comments for go:nosplit
Change-Id: I71c29a2dc7e5b2b6bc35093535228d2907b16b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/361595
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
2021-11-10 02:57:43 +00:00