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

52447 Commits

Author SHA1 Message Date
Russ Cox
ae3d890202 go/doc/comment: parse and print identifiers, automatic links
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing and printing of unmarked identifiers
and automatic URL links in plain text.

For #51082.

Change-Id: Ib83ad482937501a6fc14fa788eab289533a68e3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/397280
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 16:31:41 +00:00
Russ Cox
6130b88130 go/doc/comment: add Printer and basic comment printing
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement printing of plain text doc paragraphs.

For #51082.


Change-Id: Ieff0af64a900f566bfc833c3b5706488f1444798
Reviewed-on: https://go-review.googlesource.com/c/go/+/397279
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 16:31:40 +00:00
Russ Cox
98b17892a0 go/doc/comment: add paragraph parsing and test framework
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement parsing of plain text doc paragraphs,
as well as a txtar-based test framework. Subsequent CLs will
implement the rest of the possible markup.

For #51082.

Change-Id: I449aac69b44089f241fde8050ac134e17cb25116
Reviewed-on: https://go-review.googlesource.com/c/go/+/397278
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 16:31:37 +00:00
Russ Cox
7575811c2b go/doc/comment: add low-level parsing helpers
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement helpers to recognize old-style headings,
plain text (not marked up) URLs, and Go identifiers.

For #51082.

Change-Id: Ibabce72ef3ffd79a9d33366091f8c76ef27d0182
Reviewed-on: https://go-review.googlesource.com/c/go/+/397277
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 16:31:36 +00:00
Russ Cox
494b79f39a go/doc/comment: add data structures
[This CL is part of a sequence implementing the proposal #51082.
The design doc is at https://go.dev/s/godocfmt-design.]

Implement just the data structures of the new API for
parsing and printing doc comments, as well as a syntax tree
form for inspecting and manipulating them.

The API itself was discussed and accepted as part of the
proposal process in #51082.

For #51082.

Change-Id: Iae7fbc85705964585273b970c5c62e394feb1288
Reviewed-on: https://go-review.googlesource.com/c/go/+/397276
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11 16:31:33 +00:00
Wayne Zuo
32de2b0d1c cmd/compile: add MOVBE index load/store
Fixes #51724

Change-Id: I94e650a7482dc4c479d597f0162a6a89d779708d
Reviewed-on: https://go-review.googlesource.com/c/go/+/395474
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-11 15:41:56 +00:00
Wayne Zuo
615d3c3040 test: adjust load and store test
In the load tests, we only want to test the assembly produced by
the load operations. If we use the global variable sink, it will produce
one load operation and one store operation(assign to sink).

For example:

func load_be64(b []byte) uint64 {
	sink64 = binary.BigEndian.Uint64(b)
}

If we compile this function with GOAMD64=v3, it may produce MOVBEQload
and MOVQstore or MOVQload and MOVBEQstore, but we only want MOVBEQload.
Discovered when developing CL 395474.

Same for the store tests.

Change-Id: I65c3c742f1eff657c3a0d2dd103f51140ae8079e
Reviewed-on: https://go-review.googlesource.com/c/go/+/397875
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-11 15:41:04 +00:00
Keith Randall
a6f6932b3e cmd/asm: fix MOVK when constant has high bit set
Fixes #52261

Change-Id: I1dc4c19c95a91f9e1e99d1e74afeb69f5bf8a979
Reviewed-on: https://go-review.googlesource.com/c/go/+/399455
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2022-04-11 02:55:52 +00:00
Meng Zhuo
b6fb3af6af archive/zip: fail fast if UncompressedSize64 < nread
The zip reader checks that the uncompressed file size is valid
after all compressed files read until EOF.
However in between reading each file, there could have already
been an overflow where nread > UncompressedSize64 hence this
change will now return ErrFormat in such situations.

Fixes #49791

Change-Id: If3584a57d173de6a97bf35c07d2a99ff6972f820
Reviewed-on: https://go-review.googlesource.com/c/go/+/366854
Trust: mzh <mzh@golangcn.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2022-04-11 01:24:31 +00:00
Leonard Wang
a10f158d6f runtime: update description of GODEBUG=gctrace=1
For #44167.

Change-Id: I2dcd13cbe74e88de00e9fc51f9bd86e604a167df
Reviewed-on: https://go-review.googlesource.com/c/go/+/399300
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-10 16:04:13 +00:00
cia-rana
8cd6aacf81 runtime: fix URL in a comment
For various reasons Intel has suspended viewing web pages in the .ru
domain, so change the domain of the documents cited in the code
to the .com domain. In addition, the chapter numbers in the document
were updated and fix it.

Change-Id: I718be1548ec46f05ebc4f73873d4635c1d5fc76d
Reviewed-on: https://go-review.googlesource.com/c/go/+/399060
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2022-04-10 15:52:08 +00:00
Ian Lance Taylor
db7183ccf9 go/build: remove unused fileInfo.embedErr field
Change-Id: If86a0402dae32c57d07545ee6d818010e0e4b5ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/399255
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-04-09 00:07:58 +00:00
Paul E. Murphy
0f0c892430 crypto/aes: merge ppc64le crypt key expansion
It is not necessary to expand the key twice for each direction,
the decrypt key can be stored in reverse simultaneously.

Likewise, there is no need to store the key length alongside the
expanded keys, this is now inferred by the key length slice.
Noteably, the key expansion benchmark assumes the key array size
is the exact size of the expanded key.

Now, the ppc64le aes asm interface is identical to the generic
asm interface. Callsites and usage is updated to reflect this.

Performance uplift on POWER9 is substantial:

name    old time/op  new time/op  delta
Expand   167ns ± 0%    49ns ± 0%  -70.55%

Change-Id: I3fdaf9c27e8860e8150d4683eb4046d97a53293a
Reviewed-on: https://go-review.googlesource.com/c/go/+/398894
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
2022-04-08 21:51:50 +00:00
Johan Jansson
db576c9f3a net/textproto: initialize commonHeader in canonicalMIMEHeaderKey
Call initCommonHeader in canonicalMIMEHeaderKey to ensure that
commonHeader is initialized before use. Remove all other calls to
initCommonHeader, since commonHeader is only used in
canonicalMIMEHeaderKey.

This prevents a race condition: read of commonHeader before
commonHeader has been initialized.

Add regression test that triggers the race condition which can be
detected by the race detector.

Fixes #46363

Change-Id: I00c8c52c6f4c78c0305978c876142c1b388174af
Reviewed-on: https://go-review.googlesource.com/c/go/+/397575
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-08 21:40:11 +00:00
Bryan C. Mills
3a19102de3 cmd/vendor: revert vendored code mistakenly modified in CL 398734
CL 398734 mistakenly modified
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm/tables.go, which causes
the cmd/internal/moddeps to (correctly) fail due to modified vendored
code. This reverts the edit by re-running 'go mod vendor'.

Fixes #52231.

Change-Id: I1def3efe5d408464561e775feb0f9d34ff5fd0b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/399154
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-08 18:30:53 +00:00
qmuntal
3e387528e5 cmd/go: cgo export header to be compatible with MSVC complex types
After CL 379474 has landed, the only remaining cgo export header
incompatibility with MSVC is the use of the _Complex macro,
which is not supported in MSVC even when it is part of the ISO C99
standard (1).

Since MSVC 2015 (2), complex math are supported via _Fcomplex and
_Dcomplex, which are equivalent to float _Complex and double _Complex.

As MSVC and C complex types have the same memory layout, we should
be able to typedef GoComplex64 and GoComplex128 to the appropriate
type in MSVC.

It is important to note that this CL is not adding MSVC support to cgo.
C compilers should still be GCC-compatible.

This CL is about allowing to include, without further modifications,
a DLL export header generated by cgo, normally using Mingw-W64 compiler,
into a MSVC project. This was already possible if the export header
changes introduced in this CL were done outside cgo, either manually or
in a post-build script.

Fixes #36233

1: https://docs.microsoft.com/en-us/cpp/c-runtime-library/complex-math-support
2: https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?c-standard-library-features-1
Change-Id: Iad8f26984b115c728e3b73f3a8334ade7a11cfa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/397134
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-08 14:13:32 +00:00
Daniel Martí
3e7ffb862f all: consistently use US spelling of present participles
It has been agreed that we should prefer the US spelling of words like
"canceling" over "cancelling"; for example, see https://go.dev/cl/14526.

Fix a few occurrences of the "canceling" inconsistency, as well as:

* signaling
* tunneling
* marshaling

Change-Id: I99f3ba0a700a9f0292bc6c1b110af31dd05f1ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/398734
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-08 13:44:41 +00:00
hopehook
5a90270d7f cmd/compile: fix deadlock on syntax error
Fixes #52127

Change-Id: I6523c83350cb9263d23e3e8b472fe63a5cc99c2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/398014
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-07 23:33:12 +00:00
hopehook
c451a02a6d strings, bytes: improve the description of simple case-folding in EqualFold
This CL removes the problem description pointed out by @bjkail.
Second, synchronously modify the comments of the bytes package.

Updates #52022
Fixes #52204

Change-Id: I0aa52c774f40bb91f32bebdd2a62a11067a77be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/398736
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2022-04-07 23:06:24 +00:00
Paul E. Murphy
8d581f589e crypto/aes: simplify key expansion in ppc64le asm
The ported cryptogam implementation uses a subtle and tricky mechanism
using lxv/vperm/lvsl to load unaligned vectors. This is difficult to
read, and may read and write unrelated bytes if reading from an
unaligned address.

Instead, POWER8 instructions can be used to load from unaligned memory
with much less overhead. Alignment interrupts only occur when reading
or writing cache-inhibited memory, which we assume isn't used in go
today, otherwise alignment penalties are usually marginal.

Instead lxvd2x+xxpermdi and xxpermdi+stxvd2x can be used to emulate
unaligned LE bytewise loads, similar to lxv/stxv on POWER9 in
little-endian mode.

Likewise, a custom permute vector is used to emulate BE bytewise
storage operations, lxvb16x/stxvb16x, on POWER9.

This greatly simplifies the code, and it makes it much easier to store
the keys in reverse (which is exactly how the decrypt keys are expected
to be stored).

Change-Id: I2334337e31a8fdf8d13ba96231142a039f237098
Reviewed-on: https://go-review.googlesource.com/c/go/+/395494
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-07 20:56:02 +00:00
Ian Lance Taylor
6f6942ef7a doc/go1.19: use the right package error.Is arguments
They were swapped.

Fixes #52205

Change-Id: Iea2626aa2204f3bc96d08c571a1aa669436a32ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/398895
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-04-07 20:39:32 +00:00
Matthew Dempsky
79619c3c7e test: extend issue52124.go to also test #52139
Change-Id: I7da79d52d50d96536a8175ba08e9da551d07fadd
Reviewed-on: https://go-review.googlesource.com/c/go/+/398094
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-07 19:16:46 +00:00
Robert Griesemer
c0bbeb0982 cmd/compile: adjust types2 shift check to match go/types (cleanup)
With this change, the shift checking code matches the corresponding
go/types code, but for the differences in the internal error reporting,
and call of check.overflow.

The change leads to the recording of an untyped int value if the RHS
of a non-constant shift is an untyped integer value. Adjust the type
in the compiler's irgen accordingly. Add test/shift3.go to verify
behavior.

Change-Id: I20386fcb1d5c48becffdc2203081fb70c08b282d
Reviewed-on: https://go-review.googlesource.com/c/go/+/398236
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-04-07 17:19:55 +00:00
Eli Bendersky
063f4032f5 sort: add Find function
For golang/go#50340

Change-Id: I3b4d278affc8e7ec706db8c9777f7a8c8ce7441d
Reviewed-on: https://go-review.googlesource.com/c/go/+/396514
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-07 14:42:13 +00:00
Nigel Tao
3a0cda43a4 image/draw: have draw.Src preserve NRGBA colors
This reverts a behavior change introduced in Go 1.18 (commit 9f69a443;
CL 340049). In Go 1.17 and earlier, draw.Draw(etc, draw.Src) with
image.NRGBA dst and src images would pass through a (heap allocated)
color.Color interface value holding a color.NRGBA concrete value.
Threading that color.NRGBA value all the way through preserves
non-premultiplied alpha transparency information (distinguishing e.g.
transparent blue from transparent red).

CL 340049 optimized out that heap allocation (per pixel), calling new
SetRGBA64At and RGBA64At methods instead. However, these methods (like
the existing image/color Color.RGBA method) work in premultiplied alpha,
so any distinction between transparent colors is lost.

This commit re-introduces the preservation of distinct transparencies,
when dst and src are both *image.NRGBA (or both *image.NRGBA64) and the
op is draw.Src.

Fixes #51893

Change-Id: Id9c64bfeeaecc458586f169f50b99d6c8aa52a7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/396795
Trust: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-04-07 10:41:34 +00:00
Meng Zhuo
d3362fc124 cmd/compile: enable reg args on riscv64
This CL updates config.go to enable register args.

Change-Id: I00697fc3db23293be0f5bd2fe33fb0055eeab43e
Reviewed-on: https://go-review.googlesource.com/c/go/+/360217
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-04-07 06:23:40 +00:00
j178
870256ec89 hash/maphash: use correct method name in comment
Change-Id: I01a3a5232525683c987b52ab8ece3fc18b6f431b
GitHub-Last-Rev: d2ec8fe536
GitHub-Pull-Request: golang/go#52194
Reviewed-on: https://go-review.googlesource.com/c/go/+/398714
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
2022-04-07 05:42:16 +00:00
mprahl
9a6acc83c8 text/template: support delimiters that can be confused with actions
In fields that start with the same character as the right delimiter, the
whole delimiter needs to be checked. The first character alone is not
sufficient.

Fixes #52165

Change-Id: I1e4086048417693757f34d0e9ff3bf86aba0d35c
Reviewed-on: https://go-review.googlesource.com/c/go/+/398475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2022-04-06 22:27:40 +00:00
Bryan C. Mills
81ae993e54 net/http: ignore ECONNRESET errors in TestTransportConcurrency on netbsd
The source of these errors is undiagnosed, but they have only been
observed on netbsd builders (on a variety of architectures).

Tested manually by injecting this code into the test's handler:

		if mrand.Intn(4) == 0 {
			if conn, _, err := w.(Hijacker).Hijack(); err == nil {
				conn.(*net.TCPConn).SetLinger(0)
				conn.Close()
				return
			}
		}

and temporarily disabling the 'runtime.GOOS' part of the condition.

For #52168.

Change-Id: I10965803e5a0d493ac4a000575de8b5f0266989c
Reviewed-on: https://go-review.googlesource.com/c/go/+/398635
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-06 20:46:47 +00:00
Philippe Antoine
5bb2628c6f bytes: limit allocation in SplitN
So that bytes.SplitN("", "T", int(144115188075855872)) does not panic.

Change-Id: I7c068852bd708416164fc2ed8b84cf6b2d593666
GitHub-Last-Rev: f8df09d65e
GitHub-Pull-Request: golang/go#52147
Reviewed-on: https://go-review.googlesource.com/c/go/+/398076
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: mzh <mzh@golangcn.org>
2022-04-06 03:13:34 +00:00
Meng Zhuo
6c17529af7 cmd/internal/obj: set morestack arg spilling and regabi prologue on riscv64
This CL spill arg registers before calling morestack, unspill
after.
Also, avoid X11,X12,X13 in function prologue, which may carry
live argument value.

Change-Id: I7a2841fbe306f62a7765e212f9f0be5c11ce7f8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/396655
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-04-06 01:11:21 +00:00
Roland Shoemaker
2de2f6df64 crypto/x509: add new CRL parser, deprecate old one
Adds a new, cryptobyte based, CRL parser, which returns a
x509.RevocaitonList, rather than a pkix.CertificateList. This allows us
to return much more detailed information, as well as leaving open the
option of adding further information since RevocationList is not a
direct ASN.1 representation like pkix.CertificateList. Additionally
a new method is added to RevocationList, CheckSignatureFrom, which is
analogous to the method with the same name on Certificate, which
properly checks that the signature is from an issuing certiifcate.

This change also deprecates a number of older CRL related functions and
types, which have been replaced with the new functionality introduced
in this change:
  * crypto/x509.ParseCRL
  * crypto/x509.ParseDERCRL
  * crypto/x509.CheckCRLSignature
  * crypto/x509/pkix.CertificateList
  * crypto/x509/pkix.TBSCertificateList

Fixes #50674

Change-Id: I27dc219e39bef09a396e666b4fccaa32578fd913
Reviewed-on: https://go-review.googlesource.com/c/go/+/390834
Reviewed-by: Damien Neil <dneil@google.com>
Trust: 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>
2022-04-05 23:32:55 +00:00
Ian Lance Taylor
dbb52cc9f3 net/url: preserve a trailing slash in JoinPath
Fixes #52074

Change-Id: I30897f32e70a6ca0c4e11aaf07088c27336efaba
Reviewed-on: https://go-review.googlesource.com/c/go/+/397256
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
2022-04-05 22:09:11 +00:00
Bryan C. Mills
69756b38f2 cmd/dist: move more environment logic into cmd/dist from make and run scripts
'go tool dist env' outputs different (and fewer) environment variables
than 'go env'. The 'go tool dist env' variables should be
authoritative, whereas many printed by 'go env' are merely
informational (and not intended to be overridden in the actual
environment).

Fixes #52009

Change-Id: Ic0590153875183135cebf7ca55ead7c2b4038569
Reviewed-on: https://go-review.googlesource.com/c/go/+/398061
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05 21:45:19 +00:00
Bryan C. Mills
5a6a830c1c cmd/vendor: undo stray edits from CL 384262
cmd/internal/moddeps is currently failing on the longtest builders
because vendored third-party dependencies were accidentally edited as
part of CL 384262 (a global cleanup of the standard library).

Updates #51082

Change-Id: I6f79c8f1177420a51128ce42d6c14fa5dcc4bd7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/398455
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05 18:58:52 +00:00
Russ Cox
9e16cc1541 hash/maphash: add Bytes and String
For very small inputs, h.Reset+h.Write+h.Sum64 is fundamentally
slower than a single operation, by about a factor of two, because
Write must copy the data into h's buffer, just in case there is another
Write before the Sum64.

A single function doing the whole sequence knows there is no extra
write that will happen, so it doesn't need the buffer, so it avoids the copy.

Fixes #42710.

Change-Id: Icc79c68ccb10827f6640071d026df86b4940fcc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/392494
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05 18:01:26 +00:00
Russ Cox
9839668b56 all: separate doc comment from //go: directives
A future change to gofmt will rewrite

	// Doc comment.
	//go:foo

to

	// Doc comment.
	//
	//go:foo

Apply that change preemptively to all comments (not necessarily just doc comments).

For #51082.

Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9
Reviewed-on: https://go-review.googlesource.com/c/go/+/384260
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05 17:54:15 +00:00
Russ Cox
81431c7aa7 all: replace `` and '' with “ (U+201C) and ” (U+201D) in doc comments
go/doc in all its forms applies this replacement when rendering
the comments. We are considering formatting doc comments,
including doing this replacement as part of the formatting.
Apply it to our source files ahead of time.

For #51082.

Change-Id: Ifcc1f5861abb57c5d14e7d8c2102dfb31b7a3a19
Reviewed-on: https://go-review.googlesource.com/c/go/+/384262
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05 17:52:29 +00:00
Bryan C. Mills
b4cabaf8c0 os/signal: run TestNotifyContextNotifications subtests in parallel
If we run out of time on the first subtest, we don't want to start the
second one with essentially no time remaining. (Moreover, there is no
compelling reason not to run these tests in parallel, since they send
signals to separate processes.)

For #51054.

Change-Id: I0424e08c3a9d2db986568d5a5c004859b52f7c51
Reviewed-on: https://go-review.googlesource.com/c/go/+/398454
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Henrique Vicente de Oliveira Pinto <henriquevicente@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05 17:35:18 +00:00
zhouguangyuan
7c45dafdb2 cmd/internal/objabi: fix FuncID of runtime.rt0_go and runtime.systemstack_switch
Fixes #52092

Change-Id: I774a6722c6e3ce6781e1d8bc16ac68efee6f9c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/396797
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
2022-04-05 17:12:35 +00:00
Roland Shoemaker
65153e478e crypto/x509: rework path building
This change does four things:
  * removes the chain cache
  * during path building, equality is determined by checking if the
    subjects and public keys match, rather than checking if the entire
    certificates are equal
  * enforces EKU suitability during path building
  * enforces name constraints on intermediates and roots which have
    SANs during path building

The chain cache is removed as it was causing duplicate chains to be
returned, in some cases shadowing better, shorter chains if a longer
chain was found first.

Checking equality using the subjects and public keys, rather than the
entire certificates, allows the path builder to ignore chains which
contain cross-signature loops.

EKU checking is done during path building, as the previous behavior
of only checking EKUs once the path had been built caused the path
builder to incorrectly ignore valid paths when it encountered a path
which would later be ruled invalid because of unacceptable EKU usage.

Name constraints are applied uniformly across all certificates, not
just leaves, in order to be more consistent.

Fixes #48869
Fixes #45856

Change-Id: I4ca1cd43510d061e148f953d6c1ed935100fdb10
Reviewed-on: https://go-review.googlesource.com/c/go/+/389555
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Cherry Mui <cherryyz@google.com>
Trust: 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>
2022-04-05 17:00:25 +00:00
Lasse Folger
4739b353bb [dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: Iaf618444dd2d99721c19708df9ce2c1f35854efd
2022-04-05 18:53:15 +02:00
vpachkov
1a955bcdb7 reflectdata: unroll a loop in array equal function generation
As josharian mentioned, a compare function could benefit from
unrolling a loop for arrays. This commit introduces such
functionality.

name                     old time/op  new time/op  delta
EqArrayOfStrings5-12     12.5ns ± 1%   8.4ns ± 1%  -33.05%  (p=0.008 n=5+5)
EqArrayOfStrings64-12    71.7ns ± 1%  64.1ns ± 1%  -10.57%  (p=0.008 n=5+5)
EqArrayOfStrings1024-12  1.12µs ± 1%  1.01µs ± 0%   -9.77%  (p=0.008 n=5+5)
[Geo mean]                100ns         81ns       -18.56%

name                    old time/op  new time/op  delta
EqArrayOfFloats5-12     4.50ns ± 2%  3.32ns ± 1%  -26.09%  (p=0.008 n=5+5)
EqArrayOfFloats64-12    41.3ns ± 1%  35.7ns ± 0%  -13.63%  (p=0.016 n=5+4)
EqArrayOfFloats1024-12   619ns ± 1%   557ns ± 1%   -9.95%  (p=0.008 n=5+5)
[Geo mean]              48.6ns       40.4ns       -16.85%

Change-Id: If1b69c5cf3fb246bb0275a292118b0b93ad9c9a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/368614
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-05 14:34:18 +00:00
Bryan C. Mills
5210a71285 run.bat: use cmd/dist instead of 'go install' to rebuild std and cmd
cmd/dist may set and/or unset variables before building, and at any
rate it is fragile to run 'go install' before sourcing env.bat.

The build-stamp information embedded by the 'go' command is currently
sensitive to whether CGO_* variables are implicit or explicit, so running
'go install' before env.bat may cause stamped metadata to become stale.
(Explicitly setting to the default arguably ought to produce the same
metadata as leaving the variables unset, but that's a separate issue
and a bigger cleanup.)

Moreover, run.bat is supposed to parallel run.bash, and run.bash
already hasn't invoked 'go install' itself since CL 6531!

For #52009

Change-Id: Ie35217913f02cc7e0c3f9b12874abd7416473478
Reviewed-on: https://go-review.googlesource.com/c/go/+/398060
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-04-05 14:18:19 +00:00
Bryan C. Mills
592078ff3f cmd/go/internal/work: omit modinfo line from cache key when empty
Cache keys are dumped in case of mismatch; an empty modinfo string
adds noise to that dump without a corresponding benefit.

For #52009.

Change-Id: I1b4cd85fa5ff920973552fc94977954f93622a32
Reviewed-on: https://go-review.googlesource.com/c/go/+/398059
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05 14:16:39 +00:00
Bryan C. Mills
62bceae32d cmd/go: quote fragments in CGO_ env variables reported by 'go env'
These fields have been parsed as quoted fields since CL 334732,
but we missed the unparsing side in 'go env'.

Certain scripts (notably make.ba{sh,t}) expect to be able to set the
environment to exactly what 'go env' reports, so for round-trip
purposes it is important to match the marshaling and unmarshaling
functions.

(Noticed while debugging #52009.)
Updates #41400

Change-Id: I0ff39b7a6e1328111c285c97cd23f79b723f3c73
Reviewed-on: https://go-review.googlesource.com/c/go/+/398058
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05 14:15:59 +00:00
Filippo Valsorda
a5f801f39d crypto/elliptic: delete outdated fuzz test
It had not been doing anything since CL 233939, because the Params
method was getting upgraded to the assembly one. We could make it use
genericParamsForCurve, but really we need lower-level, targeted Go 1.18
fuzz targets in nistec now.

Change-Id: I5b198a309aa90ecef9c04aaa6c107d5c0a41a44b
Reviewed-on: https://go-review.googlesource.com/c/go/+/396254
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-04-05 09:26:22 +00:00
Filippo Valsorda
a041a75295 crypto/elliptic: fix BenchmarkMarshalUnmarshal/Compressed
Change-Id: Ifbf4a95e5f315a88633ec0170625cadb087167c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/396934
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-04-05 09:26:01 +00:00
Dmitri Shuralyov
eec47d06c1 api: add x509.CertPool.Equal to next/46057.txt
CL 388915 added an exported API but was authored (and tested)
before the API check became stricter.

Updates #46057.

Change-Id: Iee6e4969ade77fb0539fa97fcef0047389fb2cf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/398237
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-04-05 03:54:36 +00:00
Dan Kortschak
07b0c57a75 crypto/subtle: note that input length mismatch makes ConstantTimeCompare return immediately
Change-Id: Id1ae6c8fbb8c2f31b251ba141dc2bbedae189006
Reviewed-on: https://go-review.googlesource.com/c/go/+/316169
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2022-04-05 01:54:27 +00:00