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

51270 Commits

Author SHA1 Message Date
Robert Griesemer
ade5488d75 doc/go1.18: document type parameter name restriction
For #47694.

Change-Id: I00862f987a0ff9f71e0295ce4320e6f9a6a4332f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376414
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-07 18:20:24 +00:00
Cuong Manh Le
98ed916369 cmd/compile: fix instantiation of types referenced during inlining
CL 352870 added extra phase for instantiation after inlining, to take
care of the new fully-instantiated types. However, when fetching inlined
body of these types's methods, we need to allow OADDR operations on
untyped expressions, the same as what main inlining phase does.

The problem does not show up, until CL 371554, which made the compiler
do not re-typecheck while importing, thus leaving a OXDOT node to be
marked as address taken when it's not safe to do that.

Fixes #50437

Change-Id: I20076b872182c520075a4f8b84230f5bcb05b341
Reviewed-on: https://go-review.googlesource.com/c/go/+/375574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-01-07 17:55:52 +00:00
Dmitri Shuralyov
2f45981679 .github: remove duplicate security link
Since a SECURITY.md file is present in the main Go repository,
GitHub already shows a "Report a security vulnerability" link
in the issue template list. Remove the duplicate custom link.

Fixes #49962.

Change-Id: Ifdf7e93b76ebd9258d907aa9cb4915c0dbc4f93e
Reviewed-on: https://go-review.googlesource.com/c/go/+/376357
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
2022-01-07 17:55:09 +00:00
Robert Griesemer
11b28e7e98 test/typeparam: adjust test preamble (fix longtests)
For #50481.

Change-Id: I27e6c6499d6abfea6e215d8aedbdd5074ff88291
Reviewed-on: https://go-review.googlesource.com/c/go/+/376216
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-01-07 06:34:04 +00:00
Robert Griesemer
40afced8d7 spec: be more precise with rules on specific types
Problem pointed out on golang-nuts mailing list.

Change-Id: If1c9b22e1ed7b4ec7ebcaadc80fa450333e6856c
Reviewed-on: https://go-review.googlesource.com/c/go/+/375799
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-07 02:37:20 +00:00
Robert Griesemer
2bb7f6b4f1 doc/go1.18: point to spec in same directory for release notes
The release notes explicitly refer to sections updated
for generics in the spec but then point to the old spec
which is very confusing for beta users.

For #47694

Change-Id: I5b555db3543cc32f088a8b267ec3f1195a52a812
Reviewed-on: https://go-review.googlesource.com/c/go/+/373174
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-07 02:32:39 +00:00
Robert Griesemer
ab4556a93d test/typeparam: adjust test preamble (fix longtests)
For #50317.

Change-Id: I24ccf333c380283a36b573ef8fc3e7fcd71bd17f
Reviewed-on: https://go-review.googlesource.com/c/go/+/376215
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
2022-01-07 02:32:03 +00:00
Robert Griesemer
c1e7c518ae test/typeparam: adjust test preamble (fix longtests)
For #50417.

Change-Id: Ic55727c454ec342354f7fbffd22aa350e0d392c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/376174
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07 01:36:17 +00:00
Russ Cox
07525e16ba math/big: fix spurious race in Rat.Denom, Float.SetRat
Rat maintains the invariant that x.b.neg is always false,
but Rat.Denom was writing x.b.neg = false itself too.
That makes Rat.Denom a writing operation, when it should
be a read-only operation. That in turn makes it unsafe to
use from multiple goroutines, which is highly unexpected.
Make it read-only and therefore race-free again.

Fixes #50473.

Change-Id: I97b87913954511e5200c0665d16b9ed63422e505
Reviewed-on: https://go-review.googlesource.com/c/go/+/375935
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-07 00:15:59 +00:00
Robert Griesemer
c295137ad8 go/types, types2: disallow multiple blank type parameters
Work-around for #50481: report an error for multiple
blank type parameters. It's always possible to use
non-blank names in those cases.

We expect to lift this restriction for 1.19.

For #50481.

Change-Id: Ifdd2d91340aac1da3387f7d80d46e44f5997c2a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/376058
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-07 00:02:57 +00:00
Robert Griesemer
042548b1fd cmd/compile: report type parameter error for methods only once
Move switch to enable method type parameters entirely
to the parser, by adding the mode AllowMethodTypeParams.
Ensure that the error messages are consistent.
Remove unnecessary code in the type checker.

Fixes #50317.

Change-Id: I4f3958722400bdb919efa4c494b85cf62f4002bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/376054
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06 23:39:43 +00:00
Katie Hockman
b9cae6f78f testing: fix deadlock with t.Parallel in testing seed corpus
The c.startParallel channel on the testContext is stuck
in t.Parallel() because c.running starts at 1 for the main
fuzz parent test, and is causing a deadlock because it is
never released. It would normally be released by tRunner,
but needs to instead be released by fRunner instead for fuzz
tests.

Fixes #50217

Change-Id: I2d010e9adddfd8e8321ff2f9dd2e43daf46c128f
Reviewed-on: https://go-review.googlesource.com/c/go/+/374054
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06 22:12:11 +00:00
Robert Griesemer
61014f00f2 go/types, types2: implement field access for struct structural constraints
This change implements field the access p.f where the type of p
is a type parameter with a structural constraint that is a struct
with a field f. This is only the fix for the type checker. The
compiler will need a separate CL.

This makes the behavior consistent with the fact that we can
write struct composite literals for type parameters with a
struct structural type.

For #50417.
For #50233.

Change-Id: I87d07e016f97cbf19c45cde19165eae3ec0bad2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/375795
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06 21:38:59 +00:00
Robert Griesemer
2bfa6ef63d go/types, types2: remove unused code in lookupFieldOrMethod
The underlying type of a type parameter is an interface,
so we don't need a special case for type parameters anymore.
Simply share the (identical) code for interfaces.

Adjust code in types.NewMethodSet accordingly.

No functional difference.
Preparation for fix of issues below.

For #50233.
For #50417.

Change-Id: Ib2deadd12f89e6918dec224b4ce35583001c3101
Reviewed-on: https://go-review.googlesource.com/c/go/+/375514
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06 21:38:58 +00:00
Robert Griesemer
c5540e53b1 go/types, types2: ensure that signature type bounds are interfaces
Do this by running verification for instantiated signatures
later, after the delayed type parameter set-up had a chance
to wrap type bounds in implicit interfaces where needed.

Fixes #50450

Change-Id: If3ff7dc0be6af14af854830bfddb81112ac575cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/375737
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06 21:38:57 +00:00
Bryan C. Mills
10f1ed131c time: skip TestTimerModifiedEarlier on plan9/arm
This test is observed to be flaky on the plan9-arm builder.
Skip it on that platform until it can be diagnosed and fixed.

For #50470

Change-Id: If626af426d856c377e00ac5baaca52899456556e
Reviewed-on: https://go-review.googlesource.com/c/go/+/375934
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>
2022-01-06 19:42:27 +00:00
Ian Lance Taylor
ed84a8357c test: add test of incorrect gofrontend error
For #50439

Change-Id: Ifad6e6f8de42121c695b5a4dc56e0f6606e2917e
Reviewed-on: https://go-review.googlesource.com/c/go/+/375796
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-01-06 19:21:12 +00:00
Robert Findley
7a3a2b18ff go/types, types2: eagerly check that constraints are not type params
As a result of the change to the underlying of a type parameter to be
its constraint interface, we had couple inaccuracies that combined to
cause an infinite recursion when type checking the invalid type
parameter list [A A].
 - We deferred tpar.iface() using check.later twice: once in
   newTypeParam, and then again at the end of collectTypeParams.
 - We deferred the check that type parameter constraints are not type
   parameters, even though this is unnecessary: the constraint type is
   known.

With these inaccuracies, tpar.iface() was executing before our guard
against using type parameters as constraints, causing an infinite
recursion through under().

Fix this by eagerly checking whether the constraint is a type
parameter, and marking it invalid if so. Also remove the unnecessary
calls to tpar.iface() at the end of collectTypeParams, as this will
already have been scheduled by newTypeParam.

Fixes #50321

Change-Id: I4eecbecf21656615867cb94be65b520e9e795bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/374294
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06 19:12:42 +00:00
Robert Griesemer
f009910625 cmd/compile/internal/types2: better error message for invalid range clause
Fixes #50372.

Change-Id: I8e4c0020dae42744cce016433e398e0b884bb044
Reviewed-on: https://go-review.googlesource.com/c/go/+/375475
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-01-06 16:22:21 +00:00
Bryan C. Mills
da7891f6f3 net: synchronize instead of sleeping in TestDialParallelSpuriousConnection
The arbitrary sleep in this test is empirically not always long enough
on slower builders. However, we know the exact number of connections
that should be dialed: we can wait on that number in the dial hook
instead.

Fixes #34495

Change-Id: I538244ceb75a80271a724304b993309482bd5b41
Reviewed-on: https://go-review.googlesource.com/c/go/+/375694
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>
2022-01-06 15:00:16 +00:00
Benny Siegert
f300fc2d2c runtime: crash on netbsd-arm64 when setcontext fails
Instead of exiting with status 16962 when we fail to call SYS_setcontext
in sigreturn, reference a null pointer and crash. Hopefully, this will
enable grabbing a core dump to debug.

Updates #42422

Change-Id: If02c14a0a37084351f3f00db3dc9766cb68ae4b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/375834
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
2022-01-06 14:02:44 +00:00
Ulrich Kunitz
b5bfaf410a doc: improve documentation for GOAMD64
The change clarifies in the release notes for go1.18 that the variable
is for compilation and references the microarchitecture description in
the Go Wiki,
https://golang.org/wiki/MinimumRequirements#amd64,
and references the same information in the output of go help
environment.

Fixes #50174

Change-Id: I6a7d5a06f48463a810c96cc9c76fe66113d5147c
Reviewed-on: https://go-review.googlesource.com/c/go/+/372194
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06 00:26:47 +00:00
Roland Shoemaker
2b39d86344 cmd/go: add fuzzing coverage test
Adds a test script for fuzzing coverage instrumentation.

Fixes #48654

Change-Id: Ieea7b4146bd5581baae869441cc1c652dd7485f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/375736
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-05 21:22:03 +00:00
Bryan C. Mills
88cafe0f58 net/http: skip TestClientTimeout_h{1,2} on windows/arm and windows/arm64
These tests are empirically flaky on the windows/arm and windows/arm64
builders, with a consistent (but rare) failure mode.

This change skips the test if that particular failure mode is
encountered on those platforms; the skip can be removed if and when
someone has the time to pin down the root cause.

For #43120

Change-Id: Ie3a9a06bf47e3a907c7b07441acc1494a4631135
Reviewed-on: https://go-review.googlesource.com/c/go/+/375635
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-05 21:11:50 +00:00
Clément Chigot
002283eaca runtime: ensure that asmsyscall6 follow AIX stack convention
The function asmsyscall6 must follow AIX stack layout. It means
that its first local variable must be stored after its arguments
area, ie after offset 112.

Fixes #50185

Change-Id: I897731ddd2a9faad8218443a4c2f4b204ad7e173
Reviewed-on: https://go-review.googlesource.com/c/go/+/373074
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-01-05 16:44:50 +00:00
fanzha02
2c58bb2e42 src/runtime: mark asanread and asanwrite functions as NOSPLIT
The asan runtime functions may run on stacks that cannot grow, and
they do not have large local variables, so it is safe to mark them
as NOSPLIT.

Add test case.

Fixes #50391

Change-Id: Iadcbf1ae0c837d9b64da5be208c7f424e6ba11de
Reviewed-on: https://go-review.googlesource.com/c/go/+/374398
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-01-05 09:50:29 +00:00
Jason A. Donenfeld
301db3f5d2 net: do not panic on nil IPNet.String()
The code looks like it was already trying to avoid this but missed a
spot.

Fixes #50271.

Change-Id: I450adac3f618b9535b61a28e6a160eacc351d47c
Reviewed-on: https://go-review.googlesource.com/c/go/+/373075
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-05 01:53:39 +00:00
Dan Scales
f154f8b5bb cmd/compile: save selector/inst info for generic method/function calls
In the dict info, we need to save the SelectorExpr of a generic method
call when making its sub-dictionary entry. The generic method call will
eventually be transformed into a function call on the method shape
instantiation, so we may not always have the selector info available
when we need it to create a dictionary. We use this SelectorExpr as
needed if the relevant call node has already been transformed.

Similarly, we save the InstExpr of generic function calls, since the
InstExpr will be dropped when the function call is transformed to a call
to a shape instantiation. We use this InstExpr if the relevant function
call has already been transformed.

Added an extra generic function Some2 and a call to it from Some that
exercises the generic function case. The existing test already tests the
method call case.

Fixes #50264

Change-Id: I2c7c7d79a8e33ca36a5e88e64e913c57500c97f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/373754
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-04 22:27:20 +00:00
Dan Scales
e39ab9b01c cmd/compile: pop instantiations of local types when leaving scope
Since we use existing instantiations from the symbol table when possible
(to make sure each instantiation is unique), we need to pop
instantiations of local types when leaving the containing scope.
g.stmts() now pushes and pops scope, and we do a Pushdcl() in g.typ0()
when creating an instantiation of a local type.

Non-instantiated local types (generic or not) are translated directly
from types2, so they don't need to be pushed/popped. We don't export
function bodies with local types, so there is no issue during import.

We still don't support local types in generic functions/methods.

Fixes #50177

Change-Id: If2d2fe71aec003d13f0338565c7a0da2c9580a14
Reviewed-on: https://go-review.googlesource.com/c/go/+/372654
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-04 22:05:15 +00:00
Ian Lance Taylor
1c8f9d2c97 doc/go1.18: mention new cmd/go fuzzing flags
For #47694

Change-Id: I00da9bd39700e938ec492daa71aba2035d911a06
Reviewed-on: https://go-review.googlesource.com/c/go/+/374354
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2022-01-04 21:10:15 +00:00
Jonathan Amsterdam
95b240b2cd go/doc: handle generic receiver strings
A receiver expression for a type with parameters may be an IndexExpr
or IndexListExpr in addition to an Ident or StarExpr. Add cases to
recvString to account for the new types.

Add tests that compare the fields of Func, and the fields of Type that
hold Funcs. These fields weren't previously tested.

Change-Id: Ia2cef51c85113422e0c5745c77dddcd53507ee51
Reviewed-on: https://go-review.googlesource.com/c/go/+/375095
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-03 23:45:12 +00:00
Jonathan Amsterdam
a893d0f464 go/doc: use subtests
Change the Test function to use sub-tests for each doc mode and
package.

This will allow more fine-grained test execution.

Change-Id: Ie3dda5791bda2781a60776886dd39fd18e670e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/375094
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-03 23:45:06 +00:00
Tobias Klauser
c8861432b8 os: simplify ios checks in tests
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Change tests to only use GOOS=ios to detect special cases for iOS and
stop treating darwin/arm64 as iOS.

Change-Id: I6a19f16fa9ec159ab1386aeb8fe912585e457171
Reviewed-on: https://go-review.googlesource.com/c/go/+/374399
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-02 14:27:43 +00:00
Tobias Klauser
d181885de8 os: enable TestMkdirAllWithSymlink on darwin/arm64
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

TestMkdirAllWithSymlink ought to run on darwin/arm64, so enable it on
that platform.

For #45696

Change-Id: I2cad6b1dfddf215e6b6cd262bbd22251f48f3d8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/373359
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2022-01-02 14:27:32 +00:00
Ian Lance Taylor
6178d25fc0 misc/cgo/testsanitizers: accept compilers that don't report location
It appears that GCC before version 10 doesn't report file/line
location for asan errors.

Change-Id: I03ee24180ba365636596aa2384961df7ce6ed71f
Reviewed-on: https://go-review.googlesource.com/c/go/+/374874
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-29 20:20:32 +00:00
Ian Lance Taylor
8a306e2056 misc/cgo/testsanitizers: don't fail asan test if no symbolizer
Change-Id: Ic05c641bda3cc8f5292921c9b0c0d3df34f3bc48
Reviewed-on: https://go-review.googlesource.com/c/go/+/374794
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-12-29 19:23:11 +00:00
fanzha02
91e782106e runtime: fix the issue that the -asan option cannot print where the error occurred
The current -asan option does not print where the error occurred. The
reason is that the current implementation calls incorrect asan runtime
functions, which do not pass sp and pc where asan runtime functions are
called, and report the stack trace from the native code. But asan runtime
functions are called from cgo on a separated stack, so it cannot dump the
Go stack trace correctly.

The correct asan runtime function we should call is __asan_report_error,
which will pass sp and pc, and report where the error occurred correctly.

This patch fixes this issue.

Add the test cases.

Fixes #50362

Change-Id: I12ee1d46c7ae069ddef3d23f2fe86e112db60045
Reviewed-on: https://go-review.googlesource.com/c/go/+/374395
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-29 04:10:07 +00:00
Meng Zhuo
a78532a412 runtime: invalid negative frequency while tracing
The riscv64 Hifive Unmatched is the only platform that
failed on testcase TestAnalyzeAnnotations occasionally
after CL 332954 had merged. The failure happens when
ticks per second (freq) is over 1e12 which causing the timestamps
of two events are same.

There are 2 reasons causing big frequency:
1. RDCYCLE is HART based according to the riscv manual which makes
   negative ticks delta
2. negative float64 -> uint64 is undefined and "lucky" negative float
   is too big to handle for trace

For #46737

Change-Id: I1f3c1ac31aae249969000c719c32aaf5a66d29a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/373034
Trust: Zhuo Meng <mzh@golangcn.org>
Run-TryBot: Zhuo Meng <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-12-29 01:44:55 +00:00
Ian Lance Taylor
b357b05b70 doc/go1.18: add section for runtime/debug changes
For #37475
For #47694

Change-Id: If8c1f1b756daf32648110f1a669b2ea60f797a24
Reviewed-on: https://go-review.googlesource.com/c/go/+/373875
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-23 20:03:38 +00:00
Ian Lance Taylor
0e4b878258 doc/go1.18: mention debug/plan9obj.ErrNoSymbols
For #47694
For #48052

Change-Id: I136be9b498033309d876099aae16bad330555416
Reviewed-on: https://go-review.googlesource.com/c/go/+/373774
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-23 19:58:13 +00:00
Cherry Mui
af3b8cf502 cmd/go: remove MallocNanoZone environment variable workaround
We added a workaround in runtime/race. This should not be
necessary now.

Updates #49138.

Change-Id: Ia2010e4acc95c4ddf5f463ab2919401d893c0bac
Reviewed-on: https://go-review.googlesource.com/c/go/+/374314
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-23 18:58:36 +00:00
zhangjian
ed766b6ffb cmd/compile/internal/ir: fix a typo in node.go
README.md -> HACKING.md

Change-Id: I63909b86b2e6f8d9a34622f5d2b05048c79cd698
GitHub-Last-Rev: afaab8f05e
GitHub-Pull-Request: golang/go#50326
Reviewed-on: https://go-review.googlesource.com/c/go/+/374274
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-23 17:27:50 +00:00
Carl Johnson
d2ce939604 doc/go1.18: fix broken HTML in net/http.MaxBytesHandler
For #47694

Sorry about that! I guess the autocompleter in VSCode auto-closed the paragraph and I didn't notice.

Change-Id: I1e834e47deb708cd5285d26201a442305f8c3b24
GitHub-Last-Rev: ab88731551
GitHub-Pull-Request: golang/go#50305
Reviewed-on: https://go-review.googlesource.com/c/go/+/374014
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-12-22 23:31:40 +00:00
Cherry Mui
8cfcee1fff runtime: handle stray profiling signal better
In c-archive mode, when we turn off profiling, we  restore the
previous handler for SIGPROF, and ignore SIGPROF signals if no
handler was installed. So if a pending signal lands after we
remove the Go signal handler, it will not kill the program.

In the current code there is a small window, where we can still
receive signals but we are set to not handling the signal. If a
signal lands in this window (possibly on another thread), it will
see that we are not handling this signal and no previous handler
installed, and kill the program. To avoid this race, we set the
previous handler to SIG_IGN (ignoring the signal) when turning on
profiling. So when turning off profiling we'll ignore the signal
even if a stray signal lands in the small window.

Fixes #43828.

Change-Id: I304bc85a93ca0e63b0c0d8e902b097bfdc8e3f1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/374074
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-22 20:47:09 +00:00
Ian Lance Taylor
0f3becf62f doc/go1.18: list new net/netip and net functions and methods
For #46518
For #47694

Change-Id: I4848556674baf85ceec350645d9eddcd83f1b2e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/373834
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-12-22 18:43:55 +00:00
Ian Lance Taylor
d7b035f930 doc/go1.18: mention testing.F in testing package section
For #47694

Change-Id: I27d88d864319bd8dbabfa6675a6abf2f74c50717
Reviewed-on: https://go-review.googlesource.com/c/go/+/373914
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
2021-12-22 18:38:41 +00:00
Ian Lance Taylor
90fb5a4f97 doc/go1.18: document {text,html}/template {break,continue} commands
For #20531
For #47694

Change-Id: Iaefaa0a8982eabf59cd6a53120c8af9124d60d1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/373915
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-22 00:11:21 +00:00
Carl Johnson
ebac50e9ce doc/go1.18: add net/http.MaxBytesHandler
For #47694

Change-Id: Ifab2c2720ec2ccef175a0e14a95f8df0437eb009
GitHub-Last-Rev: f3c2f12c7b
GitHub-Pull-Request: golang/go#50250
Reviewed-on: https://go-review.googlesource.com/c/go/+/373015
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-21 23:09:59 +00:00
Tobias Klauser
3fb17cfd17 os: enable TestPipeThreads on FreeBSD
This test works on FreeBSD since CL 165801 was submitted.

Updates #19093

Change-Id: I45ffeb403c1de4385cdb21b9647f21976061e1ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/373358
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-21 22:43:13 +00:00
Ian Lance Taylor
60f2c12a85 doc/go1.18: mention new go/types/Config.Context field
For #47694
For #47916

Change-Id: Ieeffaf161da744adfdb4da8aac58a64c109ebcab
Reviewed-on: https://go-review.googlesource.com/c/go/+/373775
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-12-21 22:26:48 +00:00