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

54570 Commits

Author SHA1 Message Date
Isaiah Becker-Mayer
b8d8c9e79f sync: clarify Cond.Wait documentation
The previous wording was unclear and seemingly contradictory.

Change-Id: I0781dc4525948f4e8e5698271362a82387688f81
GitHub-Last-Rev: c1e032fa94
GitHub-Pull-Request: golang/go#53516
Reviewed-on: https://go-review.googlesource.com/c/go/+/413774
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-26 21:58:42 +00:00
Than McIntosh
07bdf1dc54 runtime: add an exit hook facility
Add a new API (not public/exported) for registering a function with
the runtime that should be called when program execution terminates,
to be used in the new code coverage re-implementation. The API looks
like

  func addExitHook(f func(), runOnNonZeroExit bool)

The first argument is the function to be run, second argument controls
whether the function is invoked even if there is a call to os.Exit
with a non-zero status. Exit hooks are run in reverse order of
registration, e.g. the first hook to be registered will be the last to
run. Exit hook functions are not allowed to panic or to make calls to
os.Exit.

Updates #51430.

Change-Id: I906f8c5184b7c1666f05a62cfc7833bf1a4300c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/354790
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-26 21:49:14 +00:00
Than McIntosh
cf83a490e4 runtime: add hook to register coverage-instrumented packages
Add support to the runtime for registering coverage-instrumented
packages, using a new hook that can be called from the init function
of an instrumented package. The hook records the meta-data symbol for
the package (chaining it onto a list), and returns a package ID to be
used to identify functions in the package. This new hook is not yet
called; that will be added in a subsequent patch. The list of
registered meta-data objects will be used (again in a future patch) as
part of coverage data file writing.

Special handling is required for packages such as "runtime" or
"internal/cpu", where functions in the package execute before the
package "init" func runs. For these packages hard-code the package ID,
then record the position of the package in the overall list so that we
can fix things up later on.

Updates #51430.

Change-Id: I6ca3ddf535197442a2603c6d7a0a9798b8496f40
Reviewed-on: https://go-review.googlesource.com/c/go/+/401234
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-26 21:48:50 +00:00
Than McIntosh
efa3f1749f internal/coverage: add apis for reading/writing counter data
Add utilities for reading and writing of counter data files as part of
the new code coverage implementation.

Trivia note: currently the contents of counter data files are emitted
in little-endian form, which for the counters is somewhat painful in
that we need to visit each counter value and properly encode it. It
might be better to instead emit counters in native endianity and then
teach the tools to decode properly in the case of an endianity
mismatch.

Updates #51430.

Change-Id: I124fdcb40fc339a48b64b35264bf24c3be50ddd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/359403
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-26 21:48:18 +00:00
cuiweixie
63668a5155 reflect: create funcTypes using StructOf
follow the TODO to use StructOf, this cl can save the used memory.
for example, old code alloc [128]*rtype for func with 65 arguments(in+out),
this cl change to alloc [65]*rtype to save memory.

Change-Id: I1494bb6b3524d0d46869c3f24a628fec88119d8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/425314
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-26 21:39:25 +00:00
Robert Griesemer
22f4471599 go/types, types2: use "invalid recursive type" instead of "illegal cycle" in error messages
This matches long-standing compiler behavior.

For #55326.

Change-Id: Ic5aa0dfb08d035f2c33532cc463c73a55cc020a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/433055
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-26 21:33:48 +00:00
Robert Griesemer
4c5a6f9555 go/types, types2: provide error codes where they were missing
We need a better approach eventually, but this is ok for now.
In go/types, always use _UnsupportedFeature for unavailable
version-specific features.

Change-Id: I15b47e34eda167db3133bd481aa2f55cf3662c31
Reviewed-on: https://go-review.googlesource.com/c/go/+/433195
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-26 21:33:33 +00:00
Than McIntosh
84f95aa811 internal/coverage: add coverage meta-data decoder
Add a coverage meta-data decoder, which provides APIs for reading
encoded coverage meta-data and expanding it usable form. This package
is intended to be used in the coverage tooling that reads data files
emitted from coverage runs. Along with the new decoding package is a
unit test that runs the encode/decode paths together to check to make
sure that "decode(encode(X)) == X".

Updates #51430.

Change-Id: I81d27d8da0b2fcfa5039114a6e35a4b463d19b3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/353454
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26 20:52:13 +00:00
Than McIntosh
f951f697c4 internal/coverage: add coverage meta-data encoder
Add a new package with APIs for encoding coverage meta-data. This
provides support for accumulating information about each function
during the compilation process, and then encoding and emitting a
payload for a coverage meta-data symbol.  Not yet connected to the
rest of the coverage machinery (that will appear in a later patch).

Updates #51430.

Change-Id: I61054ce87f205b25fb1bfedaa740fd7425c34de4
Reviewed-on: https://go-review.googlesource.com/c/go/+/353453
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26 20:51:52 +00:00
Than McIntosh
a3434b71a3 cmd: add a new goexperiment for redesigned code coverage
Add a new "coverageredesign" GOEXPERIMENT (currently off by default),
for gating the use of the new code coverage design/implementation.

Updates #51430.

Change-Id: Ia61da869fcd0d61c6163f734e2fe5e3705f37a91
Reviewed-on: https://go-review.googlesource.com/c/go/+/395894
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-09-26 20:50:18 +00:00
cuiweixie
52f9c6fdb0 syscall: check if to is nil to prevent panic from WSASendto
to is an optional pointer to sockaddr, as written in the doc:
https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendto

For #55845

Change-Id: Ia685cec8d9bc9ff313f598db9d2213a1f409757a
Reviewed-on: https://go-review.googlesource.com/c/go/+/434535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-26 20:42:40 +00:00
Zeke Lu
4da2bc2eeb internal/saferio: handle potential total size overflow in SliceCap
Before the change, "SliceCap((*int64)(nil), 1<<62)" returns 1<<62.
That's because "uintptr(c)*size" overflows and gives 0 which is less
than the "chunk". SliceCap should return -1 in this case.

Change-Id: I4e99224c8ac0fc72032c6be86d7318d33d083cd8
GitHub-Last-Rev: ca30bcce45
GitHub-Pull-Request: golang/go#55870
Reviewed-on: https://go-review.googlesource.com/c/go/+/434335
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-09-26 20:36:02 +00:00
Bryan C. Mills
bd8a5b00fc os/exec: split parent I/O pipes by whether they are pumped by user code or internal goroutines
The pipes pumped by goroutines can be closed as soon as their
respective goroutines are done.

The pipes pumped by user code, however, are documented to be closed in
Wait. When we add the WaitDelay field, it isn't obvious that we should
terminate the user-pumped pipes when the WaitDelay expires, since Wait
itself isn't going to wait for those user-controlled goroutines to
complete.

(It's a bit more complicated than that because the documentation
currently states that Wait must not be called while the pipes are
being read — but it isn't obvious to me that that advice is entirely
correct.)

For #50436.

Change-Id: I97909c91d2097fb75138a360747168c08609696d
Reviewed-on: https://go-review.googlesource.com/c/go/+/401894
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-09-26 17:26:59 +00:00
Bryan C. Mills
b8d4a14a66 os/exec: clean up pipe-closing logic
Change the childFiles field to a local variable, since it was
populated during Start and (as far as I can determine) has no purpose
after Start returns.

Rename closeAfterStart and closeAfterWait to childIOFiles and
parentIOPipes respectively. That makes their contents clearer, and also
helps to clarify what should happen on error (when, for example, Wait
shouldn't be called at all).

Use a deferred call instead of individual calls to close child (and,
if necessary, pipe) FDs after Start. That helps to clarify the
invariants around when they are closed, and also makes the function a
bit more robust for future refactoring.

Also nil out the slices containing the file closers so that they can
be collected earlier.

This CL is intended as a pure refactor in preparation for #50436.

Change-Id: I05d13fa91d539b95b84b2ba923c1733f9a6203e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/401834
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-09-26 17:26:56 +00:00
Joel Sing
1163acf3ea internal/cpu: deduplicate arm64 ISAR parsing code
Deduplicate code for parsing system registers - this matches what is done
in golang.org/x/sys/cpu.

Change-Id: If3524eb2e361179c68678f8214230d7068fe4c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/422217
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26 16:42:53 +00:00
Joel Sing
95a5e20d8f internal/cpu: enable arm64 SHA512 detection for freebsd/openbsd
Change-Id: I1f21654b50d7b0cd8e1f854efe2724b72f067449
Reviewed-on: https://go-review.googlesource.com/c/go/+/422216
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-26 16:42:07 +00:00
cuiweixie
c3728b7502 reflect: simplify Value.Comparable
using Type.Comparable to simplify the Value.Comparable,
and return true directly when exit the for loop of kind == array and elements type is interface or array or struct.

Change-Id: Ib0b06a70642ba24c9215c69e7d619960fbeeed90
Reviewed-on: https://go-review.googlesource.com/c/go/+/426457
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
2022-09-26 16:36:07 +00:00
Tobias Klauser
deaec39323 cmd/go/internal/mmap: fix build for js/wasm
Even though there isn't much point in building cmd/go for js/wasm given
it relies on executing sub-processes, this change is trivial enough and
makes cmd/go build for js/wasm again.

Fixes #54219

Change-Id: I91e3adec0f31a4e261af89b4cc829711828ac2ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/433480
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-09-26 16:33:32 +00:00
Tobias Klauser
eab78849fc cmd/go/internal, go/build: remove unused errGoBuildWithoutBuild
Last use was removed by CL 240607.

Change-Id: Icfe9e477c6035823bd676a2ff28e1ac202dd991e
Reviewed-on: https://go-review.googlesource.com/c/go/+/431662
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-26 16:28:50 +00:00
Andy Pan
5036ed26bd syscall: check if to is nil to prevent panic from Sendto
Fixes #55845

Change-Id: If30263b7d34829c40e6606846115ec520f351f2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/433504
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26 14:30:17 +00:00
Than McIntosh
1e91ffc897 cmd/go: avoid internal errors on "go test -testwork"
Fix up the package test harness to avoid errors of the form

  go_test.go:NNN: internal testsuite error: path(".") with no tempdir

when the "-testwork" flag is passed when running "go test".

Fixes #55874.

Change-Id: I76cc39902f51a62cb4cd0da8794b97d620fb4873
Reviewed-on: https://go-review.googlesource.com/c/go/+/434455
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-26 14:16:42 +00:00
Ian Lance Taylor
a0441c7ae3 encoding/gob: use saferio.SliceCap when decoding a slice
This avoids allocating an overly large slice for corrupt input.

Change the saferio.SliceCap function to take a pointer to the element type,
so that we can handle slices of interface types. This revealed that a
couple of existing calls were actually incorrect, passing the slice type
rather than the element type.

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

Fixes #55338

Change-Id: I3c1724183cc275d4981379773b0b8faa01a9cbd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/433296
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-25 01:18:43 +00:00
cuiweixie
336ce966e4 cmd/compile: use "missing method m" instead of "missing m method"
For #55326

Change-Id: I3d0ff7f820f7b2009d1b226abf701b2337fe8cbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/432635
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-24 17:04:15 +00:00
Tobias Klauser
e5deb1556b Revert "net/netip: use slice-to-array conversions"
This reverts commit 3dcf6e2c29.

Reason for revert: breaks the longtest builders for x/tools

Change-Id: I6b6d5afbe46890b6a59829e3d5ab50d885661696
Reviewed-on: https://go-review.googlesource.com/c/go/+/433478
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-23 22:21:53 +00:00
Damien Neil
7c84234142 net/http/httputil: avoid query parameter smuggling
Query parameter smuggling occurs when a proxy's interpretation
of query parameters differs from that of a downstream server.
Change ReverseProxy to avoid forwarding ignored query parameters.

Remove unparsable query parameters from the outbound request

   * if req.Form != nil after calling ReverseProxy.Director; and
   * before calling ReverseProxy.Rewrite.

This change preserves the existing behavior of forwarding the
raw query untouched if a Director hook does not parse the query
by calling Request.ParseForm (possibly indirectly).

Fixes #54663
Fixes CVE-2022-2880

Change-Id: If1621f6b0e73a49d79059dae9e6b256e0ff18ca9
Reviewed-on: https://go-review.googlesource.com/c/go/+/432976
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-09-23 21:06:17 +00:00
Tobias Klauser
3dcf6e2c29 net/netip: use slice-to-array conversions
Use slice-to-array conversions in AddrFromSlice and
(*Addr).UnmarshalBinary. This allows allows to use AddrFrom16 and drop
the redundant ipv6Slice helper.

For #46505

Change-Id: I0e3a7d8825ad438115b7f23ee97cc74eec41a826
Reviewed-on: https://go-review.googlesource.com/c/go/+/432735
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-23 20:32:51 +00:00
Robert Griesemer
c58bfeeb04 cmd/compile: use "init... cycle" instead of "init... loop" in error messages
For #55326.

Change-Id: Ia3c1124305986dcd49ac769e700055b263cfbd59
Reviewed-on: https://go-review.googlesource.com/c/go/+/432615
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-23 20:27:09 +00:00
Robert Griesemer
5d213a3dc7 cmd/compile: handle go.mod error msg reference in noder, not type checker
Currently, for version errors, types2 adds the helpful hint

(-lang was set to go1.xx; check go.mod)

where 1.xx is the respective language version, to the error message.
This requires that the type checker knows that it was invoked by the
compiler, which is done through the Config.CompilerErrorMessages flag.

This change looks for version errors being returned by the type checker
and then adds the hint at that point, external to the type checker.
This removes a dependency on the Config.CompilerErrorMessages. Once
we have removed all dependencies on Config.CompilerErrorMessages we
can remove it.

For #55326.

Change-Id: I1f9b2e472c49fe785a2075e26c4b3d9b8fcdbf4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/432559
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-23 20:27:07 +00:00
Damien Neil
2f3008386f cmd: update vendored golang.org/x/tools for multiple error wrapping
Updates vet to permit errors with an Unwrap method returning []error
and multiple %w verbs in fmt.Errorf.

For #53435.

Change-Id: If097715f86c5a03ed606e6d4fb048e17b154b489
Reviewed-on: https://go-review.googlesource.com/c/go/+/433057
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2022-09-23 15:58:01 +00:00
Tobias Klauser
68fa3696b6 cmd/compile/internal/ir: add missing import to mknode.go
CL 426257 changed ioutil.WriteFile to os.WriteFile but didn't add the
corresponding import for package os.

Change-Id: I7be32138463b44aabc8e36ce353f6dc1376cbe60
Reviewed-on: https://go-review.googlesource.com/c/go/+/433415
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-23 15:14:20 +00:00
Cuong Manh Le
7ed6073da0 cmd/compile: update bottomUpVisitor.visit comments
Change-Id: I83a62b15c5946cfe61afc53c2c528aa3a62f815e
Reviewed-on: https://go-review.googlesource.com/c/go/+/429975
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-23 15:09:44 +00:00
Russ Cox
65deb9c3ce text/template/parse: fix confusion about markers near right delims
Fixes #52527.
Fixes #55336.

Change-Id: I8f5c521c693e74451a558788909e7e4ad1cc797a
Reviewed-on: https://go-review.googlesource.com/c/go/+/433036
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-23 15:03:43 +00:00
Joe Tsai
2551324cd0 path/filepath: optimize isReservedName
A linear search through a list of 22 strings takes ~80ns.
A quick check for 3-4 byte strings reduces this check to 2ns
for a vast majority of inputs.
In the event of a name match, the new logic is either just
as fast (for "CON") or 10x faster (for "LPT9").

Change-Id: I412fa73beebd7c81dc95f9ed12c35ca1d5d6baf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/433175
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-23 04:34:52 +00:00
Russ Cox
c2ede92a0d runtime/pprof: force use of 4-column profiles in pprof memprofile output
Pprof's converter from legacy text format to protobuf format
assumes that if the alloc and inuse stats are equal, then what's
really going on is that the program makes no distinction, and it
reads them as a two-column profile: objects and bytes.

Most of the time, some sampled object has been freed, and alloc != inuse.
In that case, pprof reads the profile as a four-column profile, with
alloc_objects, alloc_bytes, inuse_objects, inuse_bytes.

The 2-column form causes problems in a few ways. One is that if
you are reading the proto form and expect samples with the 4-column
names, they're not there. Another is that pprof's profile merger insists
on having the same number of columns and same names. This means
that

	pprof *.memprofile

works most of the time but fails if one of the memory profiles hit
the unlikely condition that alloc == inuse, since now its converted
form differs from the others.

Most programs should simply not be using this output form at all,
but cmd/compile and cmd/link still do, because x/tools/cmd/compilebench
reads some extra values from the text form that we have not yet added
to the proto form.

For the programs still writing this form, the easiest way to avoid the
column collapse issues is to ensure that the header never reports
alloc == inuse. The actual values in the header are ignored by pprof now,
except for the equality check (they should sum to the other values in the
file, so they are technically redundant). Because the actual values are not
used except for the equality check, we could hard-code different values
like 0 and 1, but just in case, to break as little as possible, this CL only
adjusts the values when they would otherwise be equal. In that case it
adds 1 to allocBytes. For most profiles, where alloc != inuse already, there
is no effect at all.

Change-Id: Ia563e402573d0f6eb81ae496645db27c08f9fe31
Reviewed-on: https://go-review.googlesource.com/c/go/+/432758
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-09-23 01:07:03 +00:00
Cherry Mui
ddaf68200a cmd/internal/objfile: read file/line information for ELF PIE binaries
For PIE binaries, the .gopclntab section doesn't have the usual
name, but .data.rel.ro.gopclntab. Try the relro version as well.
If both failed (e.g. for externally linked PIE binaries), try
runtime.pclntab symbol.

This should make cmd/objdump able to print the file/line
information for PIE binaries.

I attempted to do this a few years ago, but that wasn't enough,
because the pclntab itself contains dynamic relocations which are
not applied by the tool. As of Go 1.18 the pclntab is mostly
position independent and does not contain dynamic relocations, so
this should be possible now.

Fixes #17883.
Updates #46639.

Change-Id: I85dc3d50ffcc1a4b187a349479a6a162de1ab2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227483
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 23:46:28 +00:00
Cuong Manh Le
533cd80315 cmd/compile/internal/walk: remove reduceSlice
After CL 22425, there're two optimizations for slice expr which are
never applied during walk pass:

	s[i:len(s)]
        s[i:j:cap(s)]

The order pass have already rewritten len/cap expression to use autotmp,
thus the same safe expression check will never fire. The code can now be
simplified by moving the only case left from reduceSlice to walkSlice,
then removing reduceSlice entirely.

Passes toolstash-check.

Change-Id: Ia8cfb15c8e96c186a214c17b42d0fee51b0d3a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/432695
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 21:36:44 +00:00
Bryan C. Mills
42a46206b9 cmd/go: omit VCS stamping during bootstrap
cmd/dist can't easily hard-code -buildvcs=false because not all
versions of cmd/go supported for bootstrapping recognize that flag.

However, we don't want to stamp the bootstrap binaries: the stamping
is redundant with the VERSION file writted during bootstrapping (which
is why it is normally omitted for standard-library packages and
commands), and it may also interfere with building the Go repo from a
source tarball or zip file.

Fixes #54852.

Change-Id: If223f094af137c4c202d6bf622619bd2da397ec4
Reviewed-on: https://go-review.googlesource.com/c/go/+/432435
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 18:55:06 +00:00
Kevin Chen
88a6a4d1ba cmd/compile/internal/syntax: remove TypeList syntax in comment
Change-Id: Ic4df6a8e198b069a9f3a28710fa40f29bd658b06
GitHub-Last-Rev: 51040eb5e5
GitHub-Pull-Request: golang/go#55345
Reviewed-on: https://go-review.googlesource.com/c/go/+/432795
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-09-22 18:43:28 +00:00
cuiweixie
ebaa5ff39e crypto/tls: convert Conn.activeCall to atomic type
Change-Id: I5b063070a17bdeed57e73bfb76125b94268b3bc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/426088
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-09-22 18:24:49 +00:00
Damien Neil
d7df872267 all: tidy std module
Change-Id: I7350a608a198073673fb9b7e9b91dae6f1c861b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/432495
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2022-09-21 20:59:10 +00:00
Damien Neil
4412230503 net/http: add tracing to TestTransportReuseConnection_Gzip_*
These tests are flaky; add some additional logging in hopes
it will aid in debugging.

For #53373

Change-Id: I971a2815f50932a9700ef8c2f684c5416951e6de
Reviewed-on: https://go-review.googlesource.com/c/go/+/432375
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 15:39:17 +00:00
Damien Neil
e246cf626d net/http: accept HEAD requests with a body
RFC 7231 permits HEAD requests to contain a body, although it does
state there are no defined semantics for payloads of HEAD requests
and that some servers may reject HEAD requests with a payload.

Accept HEAD requests with a body.

Fix a bug where a HEAD request with a chunked body would interpret
the body as the headers for the next request on the connection.

For #53960.

Change-Id: I83f7112fdedabd6d6291cd956151d718ee6942cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/418614
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 15:30:20 +00:00
Damien Neil
493ebc3590 all: update vendored golang.org/x/net
Pull in HTTP/2 fix needed for net/http test case.

	f8f703f979 http2: accept HEAD requests with a body

For #53960

Change-Id: I59bbd83977daced5ed21ec5345af8cdb607e532e
Reviewed-on: https://go-review.googlesource.com/c/go/+/432197
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-21 15:07:53 +00:00
Shulhan
68370187fa math: show value of integer constants in comments
Fixes #51282

Change-Id: I5b0d68165b727a427bd4a42663b2fa0070ced22f
Reviewed-on: https://go-review.googlesource.com/c/go/+/343990
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 14:07:39 +00:00
Cuong Manh Le
334984a92a spec: describe an edge case for slice expression of nil slice
Change-Id: I8c0e2b37e7e8cb4db6ad0b456fde7eb908ffbd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/430836
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-21 14:06:17 +00:00
Cuong Manh Le
4b58b30778 spec: describe an edge case of slice-to-array conversions
Converting from nil slice to zero element array is ok, so explicitly
describe the behavior in the spec.

For #46505

Change-Id: I68f432deb6c21a7549bf7e870185fc62504b37f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/430835
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-21 14:06:15 +00:00
Charlie Vieth
c70fd4b30a bytes, strings: add ASCII fast path to EqualFold
This commit adds an ASCII fast path to bytes/strings EqualFold that
roughly doubles performance when all characters are ASCII.

It also changes strings.EqualFold to use `for range` for the first
string since this is ~10% faster than using utf8.DecodeRuneInString for
both (see #31666).

Performance (similar results on arm64 and amd64):

name                        old time/op  new time/op  delta
EqualFold/Tests-10           238ns ± 0%   172ns ± 1%  -27.91%  (p=0.000 n=10+10)
EqualFold/ASCII-10          20.5ns ± 0%   9.7ns ± 0%  -52.73%  (p=0.000 n=10+10)
EqualFold/UnicodePrefix-10  86.5ns ± 0%  77.6ns ± 0%  -10.37%  (p=0.000 n=10+10)
EqualFold/UnicodeSuffix-10  86.8ns ± 2%  71.3ns ± 0%  -17.88%  (p=0.000 n=10+8)

Change-Id: I058f3f97a08dc04d65af895674d85420f920abe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/425459
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-21 14:00:37 +00:00
Joe Tsai
9c916c7901 fmt: rely on utf8.AppendRune
This is both simpler and more performant.
The need for fmt.fmtC to manually check for utf8.MaxRune
is subtle to avoid overflow when converting uint64 to rune,
so a test case was added to exercise this edge case.

Change-Id: I0f2e6cce91dcd4cc6b88190c29807ca1c58e999d
Reviewed-on: https://go-review.googlesource.com/c/go/+/412335
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-21 13:54:31 +00:00
Ian Lance Taylor
d11c58eedb runtime: treat SI_TKILL like SI_USER on Linux
On Linux a signal sent using tgkill will have si_code == SI_TKILL,
not SI_USER. Treat the two cases the same. Add a Linux-specific test.

Change the test to use the C pause function rather than sleeping
for a second, as that achieves the same effect.

This is a roll forward of CL 431255 which was rolled back in CL 431715.
This new version skips flaky tests on more systems, and marks a new method
nosplit.

Change-Id: Ibf2d3e6fc43d63d0a71afa8fcca6a11fda03f291
Reviewed-on: https://go-review.googlesource.com/c/go/+/432136
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 01:56:24 +00:00
Keith Randall
fec83c8a7d Revert "cmd/compile: enable carry chain scheduling for arm64"
This reverts commit 4c414c7673.

Reason for revert: breaks ppc64 build (see issue 55254)

Change-Id: I096ffa0e6535d31d9dd4079b48bb201b20220d76
Reviewed-on: https://go-review.googlesource.com/c/go/+/432196
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-20 20:51:20 +00:00