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

50438 Commits

Author SHA1 Message Date
Rhys Hiltner
5f0e5d21bb runtime/pprof: disable GC during calibration test
TestCPUProfileMultithreadMagnitude compares Go's CPU profile against the
OS's accounting of the process's execution time, expecting them to be
near equal. Background work from the runtime (especially in the garbage
collector) can add significant noise to that measurement and flakiness
to the test. Disable automatic GC cycles during the test.

Updates #49065

Change-Id: Ie88895bfea17374278c5187f3a83e9f486bd37fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/359934
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
2021-11-03 15:59:11 +00:00
Dan Scales
c143661568 test/typeparam: add test for indexing on typeparams with various constraints
Add test for indexing on variables whose types are constrained to
various kinds of types.

Change-Id: I991eecfe39dba5d817c0fbe259ba558d4881ea84
Reviewed-on: https://go-review.googlesource.com/c/go/+/360867
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-03 15:47:47 +00:00
Joel Sing
6458b2e8db all: add support for c-archive and c-shared on linux/riscv64
This provides the runtime glue (_rt0_riscv64_linux_lib) for c-archive and c-shared
support, along with enabling both of these buildmodes on linux/riscv64.

Both misc/cgo/testcarchive and misc/cgo/testcshared now pass on this platform.

Fixes #47100

Change-Id: I7ad75b23ae1d592dbac60d15bba557668287711f
Reviewed-on: https://go-review.googlesource.com/c/go/+/334872
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-03 09:23:34 +00:00
Joel Sing
5b213178e7 cmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64
The X3 (aka GP) register will potentially be loaded with the __global_pointer$ symbol
during program start up (usually by the dynamic linker). As such, non-Go code may depend
on the contents of GP and calculate offsets based on it, including code called via cgo
and signal handlers installed by non-Go code. As such, stop using the X3 register so
that there are fewer issues interacting between Go and non-Go code.

While here remove the X4 (TP) name from the assembler such that any references must
use the 'TP' name. This should reduce the likelihood of accidental use (like we do
for the 'g' register). The same applies for X3 (GP) when the -shared flag is given.

Updates #47100

Change-Id: I72e82b5ca3f80c46a781781345ca0432a4111b74
Reviewed-on: https://go-review.googlesource.com/c/go/+/351859
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-03 09:08:46 +00:00
Matthew Dempsky
519c0a2323 cmd/compile/internal/types2: port nomono check from go/types
Same logic as CL 357449 (including CL 360815), just ported to types2.

Updates #48098.

Change-Id: I4578f7329bb4ffc42410025bb6cb97e24697ebfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/360857
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-03 05:00:00 +00:00
Ian Lance Taylor
a4b2c579e9 runtime: install sigPreempt signal handler for c-archive/c-shared
Fixes #49288

Change-Id: I7bfcbecbefa68871a3e556935a73f241fff44c0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/360861
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>
2021-11-03 00:49:50 +00:00
Robert Griesemer
8f0ca7dc72 cmd/compile/internal/types2: report cause for failing const conversions
Follow-up on CL 360396.

Change-Id: Icd802baffb1fef91f8fef0070b6167a438ceda1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/360795
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-03 00:21:24 +00:00
Robert Findley
49a00631b1 go/types: report cause for failing const conversions
This is a port of CL 360795 to go/types. Error messages were adjusted
accordingly, with a TODO to fix the discrepancy.

Change-Id: Ifd7d8248fa11a31fde391021f3c5f1840877892f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360937
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-03 00:07:38 +00:00
Robert Findley
2b81b863a2 go/types: fix indexing of generic types
This is a clean port of CL 360603 to go/types.

Change-Id: Iadb312f07e509ff83339d5525765b7b7987bf233
Reviewed-on: https://go-review.googlesource.com/c/go/+/360936
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-03 00:07:10 +00:00
Robert Findley
d6f7203a3c go/types: adjust printing of type parameter in error
This is a clean port of CL 360514 to go/types.

Change-Id: Ia13638b3758b3b8017867934d09136ac5f9a62ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/360935
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-03 00:07:03 +00:00
Robert Findley
32d27527a6 go/types: fix conversions of constants to type parameter
This is a port of both CL 360396 and CL 360796 to go/types. The latter
is added to avoid introducing an intermediate bug.

An error message was adjusted in issue49296.go2, with a TODO to switch
to the types2 error.

Change-Id: Iede294b69b4e097e53876498f039ee18667568c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/360934
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-03 00:06:52 +00:00
Ian Lance Taylor
a0f373ca08 runtime/asan: declare asan reporting functions in C
Fixes #49287

Change-Id: I3f970d6db0b1dee886df2f7bb6cbeb56a37c42c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/360860
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 23:44:58 +00:00
Dan Scales
eb63cbd295 cmd/compile: remove TODO that is no longer relevant
types2 methods are now sorted in the same way as types1, so this TODO is
no longer needed.  (Comment change only).

Change-Id: Ic975ce001a5d54f15381a9cb7b6969dff795e3b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/360856
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-11-02 23:05:17 +00:00
Brad Fitzpatrick
2157498dfe doc/go1.18: remove some redundancy from netip docs
Change-Id: I593862331add3366f6b337844588568301746b80
Reviewed-on: https://go-review.googlesource.com/c/go/+/360608
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 22:20:40 +00:00
Robert Findley
42e6b5bce2 go/types: differently named types are not assignable
This is a clean port of CL 360274 to go/types.

Change-Id: Idfa584fab95f7226e10b1a7c5b06d56a0bf9d757
Reviewed-on: https://go-review.googlesource.com/c/go/+/360759
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-02 21:19:29 +00:00
Robert Findley
ea403bc237 go/types: disallow lone type parameter on RHS of type declaration
This is a clean port of CL 359177 to go/types.

Change-Id: I6c1574e3a1c23ea326eb8d4aacea0e78415703ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/360758
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-02 21:19:22 +00:00
Robert Findley
80065cf2f6 go/types: implement singleType and structure (type)
This is a clean port of CL 359015 to go/types.

Change-Id: Iea4e3bfe0a4ae0e5a9052cb6e66c01405bd57c3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/360756
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-02 21:18:44 +00:00
Robert Findley
60fd3ed2b1 go/types: rename isNamed predicate to hasName
This is a clean port of CL 358621 to go/types.

Change-Id: I4e858b1b70cff69b6e0e76bb8a58a70ff54990c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/360755
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-02 21:18:39 +00:00
Robert Findley
1012bc810f go/types: clean up asT converters (step 2 of 2)
This is a clean port of CL 358774 to go/types.

Change-Id: Icba54336de2b8de7c2002d2a44cac856907178c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/360754
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-02 21:18:33 +00:00
Josh Bleecher Snyder
79024cf33d errors: improve wording in As doc comment
"so" didn't have an antecedent.

Change-Id: I27f7b334decea7bc34bfa3f3f2d3a79874c6fe90
Reviewed-on: https://go-review.googlesource.com/c/go/+/360797
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 20:59:34 +00:00
Jason7602
b24687394b archive/zip: don't panic on (*Reader).Open
Previously, opening a zip with (*Reader).Open could result in a panic if
the zip contained a file whose name was exclusively made up of slash
characters or ".." path elements.

Open could also panic if passed the empty string directly as an argument.

Now, any files in the zip whose name could not be made valid for
fs.FS.Open will be skipped, and no longer added to the fs.FS file list,
although they are still accessible through (*Reader).File.

Note that it was already the case that a file could be accessible from
(*Reader).Open with a name different from the one in (*Reader).File, as
the former is the cleaned name, while the latter is the original one.

Finally, made the actual panic site robust as a defense-in-depth measure.

Fixes CVE-2021-41772
Fixes #48085

Co-authored-by: Filippo Valsorda <filippo@golang.org>
Change-Id: I6271a3f2892e7746f52e213b8eba9a1bba974678
Reviewed-on: https://go-review.googlesource.com/c/go/+/349770
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Julie Qiu <julie@golang.org>
2021-11-02 20:47:30 +00:00
Robert Findley
b29182b54a go/types: clean up asT converters (step 1 of 2)
This is a port of CL 358597 to go/types. A comment was missing in the
base of applyTypeFunc, which had been there since the initial check-in
of types2; somehow it was not in go/types.

Change-Id: If08efd92d782dd3099b26254ae6e311c6cea8c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/360477
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-02 20:33:56 +00:00
Michael Anthony Knyszek
7c9510ef3e syscall: fix finalizer fd close bugs in TestFcntlFlock and TestPassFD
Currently, the syscall test suite takes very little time to run. It
stands to reason that pretty much every time, zero GCs execute.

With CL 309869, this changes because the minimum heap size is lowered,
triggering two bugs in the test suite.

One bug is in TestFcntlFlock, where a raw FD is wrapped in an os.File
whose last reference is passed into a Cmd. That FD is then closed by a
defer syscall.Close, instead of the os.File's Close, so the finalizer
may fire *after* that FD has already been reused by another test.

The second bug is in the child helper process of TestPassFD, where
there's a small window in which a temp file's FD is encoded for an
out-of-band unix domain socket message to the parent, but not yet sent.
The point of encoding is also the last reference that FD's os.File, so a
finalizer may run at any time. While it's safe for the finalizer to run
after the FD is sent, if it runs before, the send will fail, since unix
domain sockets require that any sent FDs are valid.

Change-Id: I2d1bd7e6db6efcc6763273217fd85cb5b9764274
Reviewed-on: https://go-review.googlesource.com/c/go/+/360575
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 20:26:55 +00:00
Matthew Dempsky
c45c32b1cd go/types: avoid closure allocations in mono check
This CL replaces monoEdge's "report" field with fields "pos" and
"typ", and pushes the logic for formatting them into the report
loop. This avoids needing to allocate a function closure for each
edge.

Also tweak a test case so the two type parameters involved in the
cycle aren't both "T" so they're easier to understand.

Change-Id: I9d392ad1d99a4c5e89da4613084e885149ebad07
Reviewed-on: https://go-review.googlesource.com/c/go/+/360815
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-02 19:56:02 +00:00
Damien Neil
1011e26b9c net/http: deflake TestServerKeepAlivesEnabled_h{1,2}
This test assumes that two successive TCP connections will use different
source ports. This does not appear to be a universally safe assumption.

Rewrite the test to use httptrace to detect connection reuse instead.

Fixes #46707

Change-Id: Iebfbdfdeb77a1e6663a0c654dc847cc270c5d54d
Reviewed-on: https://go-review.googlesource.com/c/go/+/360854
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-02 19:37:42 +00:00
Than McIntosh
80a7968842 cmd/compile/internal/abi: fix some typos in comments
Fix a few types in the header comment for 'ComputePadding'.

Change-Id: If38911e6dcbec571845ae44eef30fd6c33f589cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/360814
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-02 19:36:46 +00:00
Josh Bleecher Snyder
c702f91b38 net: add ReadFromUDPAddrPort
It is now possible to do completely allocation-free UDP.

This is implemented completely separately from ReadFromUDP
because ReadFromUDP exists in a delicate balance to allow
mid-stack inlining. After performance-sensitive callers have
migrated to ReadFromUDPAddrPort, we may be able to simplify
ReadFromUDP to call ReadFromUDPAddrPort.

name                          old time/op    new time/op    delta
WriteToReadFromUDPAddrPort-8    4.71µs ± 2%    4.81µs ± 5%    +2.18%  (p=0.000 n=14+14)

name                          old alloc/op   new alloc/op   delta
WriteToReadFromUDPAddrPort-8     4.00B ± 0%     0.00B       -100.00%  (p=0.000 n=15+15)

name                          old allocs/op  new allocs/op  delta
WriteToReadFromUDPAddrPort-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=15+15)

Change-Id: I37f5ad9416a1d4333ed48d83474b2cf933b2a1be
Reviewed-on: https://go-review.googlesource.com/c/go/+/360600
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 18:35:35 +00:00
Josh Bleecher Snyder
433ba582f7 net: optimize WriteToUDPAddrPort
See the recent change optimizing WriteMsgUDPAddrPort
for an explanation of why this change includes copy/paste/modify
instead of implementing WriteToUDP using WriteToUDPAddrPort.

name                          old time/op    new time/op    delta
WriteToReadFromUDPAddrPort-8    5.02µs ± 3%    4.71µs ± 2%   -6.31%  (p=0.000 n=15+14)

name                          old alloc/op   new alloc/op   delta
WriteToReadFromUDPAddrPort-8     68.0B ± 0%      4.0B ± 0%  -94.12%  (p=0.000 n=15+15)

name                          old allocs/op  new allocs/op  delta
WriteToReadFromUDPAddrPort-8      3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.000 n=15+15)

Change-Id: I301715e774de07eb6ccb4e329ccf2e554609abc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/360599
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 18:35:29 +00:00
Josh Bleecher Snyder
0b37bd9b3f net: add BenchmarkWriteToReadFromUDPAddrPort
The main item of interest is the allocs.

BenchmarkWriteToReadFromUDPAddrPort-8   	  237735	      5152 ns/op	      68 B/op	       3 allocs/op

Change-Id: I5cb3f2e1ebbb02acc51039c2266e99b90d388a99
Reviewed-on: https://go-review.googlesource.com/c/go/+/360598
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 18:35:22 +00:00
Keith Randall
79c5240799 cmd/compile: mark type descriptors as always dupok
The types of the two interfaces should be equal, but they aren't.
We end up with multiple descriptors for a type when we need type
descriptors to be unique.

Fixes #49241

Change-Id: I8a6c70da541c6088a92a01392bc83b61cc130eba
Reviewed-on: https://go-review.googlesource.com/c/go/+/360134
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-11-02 18:31:53 +00:00
Josh Bleecher Snyder
f7a95d2c17 debug/gosym: bulk allocate Syms
name                old time/op    new time/op    delta
115/NewLineTable-8    80.7ns ± 1%    81.7ns ± 3%     ~     (p=0.408 n=10+8)
115/NewTable-8        76.3µs ± 2%    63.3µs ± 3%  -17.03%  (p=0.000 n=9+9)
115/LineToPC-8        56.8µs ± 2%    56.8µs ± 3%     ~     (p=0.905 n=10+9)
115/PCToLine-8         252ns ± 1%     256ns ± 5%     ~     (p=0.183 n=10+10)

name                old alloc/op   new alloc/op   delta
115/NewLineTable-8      384B ± 0%      384B ± 0%     ~     (all equal)
115/NewTable-8         164kB ± 0%     172kB ± 0%   +4.97%  (p=0.000 n=10+10)
115/LineToPC-8         0.00B          0.00B          ~     (all equal)
115/PCToLine-8         0.00B          0.00B          ~     (all equal)

name                old allocs/op  new allocs/op  delta
115/NewLineTable-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
115/NewTable-8         1.04k ± 0%     0.01k ± 0%  -98.75%  (p=0.000 n=10+10)
115/LineToPC-8          0.00           0.00          ~     (all equal)
115/PCToLine-8          0.00           0.00          ~     (all equal)

Change-Id: Ibfe6c0cb86737dee8209cb1f58f5b796aa7b30aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/353134
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-02 18:24:18 +00:00
Roland Shoemaker
629ffebd45 cmd/go: disallow profile flags when using -fuzz
Disallow the usage of coverprofile, blockprofile, cpuprofile, memprofile,
mutexprofile, and trace when fuzzing, since these currently do not work
as the user would expect.

Fixes #48178

Change-Id: Ibe6dfaef9b28a91c60c26fcad38c33a2a959d869
Reviewed-on: https://go-review.googlesource.com/c/go/+/360395
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 18:01:20 +00:00
Matthew Dempsky
4ec52e363e go/types: add check that code is monomorphizable
This CL adds a check to ensure that generic Go code doesn't involve
any unbounded recursive instantiation, which are incompatible with an
implementation that uses static instantiation (i.e., monomorphization
or compile-time dictionary construction).

Updates #48098.

Change-Id: I9d051f0f9369ab881592a361a5d0e2a716788a6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/357449
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
2021-11-02 17:59:53 +00:00
Robert Griesemer
7548327374 comd/compile/internal/types2: add missing nil check in const conversion
Follow-up on CL 360396.

Fixes #49296.

Change-Id: Ie08f86ae884da4cfd5db557cbf4f721a237dc39f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360796
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-02 17:53:48 +00:00
Paul E. Murphy
4e7dd9fc08 bytes: test for page boundary crosses on sep of Index
Improve TestIndexNearPageBoundary to verify needles
ending on a page boundary don't cause a segfault.

Change-Id: I2edb13db63a71dc9955e266f6b97026ee13bf76e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356889
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-11-02 17:31:50 +00:00
Robert Findley
62b29b0359 go/types: generalize assignability to generic types
This is a port of CL 357917 to go/types. Some error messages in
assignability.go2 had to be adjusted. I left a TODO to investigate
whether we should align error messages.

Change-Id: Ia323ffe18bc08e82de62044f35b8b0f3edd7dc08
Reviewed-on: https://go-review.googlesource.com/c/go/+/360476
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-02 17:01:14 +00:00
Robert Findley
af8aafd570 go/types: clarify is/underIs semantics and implementation
This is a port of CL 358594 to go/types. Some code in conversions.go had
to be trivially reorganized to align with types2 -- I'm not sure how
go/types diverged from the base.

Change-Id: I40ce247bbb3b9d0e87ce88c50e440c12774c0745
Reviewed-on: https://go-review.googlesource.com/c/go/+/360475
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-02 17:01:01 +00:00
Robert Findley
c406380fa9 go/types: better error messages for empty type sets
This is a clean port of CL 358175 to go/types.

Change-Id: If1b4e51d1579fd168e651d79d031335ff09ca128
Reviewed-on: https://go-review.googlesource.com/c/go/+/360474
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-11-02 16:57:03 +00:00
vpachkov
8c8baad927 runtime: check amd64 microarchitecture level at startup
Make Go runtime throw if it's been compiled to assume instruction
set extensions that aren't available on the CPU.
Updates #48506

Change-Id: Ic4d6696e1cd6b28d389a86fe64e8175ea3ca135a
GitHub-Last-Rev: ba338377f5
GitHub-Pull-Request: golang/go#48514
Reviewed-on: https://go-review.googlesource.com/c/go/+/351191
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
2021-11-02 16:40:04 +00:00
Cuong Manh Le
58fb05a24a cmd/compile: explain special treatment when rewrite slice literal args
Followup discussion in CL 360055.

Change-Id: I36212c2a497b152d01ed86d244d5f57bd34a64a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/360614
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 16:19:52 +00:00
Cuong Manh Le
f2ff1c6074 cmd/compile: fix rewriting slice literal call argument
When seeing Key:Value expression in slice literal, the compiler only
needs to emit tmp var for the Value, not the whole expression.

Fixes #49240

Change-Id: I7bda3c796a93c0fa1974f7c5930f38025dfa665c
Reviewed-on: https://go-review.googlesource.com/c/go/+/360055
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: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-11-02 16:19:45 +00:00
Bryan C. Mills
c6a0b6f2de Revert "runtime: fix missing pprof labels"
This reverts CL 351751.

Reason for revert: new test is failing on many builders.

Change-Id: I066211c9f25607ca9eb5299aedea2ecc5069e34f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360757
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-02 16:15:22 +00:00
Robert Griesemer
f801da7855 cmd/compile/internal/types2: fix indexing of generic types
Correctly track if the index expression is addressable.
Rewrote code slightly.

Fixes #49275.

Change-Id: Ic54edd0213a091173ff5403ab0e3e1f1fca0e361
Reviewed-on: https://go-review.googlesource.com/c/go/+/360603
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-02 16:12:28 +00:00
Robert Griesemer
599de4b2c3 cmd/compile/internal/types2: adjust printing of type parameter in error
For constraint type inference failures where the type parameter doesn't
match the constraint, print the type parameter rather than its type name
object. This provides more flexibility for improving the error message
down the road.

Change-Id: I188871d6f26a16cd96e59770966a1ec65607b128
Reviewed-on: https://go-review.googlesource.com/c/go/+/360514
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-02 16:12:23 +00:00
Robert Griesemer
d39c873966 cmd/compile/internal/types2: fix conversions of constants to type parameter
When converting a constant to a type parameter, the result is never
constant (type parameters are not constant types), but we still need
to verfy that the constant is representable by each specific type in
the type set of the type parameter.

Fixes #49247.

Change-Id: I460983c7070b33baadce25dd23210e10930cfb2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/360396
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-02 16:11:43 +00:00
Amelia Downs
c3cb1ecc36 internal/fuzz: minimize bytes to be human readable
Try to replace every byte with one of the following printable
characters: "012789ABCXYZabcxyz !\"#$%&'()*+,.".

Fixes #48129

Change-Id: Ie58f6bbc3431d50d9f0a3f608ba63e854ac6ce79
Reviewed-on: https://go-review.googlesource.com/c/go/+/352614
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Amelia Downs <adowns@vmware.com>
Trust: Katie Hockman <katie@golang.org>
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 15:51:21 +00:00
Felix Geisendörfer
da7173a2ed runtime: fix missing pprof labels
Use gp.m.curg instead of the gp when recording cpu profiler stack
traces. This ensures profiler labels are captured when systemstack or similar
is executing on behalf of the current goroutine.

After this there are still rare cases of samples containing the labelHog
function, so more work might be needed. This patch should fix ~99% of the
problem.

Fixes #48577.

Change-Id: I27132110e3d09721ec3b3ef417122bc70d8f3279
Reviewed-on: https://go-review.googlesource.com/c/go/+/351751
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
2021-11-02 15:15:09 +00:00
Michael Anthony Knyszek
4d7bf41beb syscall: remove GOMAXPROCS change in TestExecHelper
TestExec and TestExecHelper check for a workaround of a particular OS
bug on darwin that's triggered more often via asynchronous preemption.

As part of this, the test sets up 100 CPU-bound goroutines, and sets
GOMAXPROCS to 50, sleeping for a little bit before calling Exec. Thus
far, this is fine because the scheduler runs the Execing goroutine in a
timely manner. However, CL 309869 will reduce the minimum heap size,
causing a GC to happen during the test.

On a 16 CPU machine, with GOMAXPROCS at 50, and 100 CPU-bound
goroutines, both the OS scheduler and the Go scheduler are severly
oversaturated. As a result, the test often (not always, but often) runs
out for the full lifetime of those 100 goroutines, which run for about 1
second.

The minimum heap size reduction is not necessary to trigger this; an
additional call to runtime.GC in the helper is also sufficient to
trigger this delay.

The delay on its own isn't great, since it adds a whole second to
all.bash on its own. However, it also seems correlated with other
subprocess tests in the syscall package, namely TestPassFD and
TestFcntlFlock. These tests fail in a fairly superficial way: the file
descriptor for the temporary directories they make gets clobbered, is
closed, or becomes stale.

Change-Id: I213dd5e38967d19a8b317e6d4c5024b57f9e3fed
Reviewed-on: https://go-review.googlesource.com/c/go/+/360574
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 13:43:24 +00:00
Leonard Wang
088bb4bf4a A+C: add Leonard Wang (individual CLA)
Change-Id: I9fa687804c7f0f1d5a987b95ab1c3110468d1b65
Reviewed-on: https://go-review.googlesource.com/c/go/+/360054
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-02 06:25:39 +00:00
fanzha02
3ee426aefa cmd/dist: add asan tests in misc/cgo/testsanitizers package
Add asan tests to check the use of Go with -asan option.

Currenly, the address sanitizer in Go only checks for error
memory access to heap objects.

TODO: Enable check for error memory access to global objects.

Updates #44853.

Change-Id: I83579f229f117b5684a369fc8f365f4dea140648
Reviewed-on: https://go-review.googlesource.com/c/go/+/298615
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 06:21:44 +00:00