]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Chressie Himpel [Wed, 27 Apr 2022 18:09:28 +0000 (20:09 +0200)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: Ic5f71c04f08c03319c043f35be501875adb0a3b0

2 years agocrypto/tls: remove tls10default GODEBUG flag
Filippo Valsorda [Tue, 19 Apr 2022 10:26:53 +0000 (06:26 -0400)]
crypto/tls: remove tls10default GODEBUG flag

Updates #45428

Change-Id: Ic2ff459e6a3f1e8ded2a770c11d34067c0b39a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/400974
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Auto-Submit: Filippo Valsorda <valsorda@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Filippo Valsorda <valsorda@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agocrypto/elliptic: split up P-256 field and group ops
Filippo Valsorda [Tue, 8 Mar 2022 10:11:17 +0000 (05:11 -0500)]
crypto/elliptic: split up P-256 field and group ops

This makes Gerrit recognize the rename of the field implementation and
facilitates the review. No code changes.

For #52182

Change-Id: I827004e175db1ae2fcdf17d0f586ff21503d27e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/390754
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/elliptic: inline marshaling into nistec pointFromAffine
Filippo Valsorda [Thu, 3 Feb 2022 17:57:25 +0000 (09:57 -0800)]
crypto/elliptic: inline marshaling into nistec pointFromAffine

Marshal behavior for invalid points is undefined, so don't use it to
check if points are valid.

For #52182

Change-Id: If167893bc4b029f71bb2528564f2bd96bee7221c
Reviewed-on: https://go-review.googlesource.com/c/go/+/382994
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agocrypto/elliptic: use generics for nistec-based curves
Filippo Valsorda [Sat, 30 Oct 2021 06:01:35 +0000 (02:01 -0400)]
crypto/elliptic: use generics for nistec-based curves

There was no way to use an interface because the methods on the Point
types return concrete Point values, as they should.

A couple somewhat minor annoyances:

    - Allocations went up due to #48849. This is fine here, where
      math/big causes allocations anyway, but would probably not be fine
      in nistec itself.

    - Carrying the newPoint/newGenerator functions around as a field is
      a little weird, even if type-safe. It also means we have to make
      what were functions methods so they can access newPoint to return
      the zero value. This is #35966.

For #52182

Change-Id: I050f3a27f15d3f189818da80da9de0cba0548931
Reviewed-on: https://go-review.googlesource.com/c/go/+/360015
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agocrypto/elliptic: refactor package structure
Filippo Valsorda [Sat, 30 Oct 2021 04:27:51 +0000 (00:27 -0400)]
crypto/elliptic: refactor package structure

Not quite golang.org/wiki/TargetSpecific compliant, but almost.

The only substantial code change is in randFieldElement: it used to use
Params().BitSize instead of Params().N.BitLen(), which is semantically
incorrect, even if the two values are the same for all named curves.

For #52182

Change-Id: Ibc47450552afe23ea74fcf55d1d799d5d7e5487c
Reviewed-on: https://go-review.googlesource.com/c/go/+/315273
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agotime: document hhmmss formats
cuiweixie [Tue, 26 Apr 2022 23:55:11 +0000 (23:55 +0000)]
time: document hhmmss formats

Fixes #52516

Change-Id: I173fdb09c245563e09be4e1aacfd374c3a764d74
GitHub-Last-Rev: 14a81e50616e0f268fee9323d0621de861885475
GitHub-Pull-Request: golang/go#52538
Reviewed-on: https://go-review.googlesource.com/c/go/+/402058
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: disable windowed Smhasher test on 32-bit systems
Keith Randall [Tue, 26 Apr 2022 23:32:07 +0000 (16:32 -0700)]
runtime: disable windowed Smhasher test on 32-bit systems

This test tends to be flaky on 32-bit systems.
There's not enough bits in the hash output, so we
expect a nontrivial number of collisions, and it is
often quite a bit higher than expected.

Fixes #43130

Change-Id: If35413b7c45eed778a08b834dacf98009ceca840
Reviewed-on: https://go-review.googlesource.com/c/go/+/402456
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agoruntime: refactor the scavenger and make it testable
Michael Anthony Knyszek [Thu, 10 Feb 2022 00:49:44 +0000 (00:49 +0000)]
runtime: refactor the scavenger and make it testable

This change refactors the scavenger into a type whose methods represent
the actual function and scheduling of the scavenger. It also stubs out
access to global state in order to make it testable.

This change thus also adds a test for the scavenger. In writing this
test, I discovered the lack of a behavior I expected: if the
pageAlloc.scavenge returns < the bytes requested scavenged, that means
the heap is exhausted. This has been true this whole time, but was not
documented or explicitly relied upon. This change rectifies that. In
theory this means the scavenger could spin in run() indefinitely (as
happened in the test) if shouldStop never told it to stop. In practice,
shouldStop fires long before the heap is exhausted, but for future
changes it may be important. At the very least it's good to be
intentional about these things.

While we're here, I also moved the call to stopTimer out of wake and
into sleep. There's no reason to add more operations to a context that's
already precarious (running without a P on sysmon).

Change-Id: Ib31b86379fd9df84f25ae282734437afc540da5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/384734
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: disable idle mark workers with at least one dedicated worker
Michael Anthony Knyszek [Thu, 24 Mar 2022 18:06:47 +0000 (18:06 +0000)]
runtime: disable idle mark workers with at least one dedicated worker

This change completes the proposal laid out in #44163. With #44313
resolved, we now ensure that stopped Ms are able to wake up and become
dedicated GC workers. As a result, idle GC workers are in theory no
longer required to be a proxy for scheduling dedicated mark workers.

And, with at least one dedicated mark worker running (which is
non-preemptible) we ensure the GC makes progress in all circumstances
when at least one is running. Currently we ensure at least one idle mark
worker is available at all times because it's possible before #44313
that a dedicated worker doesn't ever get scheduled, leading to a
deadlock if user goroutines block on a GC completing. But now that extra
idle mark worker should be unnecessary to ensure GC progress when at
least one dedicated mark worker is going to be scheduled.

Fixes #44163.

Change-Id: I62889ef2db4e69d44da883e8e6eebcfe5398c86d
Reviewed-on: https://go-review.googlesource.com/c/go/+/395634
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: move scheduling decisions by schedule into findrunnable
Michael Anthony Knyszek [Fri, 18 Mar 2022 23:59:12 +0000 (23:59 +0000)]
runtime: move scheduling decisions by schedule into findrunnable

This change moves several scheduling decisions made by schedule into
findrunnable. The main motivation behind this change is the fact that
stopped Ms can't become dedicated or fractional GC workers. The main
reason for this is that when a stopped M wakes up, it stays in
findrunnable until it finds work, which means it will never consider GC
work. On that note, it'll also never consider becoming the trace reader,
either.

Another way of looking at it is that this change tries to make
findrunnable aware of more sources of work than it was before. With this
change, any M in findrunnable should be capable of becoming a GC worker,
resolving #44313. While we're here, let's also make more sources of
work, such as the trace reader, visible to handoffp, which should really
be checking all sources of work. With that, we also now correctly handle
the case where StopTrace is called from the last live M that is also
locked (#39004). stoplockedm calls handoffp to start a new M and handle
the work it cannot, and once we include the trace reader in that, we
ensure that the trace reader gets scheduled.

This change attempts to preserve the exact same ordering of work
checking to reduce its impact.

One consequence of this change is that upon entering schedule, some
sources of work won't be checked twice (i.e. the local and global
runqs, and timers) as they do now, which in some sense gives them a
lower priority than they had before.

Fixes #39004.
Fixes #44313.

Change-Id: I5d8b7f63839db8d9a3e47cdda604baac1fe615ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/393880
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: reduce max idle mark workers during periodic GC cycles
Michael Anthony Knyszek [Wed, 16 Mar 2022 15:47:57 +0000 (15:47 +0000)]
runtime: reduce max idle mark workers during periodic GC cycles

This change reduces the maximum number of idle mark workers during
periodic (currently every 2 minutes) GC cycles to 1.

Idle mark workers soak up all available and unused Ps, up to GOMAXPROCS.
While this provides some throughput and latency benefit in general, it
can cause what appear to be massive CPU utilization spikes in otherwise
idle applications. This is mostly an issue for *very* idle applications,
ones idle enough to trigger periodic GC cycles. This spike also tends to
interact poorly with auto-scaling systems, as the system might assume
the load average is very low and suddenly see a massive burst in
activity.

The result of this change is not to bring down this 100% (of GOMAXPROCS)
CPU utilization spike to 0%, but rather

  min(25% + 1/GOMAXPROCS*100%, 100%)

Idle mark workers also do incur a small latency penalty as they must be
descheduled for other work that might pop up. Luckily the runtime is
pretty good about getting idle mark workers off of Ps, so in general
the latency benefit from shorter GC cycles outweighs this cost. But, the
cost is still non-zero and may be more significant in idle applications
that aren't invoking assists and write barriers quite as often.

We can't completely eliminate idle mark workers because they're
currently necessary for GC progress in some circumstances. Namely,
they're critical for progress when all we have is fractional workers. If
a fractional worker meets its quota, and all user goroutines are blocked
directly or indirectly on a GC cycle (via runtime.GOMAXPROCS, or
runtime.GC), the program may deadlock without GC workers, since the
fractional worker will go to sleep with nothing to wake it.

Fixes #37116.
For #44163.

Change-Id: Ib74793bb6b88d1765c52d445831310b0d11ef423
Reviewed-on: https://go-review.googlesource.com/c/go/+/393394
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: yield instead of sleeping in runqgrab on OpenBSD
Michael Anthony Knyszek [Thu, 21 Apr 2022 22:18:31 +0000 (22:18 +0000)]
runtime: yield instead of sleeping in runqgrab on OpenBSD

OpenBSD has a coarse sleep granularity that rounds up to 10 ms
increments. This can cause significant STW delays, among other issues.
As far as I can tell, there's only 1 tightly timed sleep without an
explicit wakeup for which this actually matters.

Fixes #52475.

Change-Id: Ic69fc11096ddbbafd79b2dcdf3f912fde242db24
Reviewed-on: https://go-review.googlesource.com/c/go/+/401638
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: make alloc count metrics truly monotonic
Michael Anthony Knyszek [Mon, 10 Jan 2022 22:59:26 +0000 (22:59 +0000)]
runtime: make alloc count metrics truly monotonic

Right now we export alloc count metrics via the runtime/metrics package
and mark them as monotonic, but that's not actually true. As an
optimization, the runtime assumes a span is always fully allocated
before being uncached, and updates the accounting as such. In the rare
case that it's wrong, the span has enough information to back out what
did not get allocated.

This change uses 16 bits of padding in the mspan to house another field
that represents the amount of mspan slots filled just as the mspan is
cached. This is information is enough to get an exact count, allowing us
to make the metrics truly monotonic.

Change-Id: Iaff3ca43f8745dc1bbb0232372423e014b89b920
Reviewed-on: https://go-review.googlesource.com/c/go/+/377516
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoSECURITY.md: replace golang.org with go.dev
Hana [Tue, 26 Apr 2022 14:38:11 +0000 (10:38 -0400)]
SECURITY.md: replace golang.org with go.dev

Change-Id: Ic0e882fc6666c9adcd5f2dffc96e201f3146fa0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/402180
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: use ABIInternal for most calls to sigtrampgo
Michael Pratt [Mon, 7 Mar 2022 22:52:53 +0000 (17:52 -0500)]
runtime: use ABIInternal for most calls to sigtrampgo

sigtramp on openbsd-arm64 is teetering on the edge of the nosplit stack
limit. Add more headroom by calling sigtrampgo using ABIInternal, which
eliminates a 48-byte ABI wrapper frame.

openbsd-amd64 has slightly more space, but is also close to the limit,
so convert it as well.

Other operating systems don't have it as bad, but many have nearly
identical implementations of sigtramp, so I have converted them as well.

I've omitted darwin-arm64 and solaris, as those are quite different and
would benefit from not needing ifdef for both cases.

For #51485.

Change-Id: I70512645d4208b346a59d5e5d03836a45833b1d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/390814
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agonet: skip TestDialCancel on darwin-arm64
Heschi Kreinick [Tue, 26 Apr 2022 16:34:35 +0000 (12:34 -0400)]
net: skip TestDialCancel on darwin-arm64

We're turning up Macs in a network environment that clashes with this
test. I don't think it's critical to get it working, so skip it.

For #49149.

Change-Id: I925e3ecc5356c4cefd208bdcff3d98021215d0b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/402181
Reviewed-by: Alex Rakoczy <alex@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoREADME.md: update wiki link
Hana [Tue, 26 Apr 2022 13:26:50 +0000 (09:26 -0400)]
README.md: update wiki link

Change-Id: I307c3524f2031e2a3e7ada6e86c73e278481de6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/402179
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agoos/exec: use a TestMain to avoid hijacking stdout for helper commands
Bryan C. Mills [Sat, 23 Apr 2022 03:33:16 +0000 (23:33 -0400)]
os/exec: use a TestMain to avoid hijacking stdout for helper commands

The previous implementation of helperCommand relied on running a
well-known Test function which implemented all known commands.

That not only added Skip noise in the test's output, but also (and
more importantly) meant that the commands could not write directly to
stdout in the usual way, since the testing package hijacks os.Stdout
for its own use.

The new implementation addresses the above issues, and also ensures
that all registered commands are actually used, reducing the risk of
an unused command sticking around after refactoring.

It also sets the subprocess environment variable directly in the test
process, instead of on each individual helper command's Env field,
allowing helper commands to be used without an explicit Env.

Updates #50599.
(Also for #50436.)

Change-Id: I189c7bed9a07cfe47a084b657b88575b1ee370b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/401934
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoos/exec: make skipStdinCopyError a function instead of a variable
Bryan C. Mills [Sat, 23 Apr 2022 02:00:16 +0000 (22:00 -0400)]
os/exec: make skipStdinCopyError a function instead of a variable

This makes clearer that skipStdinCopyError is always defined and never
overridden in tests.

Secondarily, it may also help reduce init-time work and allow the
linker and/or inliner to better optimize this package.

(Noticed while prototyping #50436.)

Change-Id: I4f3c1bc146384a98136a4039f82165ed106c14b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/401897
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agotime: fix quickcheck test to avoid wraparounds
Russ Cox [Mon, 25 Apr 2022 18:06:10 +0000 (14:06 -0400)]
time: fix quickcheck test to avoid wraparounds

When we call time.Unix(s, ns), the internal representation is
s + 62135596800,  where 62135596800 is the number of
seconds from Jan 1 1 to Jan 1 1970.

If quickcheck generates numbers too close to 2^63,
the addition can wraparound to make a very negative
internal 64-bit value. Wraparounds are not guarded
against, since they would not arise in any reasonable program,
so just avoid testing near them.

Fixes #52409.

Change-Id: Id466c8a34a49055ab26f2687a6b2b657cb64bed6
Reviewed-on: https://go-review.googlesource.com/c/go/+/402177
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile/internal/syntax: parser to accept ~x as unary expression
Robert Griesemer [Mon, 25 Apr 2022 23:26:10 +0000 (16:26 -0700)]
cmd/compile/internal/syntax: parser to accept ~x as unary expression

Accept ~x as ordinary unary expression in the parser but recognize
such expressions as invalid in the type checker.

This change opens the door to recognizing complex type constraint
literals such as `*E|~int` in `[P *E|~int]` and parse them correctly
instead of reporting a parse error because `P*E|~int` syntactically
looks like an incorrect array length expression (binary expression
where the RHS of | is an invalid unary expression ~int).

As a result, the parser is more forgiving with expressions but the
type checker will reject invalid uses as before.

We could pass extra information into the binary/unary expression
parse functions to prevent the use of ~ in invalid situations but
it doesn't seem worth the trouble. In fact it may be advantageous
to allow a more liberal expression syntax especially in the presence
of errors (better parser synchronization after an error).

Preparation for fixing #49482.

Change-Id: I119e8bd9445dfa6460fcd7e0658e3554a34b2769
Reviewed-on: https://go-review.googlesource.com/c/go/+/402255
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

2 years agocmd/compile: fix the missing size for FuncInfoSym
zhouguangyuan [Mon, 25 Apr 2022 08:36:01 +0000 (16:36 +0800)]
cmd/compile: fix the missing size for FuncInfoSym

Change-Id: I46543e188bf25384e529a9d5a3095033ac618bbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/402057
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agonet/http: add MaxBytesError
Carl Johnson [Mon, 28 Mar 2022 17:02:43 +0000 (17:02 +0000)]
net/http: add MaxBytesError

Fixes #30715

Change-Id: Ia3712d248b6dc86abef71ccea6e705a571933d53
GitHub-Last-Rev: 6ae68402a5a7c57f7f18e945d48c69ba2b134078
GitHub-Pull-Request: golang/go#49359
Reviewed-on: https://go-review.googlesource.com/c/go/+/361397
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoreflect: support Len and Cap on pointer-to-array Value
cuiweixie [Mon, 25 Apr 2022 05:21:35 +0000 (05:21 +0000)]
reflect: support Len and Cap on pointer-to-array Value

Fixes #52411

Change-Id: I2fd13a453622992c52d49aade7cd058cfc8a77ca
GitHub-Last-Rev: d5987c2ec817ebd01d9e1adb3bd2e75274dbbabd
GitHub-Pull-Request: golang/go#52423
Reviewed-on: https://go-review.googlesource.com/c/go/+/400954
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agoos: skip TestRemoveAllRace on dragonfly
Bryan C. Mills [Mon, 25 Apr 2022 15:14:48 +0000 (11:14 -0400)]
os: skip TestRemoveAllRace on dragonfly

This test occasionally fails on the dragonfly-amd64 builder with
"directory not empty". Since that is the only platform on which we
observe these failures, and since the test had a different (and also
invalid-looking) failure mode prior to this one (in #50716), we
suspect that it is due to either a bug in the platform or a
platform-specific Go bug.

For #52301.

Change-Id: Id36c499651b9c48e6b8b0107d01f73d2a7b6bab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/402155
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoos/exec: in TestImplicitPWD, explicitly request the logical path
Bryan C. Mills [Mon, 25 Apr 2022 14:23:45 +0000 (10:23 -0400)]
os/exec: in TestImplicitPWD, explicitly request the logical path

Fixes #52537

Change-Id: I70959881a31f425e940e7adf86b36be2596aafb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/402158
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoslices: use !{{Less}} instead of {{GreaterOrEqual}}
张云浩 [Fri, 15 Apr 2022 07:45:17 +0000 (07:45 +0000)]
slices: use !{{Less}} instead of {{GreaterOrEqual}}

In CL 371574 PatchSet 18, we replaced all !{{Less}} with {{GreaterOrEqual}} to fix a problem(handle NaNs when sorting float64 slice) in exp/slices.

We don't actually need this change, because we don't guarantee that the slice will be sorted eventually if there are NaNs(we could have a[i] < a[j] for some i,j with i>j).

This CL reverts all the replacements in exp/slices and does not affect any codes in the sort package.

Change-Id: Idc225d480de3e2efef2add35c709ed880d1306cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/400534
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>

2 years agocmd/dist: add maymorestack tests
Austin Clements [Fri, 5 Nov 2021 01:06:06 +0000 (21:06 -0400)]
cmd/dist: add maymorestack tests

These tests run the runtime, reflect, and sync package tests with the
two maymorestack hooks we have.

These tests only run on the longtest builders (or with
GO_TEST_SHORT=false) because we're running the runtime test two
additional times and the mayMoreStackMove hook makes it about twice as
slow (~230 seconds).

To run just these tests by hand, do

  GO_TEST_SHORT=false go tool dist test -run mayMoreStack

Updates #48297.

This detected #49354, which was found as a flake on the dashboard, but
was reliably reproducible with these tests; and #49395.

Change-Id: If785a8b8d6e1b9ad4d2ae67493b54055ab6cbc85
Reviewed-on: https://go-review.googlesource.com/c/go/+/361212
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: fix stack-move sensitivity in some tests
Austin Clements [Mon, 25 Apr 2022 16:25:59 +0000 (12:25 -0400)]
runtime: fix stack-move sensitivity in some tests

There are a few tests of the scheduler run queue API that allocate a
local []g and test using those G's. However, the run queue API
frequently converts between *g and guintptr, which is safe for "real"
Gs because they're heap-allocated and hence don't move, but if these
tests get a stack movement while holding one of these local *g's as a
guintptr, it won't get updated and the test will fail.

Updates #48297.

Change-Id: Ifd424147ce1a1b53732ff0cf55a81df1a9beeb3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/402157
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/compile: align table
Park Zhou [Fri, 11 Feb 2022 06:55:36 +0000 (14:55 +0800)]
cmd/compile: align table

Signed-off-by: Park Zhou <buildpaas@gmail.com>
Change-Id: Idbbd2779264a7310b839af8291315e5e38b7ced9
Reviewed-on: https://go-review.googlesource.com/c/go/+/402120
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agodebug/pe: fix off by one error in valid symbol index test
Than McIntosh [Mon, 25 Apr 2022 15:22:10 +0000 (11:22 -0400)]
debug/pe: fix off by one error in valid symbol index test

Fix an off-by-one error in COFFSymbolReadSectionDefAux, specifically
the code that tests whether a symbol index is valid.

Fixes #52525.

Change-Id: I1b6e5dacfd99249c694bef5ae606e90fdb2ef521
Reviewed-on: https://go-review.googlesource.com/c/go/+/402156
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto/ed25519: test fixup
Than McIntosh [Mon, 25 Apr 2022 14:27:34 +0000 (10:27 -0400)]
crypto/ed25519: test fixup

Fix up TestEd25519Vectors to download files into its own temporary mod
cache, as opposed relying on whatever GOPATH or GOMODCACHE setting is
in effect when the test is run.

Change-Id: I523f1862f5874b0635a6c0fa83d35a6cfac6073b
Reviewed-on: https://go-review.googlesource.com/c/go/+/402154
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: add loong64 to gcArchSizes
Robert Findley [Fri, 22 Apr 2022 15:47:11 +0000 (11:47 -0400)]
go/types, types2: add loong64 to gcArchSizes

Values are taken from cmd/internal/sys/arch.go. Also fix some incorrect
alphabetical sorting to put arm > amd.

Updates #46229
Fixes #52495

Change-Id: If7d2c675238093692060358003915f1649792cf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/401576
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
2 years agoruntime: add ABIInternal to strhash and memhash on riscv64
Meng Zhuo [Sun, 7 Nov 2021 13:37:25 +0000 (21:37 +0800)]
runtime: add ABIInternal to strhash and memhash on riscv64

This CL fixes regression of strhash and memhash on riscv64

Change-Id: Icc10431a8199c8b1eb7b440cb42be4e53420e171
Reviewed-on: https://go-review.googlesource.com/c/go/+/362134
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agoos: use a lower file count for TestOpenFileLimit on openbsd
Joel Sing [Thu, 21 Apr 2022 17:30:42 +0000 (03:30 +1000)]
os: use a lower file count for TestOpenFileLimit on openbsd

OpenBSD has a default soft limit of 512 and hard limit of 1024 - as such,
attempting to open 1200 files is always going to fail unless the defaults
have been changed. On this platform use 768 instead such that it passes
without requiring customisation.

Fixes #51713

Change-Id: I7679c8fd73d4b263145129e9308afdb29d67bb54
Reviewed-on: https://go-review.googlesource.com/c/go/+/401594
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: 谢致邦 <xiezhibang@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
2 years agoruntime: support for debugger function calls on linux/arm64
eric fang [Tue, 22 Mar 2022 07:04:35 +0000 (07:04 +0000)]
runtime: support for debugger function calls on linux/arm64

This CL adds support for debugger function calls on linux arm64
platform. The protocol is basically the same as in CL 109699, except for
the following differences:
1, The abi difference which affect parameter passing and frame layout.
2, Stores communication information in R20.
3, The closure register is R26.
4, Use BRK 0 instruction to generate a breakpoint. The saved PC in
sigcontext is the PC where the signal occurred, not the next PC.

In addition, this CL refactors the existing code (which is dedicated to
amd64) for easier multi-arch scaling.

Fixes #50614

Change-Id: I06b14e345cc89aab175f4a5f2287b765da85a86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/395754
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/race: add s390x .syso file
Keith Randall [Fri, 22 Apr 2022 00:04:34 +0000 (17:04 -0700)]
runtime/race: add s390x .syso file

Built using racebuild.

Note that racebuild fails when trying to test the .syso, because the
Go runtime doesn't think we support s390x race yet. But it builds the
.syso as a side effect which I grabbed. There's something of a
chicken-and-egg bootstrapping problem here, unfortunately.

Change-Id: Ibc6d04fd3a9bfb3224d08e8b78dcf09bb139a59d
Reviewed-on: https://go-review.googlesource.com/c/go/+/401714
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jonathan Albrecht <jonathan.albrecht@ibm.com>
2 years agoregexp/syntax: rename ErrInvalidDepth to ErrNestingDepth
Ian Lance Taylor [Fri, 22 Apr 2022 21:41:57 +0000 (14:41 -0700)]
regexp/syntax: rename ErrInvalidDepth to ErrNestingDepth

The proposal accepted the name ErrNestingDepth.

For #51684

Change-Id: I702365f19e5e1889dbcc3c971eecff68e0b08727
Reviewed-on: https://go-review.googlesource.com/c/go/+/401854
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agonet: eliminate a deadlock on the failure path in TestNotTemporaryRead
Bryan C. Mills [Fri, 22 Apr 2022 14:39:04 +0000 (10:39 -0400)]
net: eliminate a deadlock on the failure path in TestNotTemporaryRead

This fixes a deadlock-on-failure that I probably introduced in
CL 385314.

This doesn't explain why the failure observed in #52492 occurred, but
it will at least give us more information to diagnose the failure if
it happens again. (The deadlock currently prevents the t.Fatal log
message from being written to the test's output.)

Fixes #52492.

Change-Id: I9e7874985e2820a6a4b703abe4f8e2035d5138c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/401575
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years ago[dev.boringcrypto] misc/boring: skip long tests during build.release
Heschi Kreinick [Wed, 20 Apr 2022 19:48:57 +0000 (15:48 -0400)]
[dev.boringcrypto] misc/boring: skip long tests during build.release

In CL 397477 I merged long tests into the built-in cmd/release flow.
Skip them during the boringcrypto release for now; we've never run them
before.

For #51797.

Change-Id: I8d5caa945a2558cd3a311a90be5bfb62ae7b0ace
Reviewed-on: https://go-review.googlesource.com/c/go/+/401338
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/internal/syscall: use ABIInternal for Syscall6 on amd64
Michael Pratt [Tue, 19 Apr 2022 20:27:57 +0000 (16:27 -0400)]
runtime/internal/syscall: use ABIInternal for Syscall6 on amd64

This is an exact copy of CL 401096 after fixing #52472 in CL 401654.

For #51087
For #52472

Change-Id: Ib3c914949a15517aacdca2d72e69e1c7b217e430
Reviewed-on: https://go-review.googlesource.com/c/go/+/401656
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agosyscall: define Syscall6 in terms of RawSyscall6 on linux
Michael Pratt [Thu, 24 Feb 2022 22:00:12 +0000 (17:00 -0500)]
syscall: define Syscall6 in terms of RawSyscall6 on linux

This is an exact copy of CL 388478 after fixing #52472 in CL 401654.

For #51087
For #52472

Change-Id: I6c6bd7ddcab1512c682e6b44f61c7bcde97f5c58
Reviewed-on: https://go-review.googlesource.com/c/go/+/401655
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: skip TestNoShrinkStackWhileParking on openbsd
Dmitri Shuralyov [Wed, 20 Apr 2022 16:46:17 +0000 (12:46 -0400)]
runtime: skip TestNoShrinkStackWhileParking on openbsd

The test has proven to be flaky on OpenBSD since March, and there
hasn't been progress on resolving this finding. Mark the test as
flaky to so that this problem doesn't block the Go 1.19 release.

Updates #51482.

Change-Id: I92ad7498c20cfa94565880363bec85f9a4f3e916
Reviewed-on: https://go-review.googlesource.com/c/go/+/401335
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agogo/types: use error_.errorf for reporting related error information
Robert Findley [Mon, 18 Apr 2022 22:14:51 +0000 (18:14 -0400)]
go/types: use error_.errorf for reporting related error information

Use error_.errorf for reporting related error information rather than
inlining the "\n\t". This aligns go/types with types2 in cases where the
related information has no position information. In other cases,
go/types needs to report a "continuation error" (starting with '\t') so
that users can access multiple error positions.

Change-Id: Ica98466596c374e0c1e502e7227c8d8c803b4c22
Reviewed-on: https://go-review.googlesource.com/c/go/+/400825
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agogo/types: introduce the error_ type to match types2
Robert Findley [Mon, 18 Apr 2022 21:54:40 +0000 (17:54 -0400)]
go/types: introduce the error_ type to match types2

To begin aligning with types2 error reporting, use an error_ type to
hold unevaluated error information, to report via Checker.report.

Change-Id: Ic5ac515759961e55b81acc9eeaac4db25b61804c
Reviewed-on: https://go-review.googlesource.com/c/go/+/400824
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agogo/types: remove unnecessary indirection when reporting errors
Robert Findley [Mon, 18 Apr 2022 20:47:42 +0000 (16:47 -0400)]
go/types: remove unnecessary indirection when reporting errors

Checker.err was only called to report errors created with
Checker.newError or Checker.newErrorf. Update the API to pass around
*Error rather than error, eliminating unnecessary type assertions and
handling.

Change-Id: I995a120c7e87266e656b8ff3fd9ed3d368fd17fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/400823
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agoRevert "cmd/compile: enable Asan check for global variables"
Bryan Mills [Fri, 22 Apr 2022 13:24:41 +0000 (13:24 +0000)]
Revert "cmd/compile: enable Asan check for global variables"

This reverts CL 321715.

Reason for revert: broke cmd/go.TestScript/install_msan_and_race_require_cgo on several builders.

Change-Id: Ia0392de555d6e973960769a0e4709f0193d16706
Reviewed-on: https://go-review.googlesource.com/c/go/+/401755
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agoRevert "net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9"
Bryan Mills [Fri, 22 Apr 2022 13:20:48 +0000 (13:20 +0000)]
Revert "net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9"

This reverts CL 400654.

Reason for revert: broke net.TestGoLookupIP on the darwin-amd64-nocgo builder.

Updates #33097.

Change-Id: Idaf94eda88c9d4401e667a4d31c00ce376d91909
Reviewed-on: https://go-review.googlesource.com/c/go/+/401754
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/bytealg: optimize cmpbody for ppc64le/ppc64
Archana R [Wed, 10 Nov 2021 07:18:42 +0000 (01:18 -0600)]
internal/bytealg: optimize cmpbody for ppc64le/ppc64

Vectorize the cmpbody loop for bytes of size greater than or equal
to 32 on both POWER8(LE and BE) and POWER9(LE and BE) and improve
performance of smaller size compares

Performance improves for most sizes with this change on POWER8, 9
and POWER10. For the very small sizes (upto 8) the overhead of
calling function starts to impact performance.

POWER9:
name               old time/op  new time/op  delta
BytesCompare/1     4.60ns ± 0%  5.49ns ± 0%  +19.27%
BytesCompare/2     4.68ns ± 0%  5.46ns ± 0%  +16.71%
BytesCompare/4     6.58ns ± 0%  5.49ns ± 0%  -16.58%
BytesCompare/8     4.89ns ± 0%  5.46ns ± 0%  +11.64%
BytesCompare/16    5.21ns ± 0%  4.96ns ± 0%   -4.70%
BytesCompare/32    5.09ns ± 0%  4.98ns ± 0%   -2.14%
BytesCompare/64    6.40ns ± 0%  5.96ns ± 0%   -6.84%
BytesCompare/128   11.3ns ± 0%   8.1ns ± 0%  -28.09%
BytesCompare/256   15.1ns ± 0%  12.8ns ± 0%  -15.16%
BytesCompare/512   26.5ns ± 0%  23.3ns ± 5%  -12.03%
BytesCompare/1024  50.2ns ± 0%  41.6ns ± 2%  -17.01%
BytesCompare/2048  99.3ns ± 0%  86.5ns ± 0%  -12.88%

Change-Id: I24f93b2910591e6829ddd8509aa6eeaa6355c609
Reviewed-on: https://go-review.googlesource.com/c/go/+/362797
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agocmd/compile: enable Asan check for global variables
fanzha02 [Thu, 29 Apr 2021 09:02:53 +0000 (17:02 +0800)]
cmd/compile: enable Asan check for global variables

With this patch, -asan option can detect the error memory
access to global variables.

So this patch makes a few changes:

1. Add the asanregisterglobals runtime support function,
which calls asan runtime function _asan_register_globals
to register global variables.

2. Create a new initialization function for the package
being compiled. This function initializes an array of
instrumented global variables and pass it to function
runtime.asanregisterglobals. An instrumented global
variable has trailing redzone.

3. Writes the new size of instrumented global variables
that have trailing redzones into object file.

4. Notice that the current implementation is only compatible with
the ASan library from version v7 to v9. Therefore, using the
-asan option requires that the gcc version is not less than 7
and the clang version is less than 4, otherwise a segmentation
fault will occur. So this patch adds a check on whether the compiler
being used is a supported version in cmd/go.

Change-Id: I664e74dcabf5dc7ed46802859174606454e8f1d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/321715
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agointernal/bytealg: port bytealg functions to reg ABI on riscv64
Meng Zhuo [Wed, 30 Mar 2022 10:19:48 +0000 (18:19 +0800)]
internal/bytealg: port bytealg functions to reg ABI on riscv64

This CL adds support for the reg ABI to the bytes functions for
riscv64. These are initially under control of the
GOEXPERIMENT macro until all changes are in.

Change-Id: I026295ae38e2aba055f7a51c77f92c1921e5ec97
Reviewed-on: https://go-review.googlesource.com/c/go/+/361916
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime/cgo: remove stdlib.h warning workaround on darwin
Bryan C. Mills [Thu, 2 Dec 2021 14:39:22 +0000 (09:39 -0500)]
runtime/cgo: remove stdlib.h warning workaround on darwin

CL 205457 added the flag -Wno-nullability-completeness to work
around a user-reported build breakage on macOS Catalina.

However, according to
https://golang.org/issue/35247#issuecomment-589115489 the root cause
of the breakage may be a toolchain misconfiguration on the host
(perhaps compiling the XCode stdlib using a Homebrew build of the
"clang" compiler?).

Adding an obscure warning flag to enable building stdlib.h with an
otherwise-broken toolchain seems clearly inappropriate to me.
If need be we can instead provide guidance to users on how to unbreak
their toolchain.

Updates #35247
Fixes #49913

Change-Id: I84def34e101bed7911d8d78a991a29095b8791fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/368634
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/netip: fix Addr.Unmap reference in Addr.Is4 godoc comment
Tobias Klauser [Wed, 20 Apr 2022 22:00:38 +0000 (00:00 +0200)]
net/netip: fix Addr.Unmap reference in Addr.Is4 godoc comment

In CL 339309 this was probably copied from the respective godoc comment
in package inet.af/netaddr, also see
https://pkg.go.dev/inet.af/netaddr#IP.Is4

In net/netip the type is named Addr, so adjust the godoc comment
accordingly.

Change-Id: Ib5ab8054067f8b74119efa4732192a8407189f9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/401394
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agoregexp: change ErrInvalidDepth message to match proposal
Ian Lance Taylor [Tue, 19 Apr 2022 17:32:54 +0000 (10:32 -0700)]
regexp: change ErrInvalidDepth message to match proposal

Also update the file in $GOROOT/api/next to use proposal number.

For #51684

Change-Id: I28bfa6bc1cee98a17b13da196d41cda34d968bb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/401076
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agonet: permit use of Resolver.PreferGo, netgo on Windows and Plan 9
Brad Fitzpatrick [Sat, 16 Apr 2022 14:59:23 +0000 (07:59 -0700)]
net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9

Fixes #33097

Change-Id: I2e55c7c113683814521f2068e0922b63c62ea5d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/400654
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoreflect: make more Value methods inlineable
Joe Tsai [Sun, 17 Apr 2022 02:01:48 +0000 (19:01 -0700)]
reflect: make more Value methods inlineable

The following Value methods are now inlineable:

    Bool  for ~bool
    String for ~string (but not other kinds)
    Bytes for []byte (but not ~[]byte or ~[N]byte)
    Len   for ~[]T (but not ~[N]T, ~chan T, ~map[K]V, or ~string)
    Cap   for ~[]T (but not ~[N]T or ~chan T)

For Bytes, we only have enough inline budget to inline one type,
so we optimize for unnamed []byte, which is far more common than
named []byte or [N]byte.

For Len and Cap, we only have enough inline budget to inline one kind,
so we optimize for ~[]T, which is more common than the others.
The exception is string, but the size of a string can be obtained
through len(v.String()).

Performance:

Bool        1.65ns ± 0%  0.51ns ± 3%  -68.81%  (p=0.008 n=5+5)
String      1.97ns ± 1%  0.70ns ± 1%  -64.25%  (p=0.008 n=5+5)
Bytes       8.90ns ± 2%  0.89ns ± 1%  -89.95%  (p=0.008 n=5+5)
NamedBytes  8.89ns ± 1%  8.88ns ± 1%     ~     (p=0.548 n=5+5)
BytesArray  10.0ns ± 2%  10.2ns ± 1%   +1.58%  (p=0.048 n=5+5)
SliceLen    1.97ns ± 1%  0.45ns ± 1%  -77.22%  (p=0.008 n=5+5)
MapLen      2.62ns ± 1%  3.07ns ± 1%  +17.24%  (p=0.008 n=5+5)
StringLen   1.96ns ± 1%  1.98ns ± 2%     ~     (p=0.151 n=5+5)
ArrayLen    1.96ns ± 1%  2.19ns ± 1%  +11.46%  (p=0.008 n=5+5)
SliceCap    1.76ns ± 1%  0.45ns ± 2%  -74.28%  (p=0.008 n=5+5)

There's a slight slowdown (~10-20%) for obtaining the length
of a string or map, but a substantial improvement for slices.

Performance according to encoding/json:

CodeMarshal          555µs ± 2%   562µs ± 4%     ~     (p=0.421 n=5+5)
MarshalBytes/32      163ns ± 1%   157ns ± 1%   -3.82%  (p=0.008 n=5+5)
MarshalBytes/256     453ns ± 1%   447ns ± 1%     ~     (p=0.056 n=5+5)
MarshalBytes/4096   4.10µs ± 1%  4.09µs ± 0%     ~     (p=1.000 n=5+4)
CodeUnmarshal       3.16ms ± 2%  3.02ms ± 1%   -4.18%  (p=0.008 n=5+5)
CodeUnmarshalReuse  2.64ms ± 3%  2.51ms ± 2%   -4.81%  (p=0.016 n=5+5)
UnmarshalString     65.4ns ± 4%  64.1ns ± 0%     ~     (p=0.190 n=5+4)
UnmarshalFloat64    59.8ns ± 5%  58.9ns ± 2%     ~     (p=0.222 n=5+5)
UnmarshalInt64      51.7ns ± 1%  50.0ns ± 2%   -3.26%  (p=0.008 n=5+5)
EncodeMarshaler     23.6ns ±11%  20.8ns ± 1%  -12.10%  (p=0.016 n=5+4)

Add all inlineable methods of Value to cmd/compile/internal/test/inl_test.go.

Change-Id: Ifc192491918af6b62f7fe3a094a5a5256bfb326d
Reviewed-on: https://go-review.googlesource.com/c/go/+/400676
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agocmd/compile: Unify & improve struct comparisons
Derek Parker [Thu, 21 Apr 2022 23:26:16 +0000 (23:26 +0000)]
cmd/compile: Unify & improve struct comparisons

Partially fixes https://github.com/golang/go/issues/38674

The first commit has the actual unification, the second commit just cleans things up by moving shared code into its own package for clarity.

Change-Id: I85067f8b247df02f94684ec1297a1a42263bba0c
GitHub-Last-Rev: 370a4ecad315f945b62195f8daddca693345a0c7
GitHub-Pull-Request: golang/go#52315
Reviewed-on: https://go-review.googlesource.com/c/go/+/399542
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agotest/typeparam: fix copyright message
mkontani [Sun, 17 Apr 2022 15:17:08 +0000 (15:17 +0000)]
test/typeparam: fix copyright message

Change-Id: Ia0a4be56d4e1fbfc73e6ce24f01a658c89a74adb
GitHub-Last-Rev: dd95e50c4b37a031d3ee852bbb7487f748526562
GitHub-Pull-Request: golang/go#52393
Reviewed-on: https://go-review.googlesource.com/c/go/+/400694
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agobufio: implement large write forwarding in Writer.WriteString
Carlo Alberto Ferraris [Fri, 21 Jan 2022 05:21:38 +0000 (14:21 +0900)]
bufio: implement large write forwarding in Writer.WriteString

Currently bufio.Writer implements forwarding to the underlying Writer
for large writes via Write, but it does not do the same for large
writes via WriteString.

If the underlying Writer is also a StringWriter, use the same "large
writes" logic also in WriteString while taking care to only check
once per call to WriteString whether the underlying Writer implements
StringWriter.

Change-Id: Id81901c07b035936816b9e41b1f5688e699ee8e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/380074
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agoreflect: in assignTo only allocate target if needed
Ian Lance Taylor [Sun, 17 Apr 2022 01:28:29 +0000 (18:28 -0700)]
reflect: in assignTo only allocate target if needed

Also correct parameter name in comment.

Change-Id: Ic9486e08c2eea184faccf181cda7da808793def6
Reviewed-on: https://go-review.googlesource.com/c/go/+/400674
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agosyscall: define Syscall in terms of RawSyscall on linux
Michael Pratt [Thu, 24 Feb 2022 21:54:13 +0000 (16:54 -0500)]
syscall: define Syscall in terms of RawSyscall on linux

This is a re-do of CL 388477, fixing #52472.

It is unsafe to call syscall.RawSyscall from syscall.Syscall with
-coverpkg=all and -race. This is because:

1. Coverage adds a sync/atomic call in RawSyscall to increment the
   coverage counter.
2. Race mode instruments sync/atomic calls with TSAN runtime calls. TSAN
   eventually calls runtime.racecallbackfunc, which expects
   getg().m.p != 0, which is no longer true after entersyscall().

cmd/go actually avoids adding coverage instrumention to package runtime
in race mode entirely to avoid these kinds of problems. Rather than also
excluding all of syscall for this one function, work around by calling
RawSyscall6 instead, which avoids coverage instrumention both by being
written in assembly and in package runtime/*.

For #51087
Fixes #52472

Change-Id: Iaffd27df03753020c4716059a455d6ca7b62f347
Reviewed-on: https://go-review.googlesource.com/c/go/+/401654
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/trace: embed static content
Michael Pratt [Wed, 12 Jan 2022 23:27:28 +0000 (18:27 -0500)]
cmd/trace: embed static content

cmd/trace is currently somewhat painful to use in odd environments since
it depends on the presence of $GOROOT/misc/trace to serve the static
trace viewer content.

Use //go:embed to embed this content directly into cmd/trace for easier
use.

Change-Id: I83b7d97dbecc9773f3b5a6b3bc4a6597473bc01a
Reviewed-on: https://go-review.googlesource.com/c/go/+/378194
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/format: skip go/ast's object resolution
Daniel Martí [Thu, 21 Apr 2022 13:06:20 +0000 (14:06 +0100)]
go/format: skip go/ast's object resolution

Just like https://golang.org/cl/401454 removed the work from gofmt for a
nice ~5% speed-up in the default case, we can also use the option in the
equivalent go/format for programs which use it rather than gofmt,
as go/format makes no use of objects either.

No benchmark numbers as we already measured the ~5% speed-up with gofmt
in the other CL linked above.

See #46485.

Change-Id: Icbf98e6d46a616081314e2faa13f1dfade3bbaef
Reviewed-on: https://go-review.googlesource.com/c/go/+/401474
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/gofmt: only resolve go/ast objects when needed
Daniel Martí [Thu, 21 Apr 2022 13:00:26 +0000 (14:00 +0100)]
cmd/gofmt: only resolve go/ast objects when needed

go/parser will by default resolve objects as per the go/ast.Object type,
which is then used by gofmt's rewrite and simplify flags.
However, none of that is needed if neither of the flags is set,
so we can avoid the work entirely for a nice speed-up.

benchcmd -n 8 GofmtSrcCmd gofmt -l ~/tip/src/cmd

name         old time/op         new time/op         delta
GofmtSrcCmd          957ms ± 7%          908ms ± 7%  -5.12%  (p=0.028 n=8+8)

name         old user-time/op    new user-time/op    delta
GofmtSrcCmd          11.2s ± 1%          10.4s ± 1%  -7.23%  (p=0.001 n=7+7)

name         old sys-time/op     new sys-time/op     delta
GofmtSrcCmd          325ms ±29%          286ms ±22%    ~     (p=0.065 n=8+8)

name         old peak-RSS-bytes  new peak-RSS-bytes  delta
GofmtSrcCmd          295MB ±17%          276MB ±15%    ~     (p=0.328 n=8+8)

See #46485.

Change-Id: Iad1ae294953710c233f7837d7eb02e23d11c6185
Reviewed-on: https://go-review.googlesource.com/c/go/+/401454
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocrypto/x509: revert serial length restriction
Roland Shoemaker [Thu, 21 Apr 2022 20:47:26 +0000 (13:47 -0700)]
crypto/x509: revert serial length restriction

This reverts CL400377, which restricted serials passed to
x509.CreateCertificate to <= 20 octets. Unfortunately this turns out to
be something _a lot_ of people get wrong. Since it's not particularly
obvious how to properly generate conformant serials, until we provide
an easier way for people to get this right, reverting this restriction
makes sense (possible solution discussed in #52444.)

Change-Id: Ia85a0ffe61e2e547abdaf1389c3e1ad29e28a2be
Reviewed-on: https://go-review.googlesource.com/c/go/+/401657
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agoRevert "syscall: define Syscall in terms of RawSyscall on linux"
Michael Pratt [Thu, 21 Apr 2022 18:50:45 +0000 (14:50 -0400)]
Revert "syscall: define Syscall in terms of RawSyscall on linux"

This reverts CL 388477, which breaks cmd/go
TestScript/cover_pkgall_runtime.

For #51087.
For #52472.

Change-Id: Id58af419a889281f15df2471c58fece011fcffbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/401636
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoRevert "syscall: define Syscall6 in terms of RawSyscall6 on linux"
Michael Pratt [Thu, 21 Apr 2022 18:49:54 +0000 (14:49 -0400)]
Revert "syscall: define Syscall6 in terms of RawSyscall6 on linux"

This reverts CL 388478. Parent CL 388477 breaks cmd/go
TestScript/cover_pkgall_runtime.

For #51087.
For #52472.

Change-Id: Id5d5a4e138792cf130ecdcc6b996c8102d142a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/401635
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoRevert "runtime/internal/syscall: use ABIInternal for Syscall6 on amd64"
Michael Pratt [Thu, 21 Apr 2022 18:48:58 +0000 (14:48 -0400)]
Revert "runtime/internal/syscall: use ABIInternal for Syscall6 on amd64"

This reverts CL 401096. Grandparent CL 388477 breaks cmd/go
TestScript/cover_pkgall_runtime.

For #51087.
For #52472.

Change-Id: Ie82fe5f50975f66eb91fb0d01cd8bbbd0265eb4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/401634
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agomisc/cgo/test: remove timing dependency from TestParallelSleep
Ian Lance Taylor [Wed, 13 Apr 2022 21:35:15 +0000 (14:35 -0700)]
misc/cgo/test: remove timing dependency from TestParallelSleep

Rename it TestIssue1560 since it no longer sleeps.

For #1560
Fixes #45586

Change-Id: I338eee9de43e871da142143943e9435218438e90
Reviewed-on: https://go-review.googlesource.com/c/go/+/400194
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: add a better error message when in a module outside workspace
Michael Matloob [Tue, 12 Apr 2022 19:17:18 +0000 (15:17 -0400)]
cmd/go: add a better error message when in a module outside workspace

When the user is trying to list or build a package in a module that's
outside of the workspace provide a more clear message hinting to the
user that they can add the module to the workspace using go work use.

Fixes #51604

Change-Id: I1202ecb2f22fd6351bfdec88ed613b8167687fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/400014
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/internal/syscall: use ABIInternal for Syscall6 on amd64
Michael Pratt [Tue, 19 Apr 2022 20:27:57 +0000 (16:27 -0400)]
runtime/internal/syscall: use ABIInternal for Syscall6 on amd64

For #51087.

Change-Id: I25971760b63ec0d23d0f011521dd197d81a38976
Reviewed-on: https://go-review.googlesource.com/c/go/+/401096
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: define Syscall6 in terms of RawSyscall6 on linux
Michael Pratt [Thu, 24 Feb 2022 22:00:12 +0000 (17:00 -0500)]
syscall: define Syscall6 in terms of RawSyscall6 on linux

For #51087

Change-Id: I4a5b5cb74f12db8999c6ff0e98c3034b58af3959
Reviewed-on: https://go-review.googlesource.com/c/go/+/388478
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: define Syscall in terms of RawSyscall on linux
Michael Pratt [Thu, 24 Feb 2022 21:54:13 +0000 (16:54 -0500)]
syscall: define Syscall in terms of RawSyscall on linux

For #51087

Change-Id: I9de7e85ccf137ae73662759382334bcbe7208150
Reviewed-on: https://go-review.googlesource.com/c/go/+/388477
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: define RawSyscall in terms of RawSyscall6 on linux
Michael Pratt [Thu, 24 Feb 2022 21:46:54 +0000 (16:46 -0500)]
syscall: define RawSyscall in terms of RawSyscall6 on linux

For #51087

Change-Id: I63e07638507328efe33dbf7dd5f8a8b78890e037
Reviewed-on: https://go-review.googlesource.com/c/go/+/388476
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/internal/syscall, syscall: replace RawSyscall6 with runtime implementation...
Michael Pratt [Thu, 24 Feb 2022 21:35:06 +0000 (16:35 -0500)]
runtime/internal/syscall, syscall: replace RawSyscall6 with runtime implementation on linux

For #51087

Change-Id: I75a1bdeb5089454595f5ca04765a9c6e45cf9bd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/388475
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: move Syscall declarations to OS files
Michael Pratt [Mon, 28 Feb 2022 18:41:33 +0000 (13:41 -0500)]
syscall: move Syscall declarations to OS files

Future CLs will be changing the provenance of these functions. Move the
declarations to the individual OS files now so that future CLs can
change only 1 OS at a time rather than changing all at once.

For #51087

Change-Id: I5e1bca71e670263d8c0faa586c1b6b4de1a114b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388474
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: add //go:uintptrkeepalive
Michael Pratt [Fri, 25 Feb 2022 19:21:25 +0000 (14:21 -0500)]
cmd/compile: add //go:uintptrkeepalive

This CL exports the existing ir.UintptrKeepAlive via the new directive
//go:uintptrkeepalive. This makes the compiler insert KeepAlives for
pointers converted to uintptr in calls, keeping them alive for the
duration of the call.

//go:uintptrkeepalive requires //go:nosplit, as stack growth can't
handle these arguments (it cannot know which are pointers). We currently
check this on the immediate function, but the actual restriction applies
to all transitive calls.

The existing //go:uintptrescapes is an extension of
//go:uintptrkeepalive which forces pointers to escape to the heap, thus
eliminating the stack growth issue.

This pragma is limited to the standard library.

For #51087

Change-Id: If9a19d484d3561b4219e5539b70c11a3cc09391e
Reviewed-on: https://go-review.googlesource.com/c/go/+/388095
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agotest: rename live_syscall.go to live_uintptrkeepalive.go
Michael Pratt [Fri, 25 Feb 2022 19:31:32 +0000 (14:31 -0500)]
test: rename live_syscall.go to live_uintptrkeepalive.go

CL 388095 will change this file significantly. Move it preemptively to
ensure git tracks the move properly.

For #51087

Change-Id: I1408aecf8675723041b64e54cf44cdec38cc655c
Reviewed-on: https://go-review.googlesource.com/c/go/+/388094
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/build: replace a call to os.Environ with (*exec.Cmd).Environ
Bryan C. Mills [Thu, 21 Apr 2022 15:19:56 +0000 (11:19 -0400)]
go/build: replace a call to os.Environ with (*exec.Cmd).Environ

This is a code simplification using the new API added in #50599.

Change-Id: Icb9628bcd0daa3dc2d653e9654b38099730137d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/401535
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/go: replace some calls to base.AppendPWD with cmd.Environ
Bryan C. Mills [Thu, 21 Apr 2022 15:17:16 +0000 (11:17 -0400)]
cmd/go: replace some calls to base.AppendPWD with cmd.Environ

With #50599 implemented, base.AppendPWD is redundant if cmd.Env would
otherwise be nil, and calls to os.Environ followed by base.AppendPWD
can be replaced by a simpler call to cmd.Environ.

Updates #50599.

Change-Id: I94a22e2a4cc8e83c815ac41702ea0b1ee5034ecc
Reviewed-on: https://go-review.googlesource.com/c/go/+/401534
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet: use fastrand64 in randInt
zhangyunhao [Tue, 19 Apr 2022 06:20:29 +0000 (14:20 +0800)]
net: use fastrand64 in randInt

Change-Id: If3d8391d81e8de869dbb3c857f0570817e8aa440
Reviewed-on: https://go-review.googlesource.com/c/go/+/400914
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: use fastrand64 in mapiterinit
zhangyunhao [Tue, 19 Apr 2022 08:38:04 +0000 (16:38 +0800)]
runtime: use fastrand64 in mapiterinit

Change-Id: I5698c7576a0f39ae62de7bea64286ac8e578d421
Reviewed-on: https://go-review.googlesource.com/c/go/+/400916
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agohash/maphash: use fastrand64 in MakeSeed
zhangyunhao [Tue, 19 Apr 2022 06:44:03 +0000 (14:44 +0800)]
hash/maphash: use fastrand64 in MakeSeed

Change-Id: I5ccbcea4c53658136b25ca608faec19eeec2e908
Reviewed-on: https://go-review.googlesource.com/c/go/+/400915
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos/exec: set PWD implicitly if Dir is non-empty and Env is nil
Bryan C. Mills [Wed, 20 Apr 2022 21:07:14 +0000 (17:07 -0400)]
os/exec: set PWD implicitly if Dir is non-empty and Env is nil

Fixes #50599.

Change-Id: I4e5dbb3972cdf21ede049567bfb98f2c992c5849
Reviewed-on: https://go-review.googlesource.com/c/go/+/401340
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoRevert "cmd/go/internal/test: wrap os.Stdout always"
Bryan Mills [Thu, 21 Apr 2022 13:22:59 +0000 (13:22 +0000)]
Revert "cmd/go/internal/test: wrap os.Stdout always"

This reverts CL 400877.

Reason for revert: broke TestScript/test_output_wait and the
regression test for #18153 on certain builders.

Fixes #52461.

Change-Id: I98627ce5e22088b0784be502c459480c41ba353a
Reviewed-on: https://go-review.googlesource.com/c/go/+/401494
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agocrypto/x509: use SAN when comparing certs during path building
Roland Shoemaker [Tue, 19 Apr 2022 19:05:10 +0000 (12:05 -0700)]
crypto/x509: use SAN when comparing certs during path building

Per RFC 4158 Section 2.4.2, when we are discarding candidate
certificates during path building, use the SANs as well as subject and
public key when checking whether a certificate is already present in
the built path. This supports the case where a certificate in the chain
(typically a leaf) has the exact same subject and public key as another
certificate in the chain (typically its parent) but has SANs which don't
match.

Change-Id: I212c234e94a1f6afbe9691e4a3ba257461db3a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/401115
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocrypto/tls: reject duplicate extensions
Roland Shoemaker [Thu, 10 Feb 2022 17:47:49 +0000 (09:47 -0800)]
crypto/tls: reject duplicate extensions

Does what it says on the tin.

Fixes #51088

Change-Id: I12c0fa6bba1c1ce96c1ad31ba387c77a93f801c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/384894
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Chressie Himpel [Thu, 21 Apr 2022 15:30:08 +0000 (17:30 +0200)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: I30dbbe508a6252d50b4154cb9a8299cf0a054449

2 years agoos/exec: preserve original order of entries in dedupEnv
Bryan C. Mills [Tue, 19 Apr 2022 19:54:50 +0000 (15:54 -0400)]
os/exec: preserve original order of entries in dedupEnv

Once #50599 is implemented, the entries will be observable via the
Environ method. I find it confusing for later entries in the list to
jump arbitrarily far forward based on entries for the same key that no
longer exist.

This also fixes the deduplication logic for the degenerate Windows
keys observed in #49886, which were previously deduplicated as empty
keys.

(It does not do anything about the even-more-degenerate keys observed
in #52436.)

For #50599.

Change-Id: Ia7cd2200ec34ccc4b9d18631cb513194dc420c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/401339
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go/internal/test: wrap os.Stdout always
Andrew Gerrand [Tue, 19 Apr 2022 05:11:37 +0000 (15:11 +1000)]
cmd/go/internal/test: wrap os.Stdout always

There is an issue where 'go test' will hang after the tests complete if
a test starts a sub-process that does not exit (see #24050).

However, go test only exhibits that behavior when a package name is
explicitly passed as an argument. If 'go test' is invoked without any
package arguments then the package in the working directory is assumed,
however in that case (and only that case) os.Stdout is used as the test
process's cmd.Stdout, which does *not* cause 'go test' wait for the
sub-process to exit (see #23019).

This change wraps os.Stdout in an io.Writer struct in this case, hiding
the *os.File from the os/exec package, causing cmd.Wait to always wait
for the full output from the test process and any of its sub-processes.

In other words, this makes 'go test' exhibit the same behavior as
'go test .' (or 'go test ./...' and so on).

Update #23019
Update #24050

Change-Id: Ica09bf156f3b017f9a31aad91ed0f16a7837195b
Reviewed-on: https://go-review.googlesource.com/c/go/+/400877
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Andrew Gerrand <adg@golang.org>
Auto-Submit: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: add fastrand64
zhangyunhao [Mon, 18 Apr 2022 07:23:20 +0000 (15:23 +0800)]
runtime: add fastrand64

Support fastrand64 in the runtime, although fastrand uses wyrand to generate 64-bit random number, it still returns uint32. In some cases, we need to generate a 64-bit random number, the new API would be faster and easier to use, and at least we can use the new function in these places:

src/net/dnsclient.go:randInt()
src/hash/maphash/maphash.go:MakeSeed()
src/runtime/map.go:mapiterinit()

name                 time/op
Fastrand-16          0.09ns ± 5%
Fastrand64-16        0.09ns ± 6%

Change-Id: Ibb97378c7ca59bc7dc15535d4872fa58ea112e6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/400734
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoreflect: remove unused overflowPad variable
Phil Kulin [Wed, 20 Apr 2022 14:13:29 +0000 (14:13 +0000)]
reflect: remove unused overflowPad variable

overflowPad variable in bucketOf function is a holdover from a NaCl port
and never used now.

Change-Id: Ib68fdb054e1b6a655ffbfd34521a3f8773a22694
GitHub-Last-Rev: f281be9c115a87605fd28b39c0b09eed54cc774a
GitHub-Pull-Request: golang/go#52449
Reviewed-on: https://go-review.googlesource.com/c/go/+/401274
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet/http: drop mimesniff for audio/basic
Sean Liao [Mon, 18 Apr 2022 10:02:26 +0000 (11:02 +0100)]
net/http: drop mimesniff for audio/basic

The WHATWG Mime Sniffing Standard we follow dropped support for
.snd / audio/basic.
https://github.com/whatwg/mimesniff/issues/151

Change-Id: Iae1bd8b29063b06b5b3909a944e12ead5974a526
Reviewed-on: https://go-review.googlesource.com/c/go/+/400754
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocmd/compile/internal/syntax: correct an error string
Robert Griesemer [Wed, 20 Apr 2022 19:05:30 +0000 (12:05 -0700)]
cmd/compile/internal/syntax: correct an error string

When we have an error in a function type used in an expression
we don't know until we see an opening { whether we have a function
literal or a function type. Use "function type" as context because
that's always correct in the specific error message.

Change-Id: I9aad8fcddf31ae53daa53cebd2c2001f08eabde0
Reviewed-on: https://go-review.googlesource.com/c/go/+/401316
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agocmd/go: don't compute Deps fields if they're not needed
Michael Matloob [Mon, 14 Mar 2022 17:00:03 +0000 (13:00 -0400)]
cmd/go: don't compute Deps fields if they're not needed

If the user provides the -json flag to explicitly specify fields, but
doesn't specify the Deps or DepsErrors fields, skip computing the deps
fields.

For #29666

Change-Id: I15596c374aba1af13bdf5808d11d54abdc838667
Reviewed-on: https://go-review.googlesource.com/c/go/+/392495
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/link: fix StackCheckOutput on AIX
Austin Clements [Wed, 20 Apr 2022 16:24:09 +0000 (12:24 -0400)]
cmd/link: fix StackCheckOutput on AIX

This test forces GOARCH to amd64, but currently uses the default GOOS.
This works on every OS that supports amd64, which is every OS we
support except AIX. Hence, on AIX this fails with an unsupported
GOOS/GOARCH combination.

Fix this by forcing GOOS to linux.

Fixes #52451.

Change-Id: I9321dd6386c7ef0fe2b47d77ed900aafc53f2a46
Reviewed-on: https://go-review.googlesource.com/c/go/+/401334
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http: deflake TestTransportConnectionCloseOnRequest
Brad Fitzpatrick [Wed, 20 Apr 2022 15:58:42 +0000 (08:58 -0700)]
net/http: deflake TestTransportConnectionCloseOnRequest

Fixes #52450 (hopefully)

Change-Id: Ib723f8efb4a13af1b98c25cd02935425172d01e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/401314
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agocrypto/rand: apply the same max read size on Illumos as on Solaris
Bryan C. Mills [Wed, 20 Apr 2022 15:17:59 +0000 (11:17 -0400)]
crypto/rand: apply the same max read size on Illumos as on Solaris

This case was missed in CL 370894, and masked by the lack of an
Illumos TryBot.

Fixes #52452.

Change-Id: I7cda193e33c11a9d04eb888fdb5ec9218e6ed1b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/401294
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
2 years agogo/internal/srcimporter: add context to cgo errors
Bryan C. Mills [Mon, 18 Apr 2022 17:12:43 +0000 (13:12 -0400)]
go/internal/srcimporter: add context to cgo errors

An error message like "could not import os/user (exit status 1)"
(observed in https://go.dev/issue/52407) is fairly inscrutable.

On the other hand, srcimporter doesn't report errors with quite enough
structure to dump the entire stderr output from 'go tool cgo' without
potentially overwhelming the caller. Here, we split the difference by
describing which command failed but not printing the output of that
command.

For #52407, that would at least provide a stronger clue connecting
to #52408.

Change-Id: Iabdc95b17ba20a0f6ff38e5c7084e5081e1ef5e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/400817
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>