Compare commits

..

83 Commits

Author SHA1 Message Date
Gopher Robot
324c3ace2d [release-branch.go1.20] go1.20.4
Change-Id: I12cd69dd6b1c7c9620738a0d89b10e0a330a3004
Reviewed-on: https://go-review.googlesource.com/c/go/+/491435
Run-TryBot: Gopher Robot <gobot@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2023-05-02 17:21:02 +00:00
Roland Shoemaker
337dd75343 [release-branch.go1.20] html/template: emit filterFailsafe for empty unquoted attr value
An unquoted action used as an attribute value can result in unsafe
behavior if it is empty, as HTML normalization will result in unexpected
attributes, and may allow attribute injection. If executing a template
results in a empty unquoted attribute value, emit filterFailsafe
instead.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

For #59722
Fixes #59816
Fixes CVE-2023-29400

Change-Id: Ia38d1b536ae2b4af5323a6c6d861e3c057c2570a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1826631
Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1851494
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/491358
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-02 16:36:15 +00:00
Roland Shoemaker
4a28cad666 [release-branch.go1.20] html/template: handle all JS whitespace characters
Rather than just a small set. Character class as defined by \s [0].

Thanks to Juho Nurminen of Mattermost for reporting this.

For #59721
Fixes #59814
Fixes CVE-2023-24540

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes

Change-Id: I56d4fa1ef08125b417106ee7dbfb5b0923b901ba
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1821459
Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1851493
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/491356
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-02 16:35:35 +00:00
Roland Shoemaker
090590fdcc [release-branch.go1.20] html/template: disallow angle brackets in CSS values
Angle brackets should not appear in CSS contexts, as they may affect
token boundaries (such as closing a <style> tag, resulting in
injection). Instead emit filterFailsafe, matching the behavior for other
dangerous characters.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

For #59720
Fixes #59812
Fixes CVE-2023-24539

Change-Id: Iccc659c9a18415992b0c05c178792228e3a7bae4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1826636
Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1851492
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/491336
Run-TryBot: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-05-02 16:32:02 +00:00
Damien Neil
25b4f40625 [release-branch.go1.20] Revert "net/http: FileServer method check + minimal OPTIONS implementation"
This reverts https://go.dev/cl/413554

Reason for revert: Backwards-incompatible change in behavior.

For #53501
For #59375
Fixes #59469

Change-Id: Ic3f63b378f9c819599b32e5e6e410f6163849317
Reviewed-on: https://go-review.googlesource.com/c/go/+/482635
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit c02fa75086)
Reviewed-on: https://go-review.googlesource.com/c/go/+/488635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2023-04-25 15:50:56 +00:00
Bryan C. Mills
484535e67b cmd/compile/internal/importer,go/internal/gcimporter: use the 'go' command from build.Default.GOROOT in lookupGorootExport
Also set GOROOT explicitly in case it is set to something else in the
caller's environment.

Updates #59598.
Fixes #59637.

Change-Id: I5599ed1183b23187fc3b976786f3c320d42ef4f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/484756
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 750e91152b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/484758
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-04-24 18:46:00 +00:00
Tero Saarni
813a811d33 [release-branch.go1.20] crypto/tls: fix PSK binder calculation
When server and client have mismatch in curve preference, the server will
send HelloRetryRequest during TLSv1.3 PSK resumption. There was a bug
introduced by Go1.19.6 or later and Go1.20.1 or later, that makes the client
calculate the PSK binder hash incorrectly. Server will reject the TLS
handshake by sending alert: invalid PSK binder.

For #59424.
Fixes #59540.

Change-Id: I2ca8948474275740a36d991c057b62a13392dbb9
GitHub-Last-Rev: 1aad9bcf27
GitHub-Pull-Request: golang/go#59425
Reviewed-on: https://go-review.googlesource.com/c/go/+/481955
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
(cherry picked from commit 2c70690451)
Reviewed-on: https://go-review.googlesource.com/c/go/+/488055
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2023-04-24 18:25:14 +00:00
Matthew Dempsky
ee42d468f5 [release-branch.go1.20] cmd/compile: fix reproducible build of aliased generic types
Due to a missing "&& !alias" check, the unified linker was treating
type aliases the same as defined types for the purpose of exporting
method bodies. The methods will get exported anyway alongside the
aliased type, so this mistake is normally harmless.

However, if multiple type aliases instantiated the same generic type
but with different type arguments, this could result in the
same (generic) method body being exported multiple times under
different symbol names. Further, because bodies aren't expected to be
exported multiple times, we were sorting them simply based on index.
And consequently, the sort wasn't total and is sensitive to the map
iteration order used while ranging over linker.bodies.

The fix is simply to add the missing "&& !alias" check, so that we
don't end up with duplicate bodies in the first place.

Thanks rsc@ for providing a minimal repro case.

Fixes #59585.

Change-Id: Iaa55968cc7110b601e2f0f9b620901c2d55f7014
Reviewed-on: https://go-review.googlesource.com/c/go/+/484155
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
(cherry picked from commit f58c6cccc4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/484160
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-04-24 14:06:53 +00:00
David Chase
446493f5b8 [release-branch.go1.20] cmd/compile: remove broken LEA "optimization"
CL 440035 added rewrite rules to simplify "costly" LEA
instructions, but the types in the rewrites were wrong and
the code would go bad if the wrong-typed register was spilled.

CL 482536 attempted to fix this by correcting the type in the
rewrite, but that "fix" broke something on windows-amd64-race.

Instead / for-now, remove the offending rewrite rules.

Updates #21735.
Updates #59432.
Fixes #59468.

Change-Id: I0497c42db414f2055e1378e0a53e2bceee9cd5d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/482820
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 6a97a60b4b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/482164
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-04-24 13:53:18 +00:00
Keith Randall
0684cecad5 [release-branch.go1.20] cmd/compile: use correct type for byteswaps on multi-byte stores
Use the type of the store for the byteswap, not the type of the
store's value argument.

Normally when we're storing a 16-bit value, the value being stored is
also typed as 16 bits. But sometimes it is typed as something smaller,
usually because it is the result of an upcast from a smaller value,
and that upcast needs no instructions.

If the type of the store's arg is thinner than the type being stored,
and the byteswap'd value uses that thinner type, and the byteswap'd
value needs to be spilled & restored, that spill/restore happens using
the thinner type, which causes us to lose some of the top bits of the
value.

Fixes #59374

Change-Id: If6ce1e8a76f18bf8e9d79871b6caa438bc3cce4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/481395
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit b3bc8620f8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/483176
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-04-24 13:44:00 +00:00
Ian Lance Taylor
ecf7e00db8 [release-branch.go1.20] syscall: restore original NOFILE rlimit in child process
If we increased the NOFILE rlimit when starting the program,
restore the original rlimit when forking a child process.

In CL 393354 the os package was changed to raise the open file rlimit
at program start. That code is not inherently tied to the os package.
This CL moves it into the syscall package.

This is a backport of CLs 476096 and 476097 from trunk.

For #46279
Fixes #59064

Change-Id: Ib813de896de0a5d28fa2b29afdf414a89fbe7b2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/478659
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-04-14 17:58:41 +00:00
Junwei Zuo
1dbbac7d79 [release-branch.go1.20] cmd/compile: fix ir.StaticValue for ORANGE
Range statement will mutate the key and value, so we should treat them as reassigned.

Fixes #59580

Change-Id: I9c6b67d938760a0c6a1d9739f2737c67af4a3a10
Reviewed-on: https://go-review.googlesource.com/c/go/+/483855
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 89567a35c1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/484136
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-04-12 20:25:12 +00:00
Cuong Manh Le
99001c460e [release-branch.go1.20] cmd/compile: don't set range expr key/value type if already set
Unified IR already records the correct type for them.

Fixes #59450

Change-Id: I275c45b48f67bde55c8e2079d60b5868d0acde7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/481555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/482655
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2023-04-05 20:55:31 +00:00
Keith Randall
dcc9bdf380 [release-branch.go1.20] crypto/subtle: don't cast to *uintptr when word size is 0
Casting to a *uintptr is not ok if there isn't at least 8 bytes of
data backing that pointer (on 64-bit archs).
So although we end up making a slice of 0 length with that pointer,
the cast itself doesn't know that.
Instead, bail early if the result is going to be 0 length.

Fixes #59336

Change-Id: Id3c0e09d341d838835c0382cccfb0f71dc3dc7e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/480575
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit 297cf6dd31bd99fc4ccda320aa3d4faf290ab278)
Reviewed-on: https://go-review.googlesource.com/c/go/+/481238
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2023-04-05 16:51:32 +00:00
Michael Anthony Knyszek
5c7c20e262 [release-branch.go1.20] html/template,mime/multipart: document new GODEBUG settings
This change documents the new GODEBUG settings introduced for
html/template and mime/multipart, released with Go 1.19.8 and Go 1.20.3
as part of a security fix.

Updates #59153.
For #59270.
Updates #59234.
For #59272.

Change-Id: I25f4d8245da3301dccccfb44da8ff1a5985392a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/482555
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2023-04-05 16:19:16 +00:00
Gopher Robot
7c47a6b157 [release-branch.go1.20] go1.20.3
Change-Id: I1ca3074262203c6f250c902ca087d244edf9eb96
Reviewed-on: https://go-review.googlesource.com/c/go/+/482097
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Gopher Robot <gobot@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-04-04 17:30:09 +00:00
Roland Shoemaker
20374d1d75 [release-branch.go1.20] html/template: disallow actions in JS template literals
ECMAScript 6 introduced template literals[0][1] which are delimited with
backticks. These need to be escaped in a similar fashion to the
delimiters for other string literals. Additionally template literals can
contain special syntax for string interpolation.

There is no clear way to allow safe insertion of actions within JS
template literals, as handling (JS) string interpolation inside of these
literals is rather complex. As such we've chosen to simply disallow
template actions within these template literals.

A new error code is added for this parsing failure case, errJsTmplLit,
but it is unexported as it is not backwards compatible with other minor
release versions to introduce an API change in a minor release. We will
export this code in the next major release.

The previous behavior (with the cavet that backticks are now escaped
properly) can be re-enabled with GODEBUG=jstmpllitinterp=1.

This change subsumes CL471455.

Thanks to Sohom Datta, Manipal Institute of Technology, for reporting
this issue.

Fixes CVE-2023-24538
For #59234
Fixes #59272

[0] https://tc39.es/ecma262/multipage/ecmascript-language-expressions.html#sec-template-literals
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Change-Id: Idff74ec386e9b73d6e9a3c9f71990eabc0ce7506
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802457
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802688
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481993
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-04-04 16:59:18 +00:00
Damien Neil
e7c4b07ecf [release-branch.go1.20] go/scanner: reject large line and column numbers in //line directives
Setting a large line or column number using a //line directive can cause
integer overflow even in small source files.

Limit line and column numbers in //line directives to 2^30-1, which
is small enough to avoid int32 overflow on all reasonbly-sized files.

Fixes CVE-2023-24537
For #59180
Fixes #59274

Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802456
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Change-Id: Ib9c5cb38428ed34ab129d451b00a2998e72c861c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802401
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481992
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2023-04-04 16:59:15 +00:00
Damien Neil
bf8c7c575c [release-branch.go1.20] mime/multipart: limit parsed mime message sizes
The parsed forms of MIME headers and multipart forms can consume
substantially more memory than the size of the input data.
A malicious input containing a very large number of headers or
form parts can cause excessively large memory allocations.

Set limits on the size of MIME data:

Reader.NextPart and Reader.NextRawPart limit the the number
of headers in a part to 10000.

Reader.ReadForm limits the total number of headers in all
FileHeaders to 10000.

Both of these limits may be set with with
GODEBUG=multipartmaxheaders=<values>.

Reader.ReadForm limits the number of parts in a form to 1000.
This limit may be set with GODEBUG=multipartmaxparts=<value>.

Thanks for Jakob Ackermann (@das7pad) for reporting this issue.

For CVE-2023-24536
For #59153
For #59270

Change-Id: I36ddceead7f8292c327286fd8694e6113d3b4977
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802455
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802608
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481991
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2023-04-04 16:58:39 +00:00
Damien Neil
ec18f62df5 [release-branch.go1.20] net/textproto, mime/multipart: improve accounting of non-file data
For requests containing large numbers of small parts,
memory consumption of a parsed form could be about 250%
over the estimated size.

When considering the size of parsed forms, account for the size of
FileHeader structs and increase the estimate of memory consumed by
map entries.

Thanks to Jakob Ackermann (@das7pad) for reporting this issue.

For CVE-2023-24536
For #59153
For #59270

Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802454
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Change-Id: I9753aa1f8a1b1479c160f870def3b7081b6847ac
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802399
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481990
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2023-04-04 16:58:38 +00:00
Damien Neil
ea6b5a64dd [release-branch.go1.20] mime/multipart: avoid excessive copy buffer allocations in ReadForm
When copying form data to disk with io.Copy,
allocate only one copy buffer and reuse it rather than
creating two buffers per file (one from io.multiReader.WriteTo,
and a second one from os.File.ReadFrom).

Thanks to Jakob Ackermann (@das7pad) for reporting this issue.

For CVE-2023-24536
For #59153
For #59270

Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802453
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Change-Id: I44ef17c4b4964cdac2858317275594194801fee3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802398
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481989
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-04-04 16:58:11 +00:00
Damien Neil
3991f6c41c [release-branch.go1.20] net/textproto: avoid overpredicting the number of MIME header keys
A parsed MIME header is a map[string][]string. In the common case,
a header contains many one-element []string slices. To avoid
allocating a separate slice for each key, ReadMIMEHeader looks
ahead in the input to predict the number of keys that will be
parsed, and allocates a single []string of that length.
The individual slices are then allocated out of the larger one.

The prediction of the number of header keys was done by counting
newlines in the input buffer, which does not take into account
header continuation lines (where a header key/value spans multiple
lines) or the end of the header block and the start of the body.
This could lead to a substantial amount of overallocation, for
example when the body consists of nothing but a large block of
newlines.

Fix header key count prediction to take into account the end of
the headers (indicated by a blank line) and continuation lines
(starting with whitespace).

Thanks to Jakob Ackermann (@das7pad) for reporting this issue.

Fixes CVE-2023-24534
For #58975
Fixes #59268

Change-Id: I0591593e67b6fdba22a32dcc3334fad797727f5c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802452
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802397
Run-TryBot: Roland Shoemaker <bracewell@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/481988
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-04-04 16:58:09 +00:00
Lynn Boger
9a164d1c41 [release-branch.go1.20] cmd/internal/obj/ppc64: fix incorrect base reg causing segv
This fixes a segv that was reported due to building minio. The
problem occurred because of an incorrect selection of the
base register, which was introduced by CL 306369.

Fixes #59220

Change-Id: Ieb77b2afa8fb4e6f3943df5ce138679f6750d376
Reviewed-on: https://go-review.googlesource.com/c/go/+/479475
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-03-29 19:20:02 +00:00
Keith Randall
8dce4ca8df [release-branch.go1.20] cmd/compile: don't assume pointer of a slice is non-nil
unsafe.SliceData can return pointers which are nil. That function gets
lowered to the SSA OpSlicePtr, which the compiler assumes is non-nil.
This used to be the case as OpSlicePtr was only used in situations
where the bounds check already passed. But with unsafe.SliceData that
is no longer the case.

There are situations where we know it is nil. Use Bounded() to
indicate that.

I looked through all the uses of OSPTR and added SetBounded where it
made sense. Most OSPTR results are passed directly to runtime calls
(e.g. memmove), so even if we know they are non-nil that info isn't
helpful.

Fixes #59296

Change-Id: I437a15330db48e0082acfb1f89caf8c56723fc51
Reviewed-on: https://go-review.googlesource.com/c/go/+/479896
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
(cherry picked from commit b899641ecea7d07c997282e985beb295c31d1097)
Reviewed-on: https://go-review.googlesource.com/c/go/+/479899
Run-TryBot: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-03-29 19:07:23 +00:00
Cuong Manh Le
94c02a3cc4 [release-branch.go1.20] cmd/compile: re-compile instantiated generic methods in linkshared mode
For G[T] that was seen and compiled in imported package, it is not added
to typecheck.Target.Decls, prevent wasting compile time re-creating
DUPOKS symbols. However, the linker do not support a type symbol
referencing a method symbol across DSO boundary. That causes unreachable
sym error when building under -linkshared mode.

To fix it, always re-compile generic methods in linkshared mode.

Fixes #59236

Change-Id: I894b417cfe8234ae1fe809cc975889345df22cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/477375
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/479355
2023-03-29 18:40:30 +00:00
Geon Kim
65fa8a6931 [release-branch.go1.20] time: fix timezone lookup logic for non-DST zones
This change fixes time.LoadLocationFromTZData and time.Location.lookup logic if the given time is after the last transition and the extend string doesn't have the DST rule.

For #58682
Fixes #59075

Change-Id: Ie34a6d658d14c2b33098b29ab83c041ef0d34266
GitHub-Last-Rev: f6681eb44c
GitHub-Pull-Request: golang/go#58684
Reviewed-on: https://go-review.googlesource.com/c/go/+/471020
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 90dde5dec1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/478658
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
2023-03-23 17:51:16 +00:00
Than McIntosh
b52a6963bf [release-branch.go1.20] cmd/link/internal/arm: fix off-by-1 in trampoline reachability computation
Tweak the code in trampoline generation that determines if a given
call branch will reach, changing the lower limit guard from "x <
-0x800000" to "x <= -0x800000". This is to resolve linking failures
when the computed displacement is exactly -0x800000, which results in
errors of the form

  .../ld.gold: internal error in arm_branch_common, at ../../gold/arm.cc:4079

when using the Gold linker, and

  ...:(.text+0x...): relocation truncated to fit: R_ARM_CALL against `runtime.morestack_noctxt'

when using the bfd linker.

Fixes #59059.
Updates #59034.
Updates #58425.

Change-Id: I8a76986b38727df1b961654824c2af23f06b9fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/475957
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit f26bf203ac)
Reviewed-on: https://go-review.googlesource.com/c/go/+/476936
2023-03-22 17:41:43 +00:00
Than McIntosh
3ff6dbdf5b [release-branch.go1.20] cmd/go,cmd/link: prefer external linking when strange cgo flags seen
This patch changes the Go command to examine the set of compiler
flags feeding into the C compiler when packages that use cgo are built.
If any of a specific set of strange/dangerous flags are in use,
then the Go command generates a token file ("preferlinkext") and
embeds it into the compiled package's archive.

When the Go linker reads the archives of the packages feeding into the
link and detects a "preferlinkext" token, it will then use external
linking for the program by default (although this default can be
overridden with an explicit "-linkmode" flag).

The intent here is to avoid having to teach the Go linker's host object
reader to grok/understand the various odd symbols/sections/types that
can result from boutique flag use, but rather to just boot the objects
in question over to the C linker instead.

Fixes #59051.
Updates #58619.
Updates #58620.
Updates #58848.

Change-Id: I56382dd305de8dac3841a7a7e664277826061eaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/475375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 035db07d7c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/476577
2023-03-17 19:45:27 +00:00
Cherry Mui
fa42da156a [release-branch.go1.20] cmd/link: use label symbols for Duff's devices on darwin/arm64
On darwin, the external linker generally supports CALL relocations
with addend. One exception is that for a very large binary when it
decides to insert a trampoline, instead of applying the addend to
the call target (in the trampoline), it applies the addend to the
CALL instruction in the caller, i.e. generating a call to
trampoline+addend, which is not the correct address and usually
points to unreloated functions.

To work around this, we use label symbols so the CALL is targeting
a label symbol without addend. To make things simple we always use
label symbols for CALLs with addend (in external linking mode on
darwin/arm64), even for small binaries.

Updates #58935.
Fixes #58954.

Change-Id: I38aed6b62a0496c277c589b5accbbef6aace8dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/474620
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 7dbd6de7d4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/475175
2023-03-15 20:12:19 +00:00
Cherry Mui
5c7cc468a8 [release-branch.go1.20] Revert "cmd/compile: enable address folding for global symbols of shared library"
This reverts CL 445535.

Reason for revert: see issue #58826. It doesn't handle large offset well.

Updates #58826.
Fixes #58920.

Change-Id: Ic4a33f4c510c88628ea7e16207a60977a04cf798
Reviewed-on: https://go-review.googlesource.com/c/go/+/474175
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit a4cf4fde46)
Reviewed-on: https://go-review.googlesource.com/c/go/+/474235
Reviewed-by: Keith Randall <khr@golang.org>
2023-03-15 20:11:23 +00:00
Bryan C. Mills
b852f39511 [release-branch.go1.20] cmd/go: avoid running slow tests on non-longtest builders
Also annotate calls to tooSlow with specific reasons.

This will somewhat reduce test coverage on the 'darwin' builders until
we have darwin 'longtest' builders (#35678,#49055), but still seems
worthwhile to avoid alert fatigue from tests that really shouldn't be
running in the short configurations.

Updates #58918.
Updates #58919.
Fixes #58938.

Change-Id: I0000f0084b262beeec3eca3e9b8a45d61fab4313
Reviewed-on: https://go-review.googlesource.com/c/go/+/474137
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 9f532dd0de)
Reviewed-on: https://go-review.googlesource.com/c/go/+/474580
2023-03-09 22:48:51 +00:00
Heschi Kreinick
4df95d5145 [release-branch.go1.20] internal/testpty: fix error handling
When calling a c library function, you discover that an error has
occurred, typically by looking at the return value of the function. Only
after that can you use errno to figure out the cause of the error.

Nothing about cgo changes that story -- you still have to look at the
result before checking the error that represents errno. If not you can
get false errors if the function happens to leak a non-zero errno.

Fix testpty to check errors correctly.

Fixes #58942.

Change-Id: Idb95f8dd6a8ed63f653190c2e722e742cf50542b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463397
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit f85c282a18)
Reviewed-on: https://go-review.googlesource.com/c/go/+/474616
Reviewed-by: Carlos Amedee <carlos@golang.org>
2023-03-08 21:46:57 +00:00
Gopher Robot
aee9a19c55 [release-branch.go1.20] go1.20.2
Change-Id: Ib993bfea994a3e885a6068860d2e1f6705f8cf40
Reviewed-on: https://go-review.googlesource.com/c/go/+/474037
Auto-Submit: Gopher Robot <gobot@golang.org>
Run-TryBot: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-03-07 16:47:18 +00:00
Matthew Dempsky
26eeaec89c [release-branch.go1.20] cmd/compile: relax overly strict assertion
The assertion here was to make sure the newly constructed and
typechecked expression selected the same receiver-qualified method,
but in the case of anonymous receiver types we can actually end up
with separate types.Field instances corresponding to each types.Type
instance. In that case, the assertion spuriously failed.

The fix here is to relax and assertion and just compare the method's
name and type (including receiver type).

Fixes #58776.

Change-Id: I67d51ddb020e6ed52671473c93fc08f283a40886
Reviewed-on: https://go-review.googlesource.com/c/go/+/471676
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 37a2004b43)
Reviewed-on: https://go-review.googlesource.com/c/go/+/472620
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
2023-03-01 22:03:12 +00:00
Roland Shoemaker
9629fa1874 [release-branch.go1.20] crypto/x509: fix broken tests
Convert TestUnknownAuthorityError to use subtests, avoiding continuing
the test after an unrecoverable failure.

Skip TestIssue51759 on pre-macOS 11 builders, which don't enforce the
behavior we were testing for. Also only enable the test on builders.

Updates #58791
Updates #58812
Fixes #58811

Change-Id: I4e3e5bc371aa139d38052184c8232f8cb564138f
Reviewed-on: https://go-review.googlesource.com/c/go/+/472496
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit cf3d0655f8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/472618
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-03-01 21:50:30 +00:00
Roland Shoemaker
3243f93747 [release-branch.go1.20] crypto/x509: fix system root tests + darwin intermediate handling
On Windows, replace tests which rely on a root that expired last year.
On Darwin fix an test which wasn't testing the expected behavior, and
fix the behavior which was broken.

Updates #58791
Fixes #58811

Change-Id: I771175b9e123b8bb0e4efdf58cc2bb93aa94fbae
Reviewed-on: https://go-review.googlesource.com/c/go/+/472295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
(cherry picked from commit bb8f9a6ae6)
Reviewed-on: https://go-review.googlesource.com/c/go/+/472616
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-03-01 21:50:27 +00:00
Cuong Manh Le
d2d0ee2049 [release-branch.go1.20] syscall: fix invalid unsafe.Pointer conversion on Windows
Updates #58714
Fixes #58774

Change-Id: Ifa5c059ed5e358ed98aee7e83b95dd1806b535f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/471335
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit de8c999159)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471599
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-03-01 18:06:43 +00:00
Bryan C. Mills
230765a11a [release-branch.go1.20] net: delete TestTCPSelfConnect
This test is flaky, apparently due to a typo'd operator in CL 21447
that causes it to compare “same port OR IP” instead of
“same port AND IP”.

If we merely fixed the comparison, the test would hopefully stop being
flaky itself, but we would still be left with another problem:
repeatedly dialing a port that we believe to be unused can interfere
with other tests, which may open the previously-unused port and then
attempt a single Dial and expect it to succeed. Arbitrary other Dial
calls for that port may cause the wrong connection to be accepted,
leading to spurious test failures.

Moreover, the test can be extremely expensive for the amount of data
we hope to get from it, depending on the system's port-reuse
algorithms and dial implementations. It is already scaled back by up
to 1000x on a huge number of platforms due to latency, and may even be
ineffective on those platforms because of the arbitrary 1ms Dial
timeout. And the incremental value from it is quite low, too: it tests
the workaround for what is arguably a bug in the Linux kernel, which
ought to be fixed (and tested) upstream instead of worked around in
every open-source project that dials local ports.

Instead of trying to deflake this test, let's just get rid of it.

Updates #18290.
Fixes #58717.

Change-Id: I8a58b93d67916a33741c9ab29ef99c49c46b32c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/460657
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
(cherry picked from commit e08642cae1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471155
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-03-01 18:01:03 +00:00
Roland Shoemaker
bdd86bda09 [release-branch.go1.20] crypto/x509: fix ParsePKCS8PrivateKey comment
Updates #58789.
Fixes #58793.

Change-Id: I91cdd20c6d4f05baaacd6a38717aa7bed6682573
Reviewed-on: https://go-review.googlesource.com/c/go/+/472155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit ec26277aec)
Reviewed-on: https://go-review.googlesource.com/c/go/+/472415
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-03-01 17:28:55 +00:00
Kir Kolyshkin
aef8a8cd42 [release-branch.go1.20] syscall: Faccessat: check for CAP_DAC_OVERRIDE on Linux
CL 416115 added using faccessat2(2) from syscall.Faccessat on Linux
(which is the only true way to implement AT_EACCESS flag handing),
if available. If not available, it uses some heuristics to mimic the
kernel behavior, mostly taken from glibc (see CL 126415).

Next, CL 414824 added using the above call (via unix.Eaccess) to
exec.LookPath in order to check if the binary can really be executed.

As a result, in a very specific scenario, described below,
syscall.Faccessat (and thus exec.LookPath) mistakenly tells that the
binary can not be executed, while in reality it can be. This makes
this bug a regression in Go 1.20.

This scenario involves all these conditions:
 - no faccessat2 support available (i.e. either Linux kernel < 5.8,
   or a seccomp set up to disable faccessat2);
 - the current user is not root (i.e. geteuid() != 0);
 - CAP_DAC_OVERRIDE capability is set for the current process;
 - the file to be executed does not have executable permission
   bit set for either the current EUID or EGID;
 - the file to be executed have at least one executable bit set.

Unfortunately, this set of conditions was observed in the wild -- a
container run as a non-root user with the binary file owned by root with
executable permission set for a user only [1]. Essentially it means it
is not as rare as it may seem.

Now, CAP_DAC_OVERRIDE essentially makes the kernel bypass most of the
checks, so execve(2) and friends work the same was as for root user,
i.e. if at least one executable bit it set, the permission to execute
is granted (see generic_permission() function in the Linux kernel).

Modify the code to check for CAP_DAC_OVERRIDE and mimic the kernel
behavior for permission checks.

[1] https://github.com/opencontainers/runc/issues/3715

For #58552.
Fixes #58624.

Change-Id: I82a7e757ab3fd3d0193690a65c3b48fee46ff067
Reviewed-on: https://go-review.googlesource.com/c/go/+/468735
Reviewed-by: Damien Neil <dneil@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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 031401a790)
Reviewed-on: https://go-review.googlesource.com/c/go/+/469956
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-28 12:45:13 +00:00
Filippo Valsorda
ef793801f8 [release-branch.go1.20] crypto/internal/bigmod: flag amd64 assembly as noescape
I had forgotten, which caused amd64 allocations to go back up
significantly. Added an allocations test.

name                    old time/op    new time/op    delta
DecryptPKCS1v15/2048-8    1.50ms ± 0%    1.48ms ± 0%   -0.95%  (p=0.000 n=9+10)
DecryptPKCS1v15/3072-8    4.64ms ± 1%    4.60ms ± 0%   -0.82%  (p=0.000 n=8+10)
DecryptPKCS1v15/4096-8    10.7ms ± 0%    10.6ms ± 1%   -0.99%  (p=0.000 n=10+10)
EncryptPKCS1v15/2048-8     158µs ± 0%     157µs ± 0%   -0.63%  (p=0.000 n=10+10)
DecryptOAEP/2048-8        1.50ms ± 0%    1.48ms ± 0%   -1.09%  (p=0.000 n=9+10)
EncryptOAEP/2048-8         161µs ± 0%     160µs ± 0%   -0.34%  (p=0.000 n=9+10)
SignPKCS1v15/2048-8       1.55ms ± 0%    1.53ms ± 1%   -1.32%  (p=0.000 n=10+10)
VerifyPKCS1v15/2048-8      157µs ± 0%     157µs ± 0%   -0.33%  (p=0.004 n=9+10)
SignPSS/2048-8            1.55ms ± 0%    1.54ms ± 0%   -1.14%  (p=0.000 n=10+10)
VerifyPSS/2048-8           160µs ± 0%     160µs ± 0%   -0.32%  (p=0.000 n=10+10)

name                    old alloc/op   new alloc/op   delta
DecryptPKCS1v15/2048-8    15.0kB ± 0%     0.6kB ± 0%  -95.74%  (p=0.000 n=10+10)
DecryptPKCS1v15/3072-8    17.9kB ± 0%     3.5kB ± 0%  -80.65%  (p=0.000 n=10+10)
DecryptPKCS1v15/4096-8    19.1kB ± 0%     4.7kB ± 0%  -75.25%  (p=0.000 n=10+10)
EncryptPKCS1v15/2048-8    7.51kB ± 0%    1.17kB ± 0%  -84.39%  (p=0.000 n=10+10)
DecryptOAEP/2048-8        15.3kB ± 0%     0.9kB ± 0%  -94.29%  (p=0.000 n=10+10)
EncryptOAEP/2048-8        7.74kB ± 0%    1.40kB ± 0%  -81.86%  (p=0.000 n=10+10)
SignPKCS1v15/2048-8       21.6kB ± 0%     0.9kB ± 0%  -95.86%  (p=0.000 n=10+10)
VerifyPKCS1v15/2048-8     7.25kB ± 0%    0.91kB ± 0%  -87.42%  (p=0.000 n=10+10)
SignPSS/2048-8            22.0kB ± 0%     1.3kB ± 0%  -94.12%  (p=0.000 n=10+10)
VerifyPSS/2048-8          7.46kB ± 0%    1.12kB ± 0%  -84.98%  (p=0.000 n=10+10)

name                    old allocs/op  new allocs/op  delta
DecryptPKCS1v15/2048-8      54.0 ± 0%       4.0 ± 0%  -92.59%  (p=0.000 n=10+10)
DecryptPKCS1v15/3072-8      60.0 ± 0%      10.0 ± 0%  -83.33%  (p=0.000 n=10+10)
DecryptPKCS1v15/4096-8      60.0 ± 0%      10.0 ± 0%  -83.33%  (p=0.000 n=10+10)
EncryptPKCS1v15/2048-8      29.0 ± 0%       7.0 ± 0%  -75.86%  (p=0.000 n=10+10)
DecryptOAEP/2048-8          60.0 ± 0%      10.0 ± 0%  -83.33%  (p=0.000 n=10+10)
EncryptOAEP/2048-8          35.0 ± 0%      13.0 ± 0%  -62.86%  (p=0.000 n=10+10)
SignPKCS1v15/2048-8         77.0 ± 0%       5.0 ± 0%  -93.51%  (p=0.000 n=10+10)
VerifyPKCS1v15/2048-8       28.0 ± 0%       6.0 ± 0%  -78.57%  (p=0.000 n=10+10)
SignPSS/2048-8              82.0 ± 0%      10.0 ± 0%  -87.80%  (p=0.000 n=10+10)
VerifyPSS/2048-8            33.0 ± 0%      11.0 ± 0%  -66.67%  (p=0.000 n=10+10)

Updates #58501.
Fixes #58505.

Change-Id: I418c5152833787b80220b556336ec284674c2493
Reviewed-on: https://go-review.googlesource.com/c/go/+/460542
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
(cherry picked from commit ed370d8720)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471855
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-28 01:46:28 +00:00
Roland Shoemaker
aaace6dda7 [release-branch.go1.20] crypto/ecdh: explicitly reject mismatched curves in ECDH
Return an explicit error when PrivateKey.ECDH is called with a PublicKey
which uses a different Curve. Also document this requirement, even
though it is perhaps obvious.

Updates #58131.
Fixes #58498.

Change-Id: I739181a3f1283bed14fb5ee7eb78658b854d28d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/464335
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
(cherry picked from commit 67d8916d55)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471602
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-02-28 01:46:26 +00:00
Matthew Dempsky
0f4483cfdc [release-branch.go1.20] cmd/compile/internal/noder: correct positions for synthetic closures
When inlining functions that contain function literals, we need to be
careful about position information. The OCLOSURE node should use the
inline-adjusted position, but the ODCLFUNC and its body should use the
original positions.

However, the same problem can arise with certain generic constructs,
which require the compiler to synthesize function literals to insert
dictionary arguments.

go.dev/cl/425395 fixed the issue with user-written function literals
in a somewhat kludgy way; this CL extends the same solution to
synthetic function literals.

This is all quite subtle and the solutions aren't terribly robust, so
longer term it's probably desirable to revisit how we track inlining
context for positions. But for now, this seems to be the least bad
solution, esp. for backporting to 1.20.

Updates #54625.
Fixes #58531.

Change-Id: Icc43a70dbb11a0e665cbc9e6a64ef274ad8253d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/468415
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
(cherry picked from commit 873c14cec730ee278848f7cc58d2b4d89ab52288)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471677
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-28 00:07:00 +00:00
Than McIntosh
1362737f50 [release-branch.go1.20] cmd/link: better fix for arm32 trampgen problem with duff routines
This patch provides a fix for a problem linking large arm32 binaries
with external linking, specifically R_CALLARM relocations against
runtime.duff* routines being flagged by the external linker as not
reaching.

What appears to be happening in the bug in question is that the Go
linker and the external linker are using slightly different recipes to
decide whether a given R_CALLARM relocation will "fit" (e.g. will not
require a trampoline). The Go linker is taking into account the addend
on the call reloc (which for calls to runtime.duffcopy or
runtime.duffzero is nonzero), whereas the external linker appears to
be ignoring the addend.

Example to illustrate:

   Addr      Size   Func
   -----     -----  -----
   ...
   XYZ       1024   runtime.duffcopy
   ...
   ABC       ...    mypackge.MyFunc
     + R0: R_CALLARM  o=8 a=848 tgt=runtime.duffcopy<0>

Let's say that the distance between ABC (start address of
runtime.duffcopy) and XYZ (start of MyFunc) is just over the
architected 24-bit maximum displacement for an R_CALLARM (let's say
that ABC-XYZ is just over the architected limit by some small value,
say 36). Because we're calling into runtime.duffcopy at offset 848,
however, the relocation does in fact fit, but if the external linker
isn't taking into account the addend (assuming that all calls target
the first instruction of the called routine), then we'll get a
"doesn't fit" error from the linker.

To work around this problem, revise the ARM trampoline generation code
in the Go linker that computes the trampoline threshold to ignore the
addend on R_CALLARM relocations, so as to harmonize the two linkers.

Fixes #58503.
Updates #58428.
Updates #58425.

Change-Id: I56e580c05b7b47bbe8edf5532a1770bbd700fbe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/469275
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
(cherry picked from commit 0b5affb193)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471597
2023-02-27 19:59:34 +00:00
Filippo Valsorda
602eeaab38 [release-branch.go1.20] crypto/internal/nistec: reduce P-256 scalar
Unlike the rest of nistec, the P-256 assembly doesn't use complete
addition formulas, meaning that p256PointAdd[Affine]Asm won't return the
correct value if the two inputs are equal.

This was (undocumentedly) ignored in the scalar multiplication loops
because as long as the input point is not the identity and the scalar is
lower than the order of the group, the addition inputs can't be the same.

As part of the math/big rewrite, we went however from always reducing
the scalar to only checking its length, under the incorrect assumption
that the scalar multiplication loop didn't require reduction.

Added a reduction, and while at it added it in P256OrdInverse, too, to
enforce a universal reduction invariant on p256OrdElement values.

Note that if the input point is the infinity, the code currently still
relies on undefined behavior, but that's easily tested to behave
acceptably, and will be addressed in a future CL.

Updates #58647
Fixes #58720
Fixes CVE-2023-24532

(Filed with the "safe APIs like complete addition formulas are good" dept.)

Change-Id: I7b2c75238440e6852be2710fad66ff1fdc4e2b24
Reviewed-on: https://go-review.googlesource.com/c/go/+/471255
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 203e59ad41)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471695
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
2023-02-27 18:47:07 +00:00
Than McIntosh
ac556f35a2 [release-branch.go1.20] cmd/internal/cov: fix misuse of bufio.Reader.Read in read helper
Fix a misuse of bufio.Reader.Read in the helper class
cmd/internal/cov.MReader; the MReader method in question should have
been using io.ReadFull (passing the bufio.Reader) instead of directly
calling Read.

Using the Read method instead of io.ReadFull will result in a "short"
read when processing a specific subset of counter data files, e.g.
those that are short enough to not trigger the mmap-based scheme we
use for larger files, but also with a large args section (something
large enough to exceed the default 4k buffer size used by
bufio.Reader).

Along the way, add some additional defered Close() calls for files
opened by the CovDataReader.visitPod, to enure we don't leave any open
file descriptor following a call to CovDataReader.Visit.

Fixes #58427.
Updates #58411.

Change-Id: Iea48dc25c0081be1ade29f3a633df02a681fd941
Reviewed-on: https://go-review.googlesource.com/c/go/+/466677
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
(cherry picked from commit a7fe9ada10)
Reviewed-on: https://go-review.googlesource.com/c/go/+/468536
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-22 20:38:53 +00:00
Ian Lance Taylor
1acd39cc92 [release-branch.go1.20] Revert "internal/poll: drop redundant ENOSYS in CopyFileRange"
This reverts CL 428555.

Reason for revert: It appears that even a newer kernel can get
ENOSYS from copy_file_range.

For #58592
Fixes #58627

Change-Id: Ib8dd1be61544f54bf652a99dc0b449109f8f50ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/470316
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-22 20:35:23 +00:00
Michael Anthony Knyszek
7b398b1ff7 [release-branch.go1.20] runtime: check for overflow in sweep assist
The sweep assist computation is intentionally racy for performance,
since the specifics of sweep assist aren't super sensitive to error.
However, if overflow occurs when computing the live heap delta, we can
end up with a massive sweep target that causes the sweep assist to sweep
until sweep termination, causing severe latency issues. In fact, because
heapLive doesn't always increase monotonically then anything that
flushes mcaches will cause _all_ allocating goroutines to inevitably get
stuck in sweeping.

Consider the following scenario:
1. SetGCPercent is called, updating sweepHeapLiveBasis to heapLive.
2. Very shortly after, ReadMemStats is called, flushing mcaches and
   decreasing heapLive below the value sweepHeapLiveBasis was set to.
3. Every allocating goroutine goes to refill its mcache, calls into
   deductSweepCredit for sweep assist, and gets stuck sweeping until
   the sweep phase ends.

Fix this by just checking for overflow in the delta live heap calculation
and if it would overflow, pick a small delta live heap. This probably
means that no sweeping will happen at all, but that's OK. This is a
transient state and the runtime will recover as soon as heapLive
increases again.

Note that deductSweepCredit doesn't check overflow on other operations
but that's OK: those operations are signed and extremely unlikely to
overflow. The subtraction targeted by this CL is only a problem because
it's unsigned. An alternative fix would be to make the operation signed,
but being explicit about the overflow situation seems worthwhile.

For #57523.
Fixes #58536.

Change-Id: Ib18f71f53468e913548aac6e5358830c72ef0215
Reviewed-on: https://go-review.googlesource.com/c/go/+/468375
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-15 21:52:31 +00:00
Cuong Manh Le
2d01f3695b [release-branch.go1.20] cmd/compile: fix wrong escape analysis for go/defer generic calls
For go/defer calls like "defer f(x, y)", the compiler rewrites it to:

	x1, y1 := x, y
	defer func() { f(x1, y1) }()

However, if "f" needs runtime type information, the "RType" field will
refer to the outer ".dict" param, causing wrong liveness analysis.

To fix this, if "f" refers to outer ".dict", the dict param will be
copied to an autotmp, and "f" will refer to this autotmp instead.

Fixes #58467

Change-Id: I238b6e75441442b5540d39bc818205398e80c94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466035
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/467935
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-02-15 21:46:55 +00:00
Cuong Manh Le
965e9ba0fb [release-branch.go1.20] cmd/compile: disable inline static init optimization
There are a plenty of regression in 1.20 with this optimization. This CL
disable inline static init, so it's safer to backport to 1.20 branch.

The optimization will be enabled again during 1.21 cycle.

Fixes #58444

Change-Id: If5916008597b46146b4dc7108c6b389d53f35e95
Reviewed-on: https://go-review.googlesource.com/c/go/+/467015
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/467035
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-02-15 21:45:58 +00:00
Adin Scannell
85ded85b78 [release-branch.go1.20] runtime: fix signature for linked functions
These functions are linked using go:linkname, but do not match the
original declarations. This change brings these in sync.

For #58442.

Change-Id: I16651304c3dba2f9897c2c42e30555d2f7805c2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466615
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 8fb9565832)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466859
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2023-02-15 21:45:24 +00:00
Michael Pratt
828b05cc64 [release-branch.go1.20] all: update vendored golang.org/x/net
Update golang.org/x/net to the tip of internal-branch.go1.20-vendor to
include CL 468336.

The contents of that CL were already merged into this branch in CL
468122, so this CL just brings go.mod back in line to matching the
actual vendored content.

For #58356
For #57855

Change-Id: I6ee9483077630c11c725927f38f6b69a784106db
Reviewed-on: https://go-review.googlesource.com/c/go/+/468302
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2023-02-14 20:55:09 +00:00
Gopher Robot
202a1a5706 [release-branch.go1.20] go1.20.1
Change-Id: I6a40cdd44d7bc7e4bf95a5169ecad16757eb41d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/468238
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-14 18:12:19 +00:00
Roland Shoemaker
8e02cffd8e [release-branch.go1.20] net/http: update bundled golang.org/x/net/http2
Disable cmd/internal/moddeps test, since this update includes PRIVATE
track fixes.

Fixes CVE-2022-41723
Fixes #58356
Updates #57855

Change-Id: I603886b5b76c16303dab1420d4ec8b7c7cdcf330
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728940
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468122
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-14 17:25:55 +00:00
Roland Shoemaker
5286ac4ed8 [release-branch.go1.20] crypto/tls: replace all usages of BytesOrPanic
Message marshalling makes use of BytesOrPanic a lot, under the
assumption that it will never panic. This assumption was incorrect, and
specifically crafted handshakes could trigger panics. Rather than just
surgically replacing the usages of BytesOrPanic in paths that could
panic, replace all usages of it with proper error returns in case there
are other ways of triggering panics which we didn't find.

In one specific case, the tree routed by expandLabel, we replace the
usage of BytesOrPanic, but retain a panic. This function already
explicitly panicked elsewhere, and returning an error from it becomes
rather painful because it requires changing a large number of APIs.
The marshalling is unlikely to ever panic, as the inputs are all either
fixed length, or already limited to the sizes required. If it were to
panic, it'd likely only be during development. A close inspection shows
no paths for a user to cause a panic currently.

This patches ends up being rather large, since it requires routing
errors back through functions which previously had no error returns.
Where possible I've tried to use helpers that reduce the verbosity
of frequently repeated stanzas, and to make the diffs as minimal as
possible.

Thanks to Marten Seemann for reporting this issue.

Updates #58001
Fixes #58359
Fixes CVE-2022-41724

Change-Id: Ieb55867ef0a3e1e867b33f09421932510cb58851
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1679436
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 1d4e6ca9454f6cf81d30c5361146fb5988f1b5f6)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728205
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468121
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2023-02-14 17:25:50 +00:00
Damien Neil
53b43607d9 [release-branch.go1.20] mime/multipart: limit memory/inode consumption of ReadForm
Reader.ReadForm is documented as storing "up to maxMemory bytes + 10MB"
in memory. Parsed forms can consume substantially more memory than
this limit, since ReadForm does not account for map entry overhead
and MIME headers.

In addition, while the amount of disk memory consumed by ReadForm can
be constrained by limiting the size of the parsed input, ReadForm will
create one temporary file per form part stored on disk, potentially
consuming a large number of inodes.

Update ReadForm's memory accounting to include part names,
MIME headers, and map entry overhead.

Update ReadForm to store all on-disk file parts in a single
temporary file.

Files returned by FileHeader.Open are documented as having a concrete
type of *os.File when a file is stored on disk. The change to use a
single temporary file for all parts means that this is no longer the
case when a form contains more than a single file part stored on disk.

The previous behavior of storing each file part in a separate disk
file may be reenabled with GODEBUG=multipartfiles=distinct.

Update Reader.NextPart and Reader.NextRawPart to set a 10MiB cap
on the size of MIME headers.

Thanks to Jakob Ackermann (@das7pad) for reporting this issue.

Updates #58006
Fixes #58363
Fixes CVE-2022-41725

Change-Id: Ibd780a6c4c83ac8bcfd3cbe344f042e9940f2eab
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1714276
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
(cherry picked from commit 7d0da0029bfbe3228cc5216ced8c7b3184eb517d)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728950
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468120
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-14 16:58:51 +00:00
Damien Neil
bdf07c2e16 [release-branch.go1.20] path/filepath: do not Clean("a/../c:/b") into c:\b on Windows
Do not permit Clean to convert a relative path into one starting
with a drive reference. This change causes Clean to insert a .
path element at the start of a path when the original path does not
start with a volume name, and the first path element would contain
a colon.

This may introduce a spurious but harmless . path element under
some circumstances. For example, Clean("a/../b:/../c") becomes `.\c`.

This reverts CL 401595, since the change here supersedes the one
in that CL.

Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue.

Updates #57274
Fixes #57276
Fixes CVE-2022-41722

Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
(cherry picked from commit 8ca37f4813ef2f64600c92b83f17c9f3ca6c03a5)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728944
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468119
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
2023-02-14 16:58:49 +00:00
Frederic Branczyk
3a04b6e12e [release-branch.go1.20] cmd/compile/internal/pgo: fix hard-coded PGO sample data position
This patch detects at which index position profiling samples that have
the value-type samples count are, instead of the previously hard-coded
position of index 1. Runtime generated profiles always generate CPU
profiling data with the 0 index being CPU nanoseconds, and samples count
at index 1, which is why this previously hasn't come up.

This is a redo of CL 465135, now allowing empty profiles. Note that
preprocessProfileGraph will already cause pgo.New to return nil for
empty profiles.

For #58292
For #58309

Change-Id: Ia6c94f0793f6ca9b0882b5e2c4d34f38e600c1e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/467375
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2023-02-10 19:24:45 +00:00
Bryan C. Mills
00f5d3001a [release-branch.go1.20] cmd/go/internal/script: retry ETXTBSY errors in scripts
Fixes #58431.
Updates #58019.

Change-Id: Ib25d668bfede6e87a3786f44bdc0db1027e3ebec
Reviewed-on: https://go-review.googlesource.com/c/go/+/463748
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 23c0121e4e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466856
Reviewed-by: David Chase <drchase@google.com>
2023-02-10 17:48:14 +00:00
Bryan C. Mills
7628627cb2 [release-branch.go1.20] cmd/go/internal/test: refresh flagdefs.go and fix test
The tests for cmd/go/internal/test were not running at all due to a
missed call to m.Run in TestMain. That masked a missing vet analyzer
("timeformat") and a missed update to the generator script in
CL 355452.

Fixes #58421.
Updates #58415.

Change-Id: I7b0315952967ca07a866cdaa5903478b2873eb7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466635
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>
(cherry picked from commit 910f041ff0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466855
2023-02-10 17:41:09 +00:00
Bryan C. Mills
1fa2deb1b1 [release-branch.go1.20] cmd/go: remove tests that assume lack of new versions of external modules
In general it seems ok to assume that an open-source module that did
exist will continue to do so — after all, users of open-source modules
already do that all the time. However, we should not assume that those
modules do not publish new versions — that's really up to their
maintainers to decide.

Two existing tests did make that assumption for the module
gopkg.in/natefinch/lumberjack.v2. Let's remove those two tests.
If we need to replace them at some point, we can replace them with
hermetic test-only modules (#54503) or perhaps modules owned by the Go
project.

Updates #58445.
Fixes #58450.

Change-Id: Ica8fe587d86fc41f3d8445a4cd2b8820455ae45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/466861
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-02-10 17:29:40 +00:00
Russ Cox
a943fd0ccc [release-branch.go1.20] runtime: skip darwin osinit_hack on ios
Darwin needs the osinit_hack call to fix some bugs in the Apple libc
that surface when Go programs call exec. On iOS, the functions that
osinit_hack uses are not available, so signing fails. But on iOS exec
is also unavailable, so the hack is not needed. Disable it there,
which makes signing work again.

Fixes #58323.
Fixes #58419.

Change-Id: I3f1472f852bb36c06854fe1f14aa27ad450c5945
Reviewed-on: https://go-review.googlesource.com/c/go/+/466516
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dave Anderson <danderson@tailscale.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/467316
2023-02-10 17:19:24 +00:00
Russ Cox
fbba58a0a4 [release-branch.go1.20] cmd/link: keep go.buildinfo even with --gc-sections
If you use an external linker with --gc-sections, nothing refers
to .go.buildinfo, so the section is deleted, which in turns makes
'go version' fail on the binary. It is important for vulnerability
scanning and the like to be able to run 'go version' on any binary.

Fix this by inserting a reference to .go.buildinfo from the rodata
section, which will not be GC'ed.

Fixes #58222.
Fixes #58224.

Change-Id: I1e13e9464acaf2f5cc5e0b70476fa52b43651123
Reviewed-on: https://go-review.googlesource.com/c/go/+/464435
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/464796
2023-02-10 17:19:20 +00:00
qmuntal
9987cb6cf3 [release-branch.go1.20] time: update windows zoneinfo_abbrs
zoneinfo_abbrs hasn't been updated since go 1.14, it's time to
regenerate it.

Fixes #58117.

Change-Id: Ic156ae607c46f1f5a9408b1fc0b56de6c14a4ed4
Reviewed-on: https://go-review.googlesource.com/c/go/+/463838
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 007d8f4db1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466436
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
2023-02-09 18:01:32 +00:00
Matthew Dempsky
90b06002c4 [release-branch.go1.20] cmd/compile/internal/noder: stop creating TUNION types
In the types1 universe under the unified frontend, we never need to
worry about type parameter constraints, so we only see pure
interfaces. However, we might still see interfaces that contain union
types, because of interfaces like "interface{ any | int }" (equivalent
to just "any").

We can handle these without needing to actually represent type unions
within types1 by simply mapping any union to "any".

Fixes #58413.

Change-Id: I5e4efcf0339edbb01f4035c54fb6fb1f9ddc0c65
Reviewed-on: https://go-review.googlesource.com/c/go/+/458619
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit a7de684e1b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/466435
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
2023-02-09 18:01:12 +00:00
Cuong Manh Le
487be3f90b [release-branch.go1.20] cmd/compile: fix inline static init arguments substitued tree
Blank node must be ignored when building arguments substitued tree.
Otherwise, it could be used to replace other blank node in left hand
side of an assignment, causing an invalid IR node.

Consider the following code:

	type S1 struct {
		s2 S2
	}

	type S2 struct{}

	func (S2) Make() S2 {
		return S2{}
	}

	func (S1) Make() S1 {
		return S1{s2: S2{}.Make()}
	}

	var _ = S1{}.Make()

After staticAssignInlinedCall, the assignment becomes:

	var _ = S1{s2: S2{}.Make()}

and the arg substitued tree is "map[*ir.Name]ir.Node{_: S1{}}". Now,
when doing static assignment, if there is any assignment to blank node,
for example:

	_ := S2{}

That blank node will be replaced with "S1{}":

	S1{} := S2{}

So constructing an invalid IR which causes the ICE.

Fixes #58335

Change-Id: I21b48357f669a7e02a7eb4325246aadc31f78fb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/465098
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/466275
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-09 17:29:22 +00:00
Cuong Manh Le
7302f83d87 [release-branch.go1.20] cmd/compile: remove constant arithmetic overflows during typecheck
Since go1.19, these errors are already reported by types2 for any user's
Go code. Compiler generated code, which looks like constant expression
should be evaluated as non-constant semantic, which allows overflows.

Fixes #58319

Change-Id: I6f0049a69bdb0a8d0d7a0db49c7badaa92598ea2
Reviewed-on: https://go-review.googlesource.com/c/go/+/466676
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-02-09 17:09:03 +00:00
Gopher Robot
de4748c47c [release-branch.go1.20] go1.20
Change-Id: I156873d216ccb7d91e716b4348069df246b527b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/464496
Run-TryBot: Gopher Robot <gobot@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-02-01 19:03:46 +00:00
Than McIntosh
52bd3b186b [release-branch.go1.20] internal/coverage/decodemeta: fix coding error in func literal handling
Fix a coding error in coverage meta-data decoding in the method
decodemeta.CoverageMetaDataDecoder.ReadFunc. The code was not
unconditionally assigning the "function literal" field of the
coverage.FuncDesc object passed in, resulting in bad values depending
on what the state of the field happened to be in the object.

Fixes #57942.

Change-Id: I6dfd7d7f7af6004f05c622f9a7116e9f6018cf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/462955
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 620399ef0d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/463418
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-01-26 23:27:53 +00:00
Than McIntosh
be7e4fee4b [release-branch.go1.20] runtime/coverage: avoid non-test coverage profiles in test report helper
When walking through the set of coverage data files generated from a
"go test -cover" run, it's possible to encounter pods (clumps of data
files) that were generated by a run from an instrumented Go tool (for
example, cmd/compile). Add a guard to the test reporting code to
ensure that it only processes files created by the currently running
test.

Fixes #57924.

Change-Id: I1bb7dce88305e1088162e3cb1df628486ecee1c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/462756
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
(cherry picked from commit cf70d37967)
Reviewed-on: https://go-review.googlesource.com/c/go/+/463417
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-01-26 23:27:43 +00:00
Changkun Ou
b68d699aa7 [release-branch.go1.20] sync: document memory model for Swap/CompareAnd{Swap,Delete} in Map
CL 381316 documented the memory model of Map's APIs. However, the newly
introduced Swap, CompareAndSwap, and CompareAndDelete are missing from
this documentation as CL 399094 did not add this info.

This CL specifies the defined read/write operations of the new Map APIs.

For #51972

Change-Id: I519a04040a0b429a3f978823a183cd62e42c90ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/459715
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Changkun Ou <mail@changkun.de>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit f07910bd57)
Reviewed-on: https://go-review.googlesource.com/c/go/+/463416
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Changkun Ou <mail@changkun.de>
2023-01-25 19:53:59 +00:00
Keith Randall
10124c2631 [release-branch.go1.20] Revert "cmd/compile: teach prove about bitwise OR operation"
This reverts commit 3680b5e9c4.

Reason for revert: causes long compile times on certain functions. See issue #57959

Change-Id: Ie9e881ca8abbc79a46de2bfeaed0b9d6c416ed42
Reviewed-on: https://go-review.googlesource.com/c/go/+/463295
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
(cherry picked from commit a6ddb15f8f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/463415
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-01-25 18:41:55 +00:00
Joe Tsai
5adb0ca8e9 [release-branch.go1.20] time: revert strict parsing of RFC 3339
CL 444277 fixed Time.UnmarshalText and Time.UnmarshalJSON to properly
unmarshal timestamps according to RFC 3339 instead of according
to Go's bespoke time syntax that is a superset of RFC 3339.

However, this change seems to have broken an AWS S3 unit test
that relies on parsing timestamps with single digit hours.
It is unclear whether S3 emits these timestamps in production or
whether this is simply a testing artifact that has been cargo culted
across many code bases. Either way, disable strict parsing for now
and re-enable later with better GODEBUG support.

Updates #54580

Change-Id: Icced2c7f9a6b2fc06bbd9c7e90f90edce24c2306
Reviewed-on: https://go-review.googlesource.com/c/go/+/462286
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/462675
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-18 20:42:20 +00:00
Russ Cox
8b34676710 [release-branch.go1.20] cmd: update x/tools to latest internal Go 1.20 branch
Import x/tools as of CL 462596 (070db2996ebe, Jan 18 2022),
to bring in two vet analysis fixes (printf and loopclosure).

For #57911.
Fixes #57903.
Fixes #57904.

Change-Id: I82fe4e9bd56fb8e64394ee8618c155316942a517
Reviewed-on: https://go-review.googlesource.com/c/go/+/462555
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/462695
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-18 20:41:57 +00:00
Cuong Manh Le
d7c6da8bac [release-branch.go1.20] cmd/compile: fix unsafe.{SliceData,StringData} escape analysis memory corruption
Updates #57823
Updates #57854

Change-Id: I54654d3ecb20b75afa9052c5c9db2072a86188d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/461759
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/461760
2023-01-18 18:32:01 +00:00
Matthew Dempsky
9eed826bf9 [release-branch.go1.20] cmd/compile: fix static init inlining for hidden node fields
Unified IR added several new IR fields for holding *runtime._type
expressions. To avoid throwing off any frontend semantics
(particularly inlining cost heuristics), they were marked as
`mknode:"-"` so that code wouldn't visit them.

Unfortunately, this has a bad interaction with the static init
inlining optimization, because the latter relies on ir.EditChildren to
substitute all parameters. This potentially includes dictionary
parameters, which can appear within the new RType fields.

This CL adds a new ir.EditChildrenWithHidden function that also edits
these fields, and switches staticinit to use it. Longer term, we
should unhide the RType fields so that ir.EditChildren visits them
normally, but that's scarier so late in the release cycle.

Updates #57778.
Updates #57854.

Change-Id: I98c1e8cf366156dc0c81a0cb79029cc5e59c476f
Reviewed-on: https://go-review.googlesource.com/c/go/+/461686
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 9f2fbedf010d59c3ecaa8c25b07a5f68fcb2e3d5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/462535
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-17 23:46:00 +00:00
Cherry Mui
670ce9b8a8 [release-branch.go1.20] all: merge master (9088c69) into release-branch.go1.20
Merge List:

+ 2023-01-17 9088c691da cmd/compile: ensure temp register mask isn't empty
+ 2023-01-17 c0799f7015 os: document that Rename is not atomic on non-Unix platforms
+ 2023-01-17 d74c31f0ba doc/go1.20: update cryptography release notes
+ 2023-01-17 8e19929436 strings: remove redundant symbols
+ 2023-01-17 6cb8c43b84 cmd/go: include coverage build flags for "go list"
+ 2023-01-17 02ed0e5e67 crypto/ed25519: improve Ed25519ctx docs and add example
+ 2023-01-17 f375b305c8 crypto/x509: clarify that CheckSignatureFrom and CheckSignature are low-level APIs
+ 2023-01-17 8409251e10 cmd/go: document GODEBUG=installgoroot=all
+ 2023-01-17 66689c7d46 doc/go1.20: remove mention of arena goexperiment
+ 2023-01-17 145dd38471 archive/tar, archive/zip: document ErrInsecurePath and GODEBUG setting
+ 2023-01-16 1c65b69bd1 runtime: fix performance regression in morestack_noctxt on ppc64
+ 2023-01-13 ebb572d82f Revert "internal/fsys: follow root symlink in fsys.Walk"
+ 2023-01-13 16cec4e7a0 doc/go1.20: mention build speed improvements
+ 2023-01-13 643f463186 cmd/cover: remove go.mod from testdata subdir

Change-Id: I4d56c9353d423f7e7169db7e30cb59515d422a56
2023-01-17 13:45:09 -05:00
Gopher Robot
b3160e8bce [release-branch.go1.20] go1.20rc3
Change-Id: I87007947c075e8b90dd74bdf164b59e81487f6de
Reviewed-on: https://go-review.googlesource.com/c/go/+/461836
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Gopher Robot <gobot@golang.org>
2023-01-12 17:16:08 +00:00
Carlos Amedee
9efc2e7f95 [release-branch.go1.20] all: merge master (245e95d) into release-branch.go1.20
Merge List:

+ 2023-01-11 245e95dfab go/types, types2: don't look up fields or methods when expecting a type
+ 2023-01-11 18625d9bec runtime: fix incorrect comment
+ 2023-01-11 6ad27161f8 cmd/compile: better error message for when a type is in a constraint but not the type set
+ 2023-01-10 76d39ae349 cmd/link, runtime: Apple libc atfork workaround take 3
+ 2023-01-10 0a0de0fc42 runtime: revert use of __fork to work around Apple atfork bugs
+ 2023-01-10 82f09b75ca os/exec: avoid leaking an exec.Cmd in TestWaitInterrupt
+ 2023-01-09 0202ad0b3a cmd/compile: prevent IsNewObject from taking quadratic time
+ 2023-01-09 64519baf38 cmd/compile/internal/pgo: add hint to missing start_line error
+ 2023-01-09 376076f3c6 runtime: skip TestCgoPprofCallback in short mode, don't run in parallel
+ 2023-01-09 0bbd67e52f runtime/pprof: document possibility of empty stacks
+ 2023-01-09 d9f23cfe78 runtime/pprof: improve output of TestLabelSystemstack
+ 2023-01-09 8232a09e3e sync/atomic: fix the note of atomic.Store
+ 2023-01-09 841c3eb166 all: fix typos in go file comments
+ 2023-01-06 f721fa3be9 syscall: skip TestUseCgroupFD if cgroupfs not mounted
+ 2023-01-06 76ec919237 net: fix typo in hosts.go
+ 2023-01-06 660d4815ea cmd/compile: describe how Go maps to wasm implementation
+ 2023-01-05 119f679a3b crypto/tls: fix typo in cacheEntry godoc
+ 2023-01-05 d50ea217f6 cmd/cover: fix problems with "go test -covermode=atomic sync/atomic"
+ 2023-01-04 bae7d772e8 doc/go1.20: fix links to new strings functions
+ 2023-01-04 4e7c838483 crypto/internal/boring: add dev.boringcrypto README.md text
+ 2023-01-04 46e3d9d12a cmd/compile: use "satisfies" (not "implements") for constraint errors
+ 2023-01-04 79cdecc852 cmd/gofmt: fix a typo in a comment
+ 2023-01-03 9955a7e9bb README.vendor: minor updates
+ 2023-01-03 d03231d9ce doc/go1.20: fix http.ResponseController example
+ 2023-01-03 cdc73f0679 .github: suggest using private browsing in pkgsite template

Change-Id: I73be496aa4163ad1d3a6cc8114f1a612968d4b10
2023-01-11 18:01:18 -05:00
Gopher Robot
32593a9192 [release-branch.go1.20] go1.20rc2
Change-Id: Ieb30cc96008bd705677e44983c68d4581706cc05
Reviewed-on: https://go-review.googlesource.com/c/go/+/460498
Auto-Submit: Gopher Robot <gobot@golang.org>
Run-TryBot: Gopher Robot <gobot@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-01-04 16:02:35 +00:00
Heschi Kreinick
eb598248ba [release-branch.go1.20] all: merge master (db36eca) into release-branch.go1.20
Merge List:

+ 2022-12-29 db36eca33c doc/go1.20: fix typos
+ 2022-12-29 642fd5f7ce go/types, types2: use strict comparability for type set intersection
+ 2022-12-28 9123221ccf misc/cgo/testsanitizers: run libfuzzer tests in temp directory
+ 2022-12-27 e870de9936 misc/cgo/testsanitizers: add libfuzzer tests
+ 2022-12-23 38cfb3be9d testing: rephrase the sentence about naming test files
+ 2022-12-23 1ba7341cb2 cmd/link, runtime: use a different section for Go libfuzzer counters
+ 2022-12-22 c61d322d5f runtime: call __fork instead of fork on darwin
+ 2022-12-22 6c9b661867 runtime: revert Apple libc atfork workaround
+ 2022-12-22 6d3139b203 misc/cgo/testshared: test build std in shared mode
+ 2022-12-22 de6abd7889 runtime/internal/startlinetest: work around shared buildmode linking issue
+ 2022-12-22 18baca6765 runtime/race: add build tag to internal amd64vN packages
+ 2022-12-22 13ed4f42f0 doc/go1.20: fix typo
+ 2022-12-21 fadd77c05b runtime/coverage: add missing file close in test support helper
+ 2022-12-21 c9a10d48a8 crypto/x509: return typed verification errors on macOS
+ 2022-12-21 2321abc5e9 archive/tar, archive/zip: revert documentation of ErrInsecurePath
+ 2022-12-21 458241f981 net/http/httputil: don't add X-Forwarded-{Host,Proto} after invoking Director funcs
+ 2022-12-21 58f6022eee syscall: don't use faccessat2 on android
+ 2022-12-21 78fc81070a net: use correct dns msg size
+ 2022-12-19 a5a4744250 os: reenable TestReaddirSmallSeek on windows
+ 2022-12-17 0b2ad1d815 cmd/compile: sign-extend the 2nd argument of the LoweredAtomicCas32 on loong64,mips64x,riscv64
+ 2022-12-16 8bcc490667 os/user,net: add -fno-stack-protector to CFLAGS
+ 2022-12-16 f4b42f5cb8 net/http: improve errors in TestCancelRequestWhenSharingConnection
+ 2022-12-16 24ac659a39 syscall, internal/poll: fall back to accept on linux-arm
+ 2022-12-16 3323dab1f4 os/exec: retry ETXTBSY errors in TestFindExecutableVsNoexec
+ 2022-12-15 628a1e7d3a doc/go1.20: fix typo
+ 2022-12-15 357ea85892 spec: fix typo
+ 2022-12-14 ea14d1b6e1 spec: document which recursive arrays and structs are valid/invalid
+ 2022-12-14 0b8add46ce doc/go1.20.html: pre-announce dropping Windows 7, 8, and friends
+ 2022-12-14 4f8bc6224b cmd/compile: desugar OCALLMETH->OCALLFUNC within devirtualization
+ 2022-12-14 5c682f94c6 spec: document illegal recursive type parameter lists
+ 2022-12-14 bd42aa86d3 spec: describe new semantics for comparable and constraint satisfaction
+ 2022-12-14 ffefcd360b spec: introduce notion of strict comparability
+ 2022-12-13 cb07765045 syscall: fix closing of reordered FDs in plan9 ForkExec
+ 2022-12-13 5ba98b9756 go/types, types2: report type mismatch error when conversion is impossible
+ 2022-12-13 61e2b8ec59 cmd/gc: test temp string comparison with all ops
+ 2022-12-12 b16e94d13d syscall: skip TestUseCgroupFD if cgroupfs mounted RO
+ 2022-12-12 27301e8247 syscall: fix shadowing bugs in forkAndExecInChild
+ 2022-12-12 6f7a95d25e sync: remove unused const
+ 2022-12-12 6b895d9eaa doc/go1.20: fix typo
+ 2022-12-12 c6ad9dc9b5 debug/buildinfo: check pointer size on buildinfo.Read
+ 2022-12-12 5dca7ed66f doc/go1.20: fix URL anchor
+ 2022-12-11 888047c310 cmd/compile: fix conditional move rule on PPC64
+ 2022-12-10 9b8750f53e os: skip size test in TestLstat if the file is a symlink
+ 2022-12-09 e8f78cb60c cmd/compile: fix conditional select rule
+ 2022-12-09 e76c87b191 doc: fix typo in 1.20 release notes
+ 2022-12-09 80f7484af7 os/user: zero-initialize C structs returned to Go
+ 2022-12-08 e738a2f19b go/types, types2: always rename type parameters during inference
+ 2022-12-08 8247b9f17a doc: fix typo
+ 2022-12-08 f368abb46e doc/go1.20: correct test binary -v flag value for test2json
+ 2022-12-08 7973b0e508 cmd/{go,cover,covdata}: fix 'package main' inconsistent handling
+ 2022-12-08 0aad4d3257 cmd/link: fix dynamic interpreter path for musl-based linux amd64
+ 2022-12-08 eaf0e3d465 runtime: remove arbitrary timeouts in finalizer tests
+ 2022-12-08 c8313d4fa8 cmd/go: deflake TestScript/test2json_interrupt
+ 2022-12-08 b9747e0e6b os/user: on AIX getpwuid_r seems to return -1 on overflow
+ 2022-12-07 9431237d77 internal/safefilepath: fix TestFromFS on Plan 9
+ 2022-12-07 7c7cd56870 cmd/go: in TestTerminalPassthrough, delay subprocess exit until the PTY has been read

Change-Id: I037343df0fe5b171b5f5726fcc55c01108d2563e
2023-01-03 12:21:39 -05:00
Gopher Robot
9f02342144 [release-branch.go1.20] go1.20rc1
Change-Id: I26470f8bcd902f9e1c7877763e360cb3c6255f3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/456096
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2022-12-07 22:00:46 +00:00
Michael Pratt
0480336414 [release-branch.go1.20] update codereview.cfg for release-branch.go1.20
Following go.dev/cl/334376.

Change-Id: I96be6379566b5bcc31e41bdd5f30946b06001153
Reviewed-on: https://go-review.googlesource.com/c/go/+/455896
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-12-07 18:00:33 +00:00
3612 changed files with 100331 additions and 175696 deletions

2
.github/SUPPORT.md vendored
View File

@@ -1,5 +1,5 @@
Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions.
We only use our bug tracker for tracking bugs and tracking proposals going through the [Proposal Process](https://go.dev/s/proposal-process).
We only use our bug tracker for tracking bugs and tracking proposals going through the [Proposal Process](https://golang.org/s/proposal-process).
For asking questions, see:

2
.gitignore vendored
View File

@@ -33,13 +33,13 @@ _testmain.go
/src/cmd/cgo/zdefaultcc.go
/src/cmd/dist/dist
/src/cmd/go/internal/cfg/zdefaultcc.go
/src/cmd/go/internal/cfg/zosarch.go
/src/cmd/internal/objabi/zbootstrap.go
/src/go/build/zcgo.go
/src/go/doc/headscan
/src/internal/buildcfg/zbootstrap.go
/src/runtime/internal/sys/zversion.go
/src/unicode/maketables
/src/time/tzdata/zzipdata.go
/test.out
/test/garbage/*.out
/test/pass.out

View File

@@ -24,7 +24,7 @@ Otherwise, when filing an issue, make sure to answer these five questions:
4. What did you expect to see?
5. What did you see instead?
For change proposals, see [Proposing Changes To Go](https://go.dev/s/proposal-process).
For change proposals, see [Proposing Changes To Go](https://github.com/golang/proposal/).
## Contributing code

1
VERSION Normal file
View File

@@ -0,0 +1 @@
go1.20.4

View File

@@ -1,4 +1,3 @@
pkg crypto/tls, type ConnectionState struct, TLSUnique //deprecated
pkg debug/elf, const R_PPC64_SECTOFF_LO_DS = 61
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
pkg math, const MaxFloat64 = 1.79769e+308 // 179769313486231570814527423731704356798100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@@ -502,7 +501,6 @@ pkg text/template/parse, type Node interface { Copy, String, Type }
pkg unicode, const Version = "10.0.0"
pkg unicode, const Version = "11.0.0"
pkg unicode, const Version = "12.0.0"
pkg unicode, const Version = "13.0.0"
pkg unicode, const Version = "6.2.0"
pkg unicode, const Version = "6.3.0"
pkg unicode, const Version = "7.0.0"
@@ -576,25 +574,3 @@ pkg syscall (freebsd-arm-cgo), const SYS_MKNODAT = 498
pkg syscall (freebsd-arm-cgo), const SYS_STAT = 188
pkg syscall (freebsd-arm-cgo), const SYS_STAT ideal-int
pkg syscall (freebsd-arm-cgo), const SYS_STATFS = 396
pkg syscall (freebsd-arm64), const SYS_FSTAT = 189
pkg syscall (freebsd-arm64), const SYS_FSTATAT = 493
pkg syscall (freebsd-arm64), const SYS_FSTATFS = 397
pkg syscall (freebsd-arm64), const SYS_GETDIRENTRIES = 196
pkg syscall (freebsd-arm64), const SYS_GETFSSTAT = 395
pkg syscall (freebsd-arm64), const SYS_LSTAT = 190
pkg syscall (freebsd-arm64), const SYS_LSTAT ideal-int
pkg syscall (freebsd-arm64), const SYS_MKNODAT = 498
pkg syscall (freebsd-arm64), const SYS_STAT = 188
pkg syscall (freebsd-arm64), const SYS_STAT ideal-int
pkg syscall (freebsd-arm64), const SYS_STATFS = 396
pkg syscall (freebsd-arm64-cgo), const SYS_FSTAT = 189
pkg syscall (freebsd-arm64-cgo), const SYS_FSTATAT = 493
pkg syscall (freebsd-arm64-cgo), const SYS_FSTATFS = 397
pkg syscall (freebsd-arm64-cgo), const SYS_GETDIRENTRIES = 196
pkg syscall (freebsd-arm64-cgo), const SYS_GETFSSTAT = 395
pkg syscall (freebsd-arm64-cgo), const SYS_LSTAT = 190
pkg syscall (freebsd-arm64-cgo), const SYS_LSTAT ideal-int
pkg syscall (freebsd-arm64-cgo), const SYS_MKNODAT = 498
pkg syscall (freebsd-arm64-cgo), const SYS_STAT = 188
pkg syscall (freebsd-arm64-cgo), const SYS_STAT ideal-int
pkg syscall (freebsd-arm64-cgo), const SYS_STATFS = 396

File diff suppressed because it is too large Load Diff

View File

@@ -93,12 +93,6 @@ pkg math (freebsd-arm), const MinInt = -2147483648
pkg math (freebsd-arm-cgo), const MaxInt = 2147483647
pkg math (freebsd-arm-cgo), const MaxUint = 4294967295
pkg math (freebsd-arm-cgo), const MinInt = -2147483648
pkg math (freebsd-arm64), const MaxInt = 9223372036854775807
pkg math (freebsd-arm64), const MaxUint = 18446744073709551615
pkg math (freebsd-arm64), const MinInt = -9223372036854775808
pkg math (freebsd-arm64-cgo), const MaxInt = 9223372036854775807
pkg math (freebsd-arm64-cgo), const MaxUint = 18446744073709551615
pkg math (freebsd-arm64-cgo), const MinInt = -9223372036854775808
pkg math (linux-386), const MaxInt = 2147483647
pkg math (linux-386), const MaxUint = 4294967295
pkg math (linux-386), const MinInt = -2147483648
@@ -195,10 +189,6 @@ pkg runtime/cgo (freebsd-arm-cgo), func NewHandle(interface{}) Handle
pkg runtime/cgo (freebsd-arm-cgo), method (Handle) Delete()
pkg runtime/cgo (freebsd-arm-cgo), method (Handle) Value() interface{}
pkg runtime/cgo (freebsd-arm-cgo), type Handle uintptr
pkg runtime/cgo (freebsd-arm64-cgo), func NewHandle(interface{}) Handle
pkg runtime/cgo (freebsd-arm64-cgo), method (Handle) Delete()
pkg runtime/cgo (freebsd-arm64-cgo), method (Handle) Value() interface{}
pkg runtime/cgo (freebsd-arm64-cgo), type Handle uintptr
pkg runtime/cgo (linux-386-cgo), func NewHandle(interface{}) Handle
pkg runtime/cgo (linux-386-cgo), method (Handle) Delete()
pkg runtime/cgo (linux-386-cgo), method (Handle) Value() interface{}

View File

@@ -189,8 +189,6 @@ pkg syscall (freebsd-amd64), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (freebsd-amd64-cgo), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (freebsd-arm), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (freebsd-arm-cgo), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (freebsd-arm64), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (freebsd-arm64-cgo), type SysProcAttr struct, Pdeathsig Signal
pkg syscall (windows-386), func Syscall //deprecated
pkg syscall (windows-386), func Syscall12 //deprecated
pkg syscall (windows-386), func Syscall15 //deprecated

File diff suppressed because it is too large Load Diff

View File

@@ -1,421 +0,0 @@
pkg bytes, func ContainsFunc([]uint8, func(int32) bool) bool #54386
pkg bytes, method (*Buffer) AvailableBuffer() []uint8 #53685
pkg bytes, method (*Buffer) Available() int #53685
pkg cmp, func Compare[$0 Ordered]($0, $0) int #59488
pkg cmp, func Less[$0 Ordered]($0, $0) bool #59488
pkg cmp, type Ordered interface {} #59488
pkg context, func AfterFunc(Context, func()) func() bool #57928
pkg context, func WithDeadlineCause(Context, time.Time, error) (Context, CancelFunc) #56661
pkg context, func WithoutCancel(Context) Context #40221
pkg context, func WithTimeoutCause(Context, time.Duration, error) (Context, CancelFunc) #56661
pkg crypto/elliptic, func GenerateKey //deprecated #52221
pkg crypto/elliptic, func Marshal //deprecated #52221
pkg crypto/elliptic, func Unmarshal //deprecated #52221
pkg crypto/elliptic, method (*CurveParams) Add //deprecated #34648
pkg crypto/elliptic, method (*CurveParams) Double //deprecated #34648
pkg crypto/elliptic, method (*CurveParams) IsOnCurve //deprecated #34648
pkg crypto/elliptic, method (*CurveParams) ScalarBaseMult //deprecated #34648
pkg crypto/elliptic, method (*CurveParams) ScalarMult //deprecated #34648
pkg crypto/elliptic, type Curve interface, Add //deprecated #52221
pkg crypto/elliptic, type Curve interface, Double //deprecated #52221
pkg crypto/elliptic, type Curve interface, IsOnCurve //deprecated #52221
pkg crypto/elliptic, type Curve interface, ScalarBaseMult //deprecated #52221
pkg crypto/elliptic, type Curve interface, ScalarMult //deprecated #52221
pkg crypto/rsa, func GenerateMultiPrimeKey //deprecated #56921
pkg crypto/rsa, type PrecomputedValues struct, CRTValues //deprecated #56921
pkg crypto/tls, const QUICEncryptionLevelApplication = 3 #44886
pkg crypto/tls, const QUICEncryptionLevelApplication QUICEncryptionLevel #44886
pkg crypto/tls, const QUICEncryptionLevelEarly = 1 #60107
pkg crypto/tls, const QUICEncryptionLevelEarly QUICEncryptionLevel #60107
pkg crypto/tls, const QUICEncryptionLevelHandshake = 2 #44886
pkg crypto/tls, const QUICEncryptionLevelHandshake QUICEncryptionLevel #44886
pkg crypto/tls, const QUICEncryptionLevelInitial = 0 #44886
pkg crypto/tls, const QUICEncryptionLevelInitial QUICEncryptionLevel #44886
pkg crypto/tls, const QUICHandshakeDone = 7 #44886
pkg crypto/tls, const QUICHandshakeDone QUICEventKind #44886
pkg crypto/tls, const QUICNoEvent = 0 #44886
pkg crypto/tls, const QUICNoEvent QUICEventKind #44886
pkg crypto/tls, const QUICRejectedEarlyData = 6 #60107
pkg crypto/tls, const QUICRejectedEarlyData QUICEventKind #60107
pkg crypto/tls, const QUICSetReadSecret = 1 #44886
pkg crypto/tls, const QUICSetReadSecret QUICEventKind #44886
pkg crypto/tls, const QUICSetWriteSecret = 2 #44886
pkg crypto/tls, const QUICSetWriteSecret QUICEventKind #44886
pkg crypto/tls, const QUICTransportParameters = 4 #44886
pkg crypto/tls, const QUICTransportParameters QUICEventKind #44886
pkg crypto/tls, const QUICTransportParametersRequired = 5 #44886
pkg crypto/tls, const QUICTransportParametersRequired QUICEventKind #44886
pkg crypto/tls, const QUICWriteData = 3 #44886
pkg crypto/tls, const QUICWriteData QUICEventKind #44886
pkg crypto/tls, func NewResumptionState([]uint8, *SessionState) (*ClientSessionState, error) #60105
pkg crypto/tls, func ParseSessionState([]uint8) (*SessionState, error) #60105
pkg crypto/tls, func QUICClient(*QUICConfig) *QUICConn #44886
pkg crypto/tls, func QUICServer(*QUICConfig) *QUICConn #44886
pkg crypto/tls, func VersionName(uint16) string #46308
pkg crypto/tls, method (AlertError) Error() string #44886
pkg crypto/tls, method (*ClientSessionState) ResumptionState() ([]uint8, *SessionState, error) #60105
pkg crypto/tls, method (*Config) DecryptTicket([]uint8, ConnectionState) (*SessionState, error) #60105
pkg crypto/tls, method (*Config) EncryptTicket(ConnectionState, *SessionState) ([]uint8, error) #60105
pkg crypto/tls, method (*QUICConn) Close() error #44886
pkg crypto/tls, method (*QUICConn) ConnectionState() ConnectionState #44886
pkg crypto/tls, method (*QUICConn) HandleData(QUICEncryptionLevel, []uint8) error #44886
pkg crypto/tls, method (*QUICConn) NextEvent() QUICEvent #44886
pkg crypto/tls, method (*QUICConn) SendSessionTicket(bool) error #60107
pkg crypto/tls, method (*QUICConn) SetTransportParameters([]uint8) #44886
pkg crypto/tls, method (*QUICConn) Start(context.Context) error #44886
pkg crypto/tls, method (QUICEncryptionLevel) String() string #44886
pkg crypto/tls, method (*SessionState) Bytes() ([]uint8, error) #60105
pkg crypto/tls, type AlertError uint8 #44886
pkg crypto/tls, type Config struct, UnwrapSession func([]uint8, ConnectionState) (*SessionState, error) #60105
pkg crypto/tls, type Config struct, WrapSession func(ConnectionState, *SessionState) ([]uint8, error) #60105
pkg crypto/tls, type QUICConfig struct #44886
pkg crypto/tls, type QUICConfig struct, TLSConfig *Config #44886
pkg crypto/tls, type QUICConn struct #44886
pkg crypto/tls, type QUICEncryptionLevel int #44886
pkg crypto/tls, type QUICEventKind int #44886
pkg crypto/tls, type QUICEvent struct #44886
pkg crypto/tls, type QUICEvent struct, Data []uint8 #44886
pkg crypto/tls, type QUICEvent struct, Kind QUICEventKind #44886
pkg crypto/tls, type QUICEvent struct, Level QUICEncryptionLevel #44886
pkg crypto/tls, type QUICEvent struct, Suite uint16 #44886
pkg crypto/tls, type SessionState struct #60105
pkg crypto/tls, type SessionState struct, EarlyData bool #60107
pkg crypto/tls, type SessionState struct, Extra [][]uint8 #60539
pkg crypto/x509, type RevocationListEntry struct #53573
pkg crypto/x509, type RevocationListEntry struct, Extensions []pkix.Extension #53573
pkg crypto/x509, type RevocationListEntry struct, ExtraExtensions []pkix.Extension #53573
pkg crypto/x509, type RevocationListEntry struct, Raw []uint8 #53573
pkg crypto/x509, type RevocationListEntry struct, ReasonCode int #53573
pkg crypto/x509, type RevocationListEntry struct, RevocationTime time.Time #53573
pkg crypto/x509, type RevocationListEntry struct, SerialNumber *big.Int #53573
pkg crypto/x509, type RevocationList struct, RevokedCertificateEntries []RevocationListEntry #53573
pkg crypto/x509, type RevocationList struct, RevokedCertificates //deprecated #53573
pkg debug/elf, const COMPRESS_ZSTD = 2 #55107
pkg debug/elf, const COMPRESS_ZSTD CompressionType #55107
pkg debug/elf, const DF_1_CONFALT = 8192 #56887
pkg debug/elf, const DF_1_CONFALT DynFlag1 #56887
pkg debug/elf, const DF_1_DIRECT = 256 #56887
pkg debug/elf, const DF_1_DIRECT DynFlag1 #56887
pkg debug/elf, const DF_1_DISPRELDNE = 32768 #56887
pkg debug/elf, const DF_1_DISPRELDNE DynFlag1 #56887
pkg debug/elf, const DF_1_DISPRELPND = 65536 #56887
pkg debug/elf, const DF_1_DISPRELPND DynFlag1 #56887
pkg debug/elf, const DF_1_EDITED = 2097152 #56887
pkg debug/elf, const DF_1_EDITED DynFlag1 #56887
pkg debug/elf, const DF_1_ENDFILTEE = 16384 #56887
pkg debug/elf, const DF_1_ENDFILTEE DynFlag1 #56887
pkg debug/elf, const DF_1_GLOBAL = 2 #56887
pkg debug/elf, const DF_1_GLOBAL DynFlag1 #56887
pkg debug/elf, const DF_1_GLOBAUDIT = 16777216 #56887
pkg debug/elf, const DF_1_GLOBAUDIT DynFlag1 #56887
pkg debug/elf, const DF_1_GROUP = 4 #56887
pkg debug/elf, const DF_1_GROUP DynFlag1 #56887
pkg debug/elf, const DF_1_IGNMULDEF = 262144 #56887
pkg debug/elf, const DF_1_IGNMULDEF DynFlag1 #56887
pkg debug/elf, const DF_1_INITFIRST = 32 #56887
pkg debug/elf, const DF_1_INITFIRST DynFlag1 #56887
pkg debug/elf, const DF_1_INTERPOSE = 1024 #56887
pkg debug/elf, const DF_1_INTERPOSE DynFlag1 #56887
pkg debug/elf, const DF_1_KMOD = 268435456 #56887
pkg debug/elf, const DF_1_KMOD DynFlag1 #56887
pkg debug/elf, const DF_1_LOADFLTR = 16 #56887
pkg debug/elf, const DF_1_LOADFLTR DynFlag1 #56887
pkg debug/elf, const DF_1_NOCOMMON = 1073741824 #56887
pkg debug/elf, const DF_1_NOCOMMON DynFlag1 #56887
pkg debug/elf, const DF_1_NODEFLIB = 2048 #56887
pkg debug/elf, const DF_1_NODEFLIB DynFlag1 #56887
pkg debug/elf, const DF_1_NODELETE = 8 #56887
pkg debug/elf, const DF_1_NODELETE DynFlag1 #56887
pkg debug/elf, const DF_1_NODIRECT = 131072 #56887
pkg debug/elf, const DF_1_NODIRECT DynFlag1 #56887
pkg debug/elf, const DF_1_NODUMP = 4096 #56887
pkg debug/elf, const DF_1_NODUMP DynFlag1 #56887
pkg debug/elf, const DF_1_NOHDR = 1048576 #56887
pkg debug/elf, const DF_1_NOHDR DynFlag1 #56887
pkg debug/elf, const DF_1_NOKSYMS = 524288 #56887
pkg debug/elf, const DF_1_NOKSYMS DynFlag1 #56887
pkg debug/elf, const DF_1_NOOPEN = 64 #56887
pkg debug/elf, const DF_1_NOOPEN DynFlag1 #56887
pkg debug/elf, const DF_1_NORELOC = 4194304 #56887
pkg debug/elf, const DF_1_NORELOC DynFlag1 #56887
pkg debug/elf, const DF_1_NOW = 1 #56887
pkg debug/elf, const DF_1_NOW DynFlag1 #56887
pkg debug/elf, const DF_1_ORIGIN = 128 #56887
pkg debug/elf, const DF_1_ORIGIN DynFlag1 #56887
pkg debug/elf, const DF_1_PIE = 134217728 #56887
pkg debug/elf, const DF_1_PIE DynFlag1 #56887
pkg debug/elf, const DF_1_SINGLETON = 33554432 #56887
pkg debug/elf, const DF_1_SINGLETON DynFlag1 #56887
pkg debug/elf, const DF_1_STUB = 67108864 #56887
pkg debug/elf, const DF_1_STUB DynFlag1 #56887
pkg debug/elf, const DF_1_SYMINTPOSE = 8388608 #56887
pkg debug/elf, const DF_1_SYMINTPOSE DynFlag1 #56887
pkg debug/elf, const DF_1_TRANS = 512 #56887
pkg debug/elf, const DF_1_TRANS DynFlag1 #56887
pkg debug/elf, const DF_1_WEAKFILTER = 536870912 #56887
pkg debug/elf, const DF_1_WEAKFILTER DynFlag1 #56887
pkg debug/elf, const R_PPC64_REL24_P9NOTOC = 124 #60348
pkg debug/elf, const R_PPC64_REL24_P9NOTOC R_PPC64 #60348
pkg debug/elf, method (DynFlag1) GoString() string #56887
pkg debug/elf, method (DynFlag1) String() string #56887
pkg debug/elf, method (*File) DynValue(DynTag) ([]uint64, error) #56892
pkg debug/elf, type DynFlag1 uint32 #56887
pkg encoding/binary, var NativeEndian nativeEndian #57237
pkg errors, var ErrUnsupported error #41198
pkg flag, func BoolFunc(string, string, func(string) error) #53747
pkg flag, method (*FlagSet) BoolFunc(string, string, func(string) error) #53747
pkg go/ast, func IsGenerated(*File) bool #28089
pkg go/ast, type File struct, GoVersion string #59033
pkg go/build/constraint, func GoVersion(Expr) string #59033
pkg go/build, type Directive struct #56986
pkg go/build, type Directive struct, Pos token.Position #56986
pkg go/build, type Directive struct, Text string #56986
pkg go/build, type Package struct, Directives []Directive #56986
pkg go/build, type Package struct, TestDirectives []Directive #56986
pkg go/build, type Package struct, XTestDirectives []Directive #56986
pkg go/token, method (*File) Lines() []int #57708
pkg go/types, method (*Package) GoVersion() string #61175
pkg html/template, const ErrJSTemplate = 12 #59584
pkg html/template, const ErrJSTemplate ErrorCode #59584
pkg io/fs, func FormatDirEntry(DirEntry) string #54451
pkg io/fs, func FormatFileInfo(FileInfo) string #54451
pkg log/slog, const KindAny = 0 #56345
pkg log/slog, const KindAny Kind #56345
pkg log/slog, const KindBool = 1 #56345
pkg log/slog, const KindBool Kind #56345
pkg log/slog, const KindDuration = 2 #56345
pkg log/slog, const KindDuration Kind #56345
pkg log/slog, const KindFloat64 = 3 #56345
pkg log/slog, const KindFloat64 Kind #56345
pkg log/slog, const KindGroup = 8 #56345
pkg log/slog, const KindGroup Kind #56345
pkg log/slog, const KindInt64 = 4 #56345
pkg log/slog, const KindInt64 Kind #56345
pkg log/slog, const KindLogValuer = 9 #56345
pkg log/slog, const KindLogValuer Kind #56345
pkg log/slog, const KindString = 5 #56345
pkg log/slog, const KindString Kind #56345
pkg log/slog, const KindTime = 6 #56345
pkg log/slog, const KindTime Kind #56345
pkg log/slog, const KindUint64 = 7 #56345
pkg log/slog, const KindUint64 Kind #56345
pkg log/slog, const LevelDebug = -4 #56345
pkg log/slog, const LevelDebug Level #56345
pkg log/slog, const LevelError = 8 #56345
pkg log/slog, const LevelError Level #56345
pkg log/slog, const LevelInfo = 0 #56345
pkg log/slog, const LevelInfo Level #56345
pkg log/slog, const LevelKey ideal-string #56345
pkg log/slog, const LevelKey = "level" #56345
pkg log/slog, const LevelWarn = 4 #56345
pkg log/slog, const LevelWarn Level #56345
pkg log/slog, const MessageKey ideal-string #56345
pkg log/slog, const MessageKey = "msg" #56345
pkg log/slog, const SourceKey ideal-string #56345
pkg log/slog, const SourceKey = "source" #56345
pkg log/slog, const TimeKey ideal-string #56345
pkg log/slog, const TimeKey = "time" #56345
pkg log/slog, func Any(string, interface{}) Attr #56345
pkg log/slog, func AnyValue(interface{}) Value #56345
pkg log/slog, func Bool(string, bool) Attr #56345
pkg log/slog, func BoolValue(bool) Value #56345
pkg log/slog, func DebugCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, func Debug(string, ...interface{}) #56345
pkg log/slog, func Default() *Logger #56345
pkg log/slog, func Duration(string, time.Duration) Attr #56345
pkg log/slog, func DurationValue(time.Duration) Value #56345
pkg log/slog, func ErrorCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, func Error(string, ...interface{}) #56345
pkg log/slog, func Float64(string, float64) Attr #56345
pkg log/slog, func Float64Value(float64) Value #56345
pkg log/slog, func Group(string, ...interface{}) Attr #59204
pkg log/slog, func GroupValue(...Attr) Value #56345
pkg log/slog, func InfoCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, func Info(string, ...interface{}) #56345
pkg log/slog, func Int64(string, int64) Attr #56345
pkg log/slog, func Int64Value(int64) Value #56345
pkg log/slog, func Int(string, int) Attr #56345
pkg log/slog, func IntValue(int) Value #56345
pkg log/slog, func LogAttrs(context.Context, Level, string, ...Attr) #56345
pkg log/slog, func Log(context.Context, Level, string, ...interface{}) #56345
pkg log/slog, func New(Handler) *Logger #56345
pkg log/slog, func NewJSONHandler(io.Writer, *HandlerOptions) *JSONHandler #59339
pkg log/slog, func NewLogLogger(Handler, Level) *log.Logger #56345
pkg log/slog, func NewRecord(time.Time, Level, string, uintptr) Record #56345
pkg log/slog, func NewTextHandler(io.Writer, *HandlerOptions) *TextHandler #59339
pkg log/slog, func SetDefault(*Logger) #56345
pkg log/slog, func String(string, string) Attr #56345
pkg log/slog, func StringValue(string) Value #56345
pkg log/slog, func Time(string, time.Time) Attr #56345
pkg log/slog, func TimeValue(time.Time) Value #56345
pkg log/slog, func Uint64(string, uint64) Attr #56345
pkg log/slog, func Uint64Value(uint64) Value #56345
pkg log/slog, func WarnCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, func Warn(string, ...interface{}) #56345
pkg log/slog, func With(...interface{}) *Logger #56345
pkg log/slog, method (Attr) Equal(Attr) bool #56345
pkg log/slog, method (Attr) String() string #56345
pkg log/slog, method (*JSONHandler) Enabled(context.Context, Level) bool #56345
pkg log/slog, method (*JSONHandler) Handle(context.Context, Record) error #56345
pkg log/slog, method (*JSONHandler) WithAttrs([]Attr) Handler #56345
pkg log/slog, method (*JSONHandler) WithGroup(string) Handler #56345
pkg log/slog, method (Kind) String() string #56345
pkg log/slog, method (Level) Level() Level #56345
pkg log/slog, method (Level) MarshalJSON() ([]uint8, error) #56345
pkg log/slog, method (Level) MarshalText() ([]uint8, error) #56345
pkg log/slog, method (Level) String() string #56345
pkg log/slog, method (*Level) UnmarshalJSON([]uint8) error #56345
pkg log/slog, method (*Level) UnmarshalText([]uint8) error #56345
pkg log/slog, method (*LevelVar) Level() Level #56345
pkg log/slog, method (*LevelVar) MarshalText() ([]uint8, error) #56345
pkg log/slog, method (*LevelVar) Set(Level) #56345
pkg log/slog, method (*LevelVar) String() string #56345
pkg log/slog, method (*LevelVar) UnmarshalText([]uint8) error #56345
pkg log/slog, method (*Logger) DebugCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, method (*Logger) Debug(string, ...interface{}) #56345
pkg log/slog, method (*Logger) Enabled(context.Context, Level) bool #56345
pkg log/slog, method (*Logger) ErrorCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, method (*Logger) Error(string, ...interface{}) #56345
pkg log/slog, method (*Logger) Handler() Handler #56345
pkg log/slog, method (*Logger) InfoCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, method (*Logger) Info(string, ...interface{}) #56345
pkg log/slog, method (*Logger) LogAttrs(context.Context, Level, string, ...Attr) #56345
pkg log/slog, method (*Logger) Log(context.Context, Level, string, ...interface{}) #56345
pkg log/slog, method (*Logger) WarnCtx(context.Context, string, ...interface{}) #56345
pkg log/slog, method (*Logger) Warn(string, ...interface{}) #56345
pkg log/slog, method (*Logger) WithGroup(string) *Logger #56345
pkg log/slog, method (*Logger) With(...interface{}) *Logger #56345
pkg log/slog, method (*Record) AddAttrs(...Attr) #56345
pkg log/slog, method (*Record) Add(...interface{}) #56345
pkg log/slog, method (Record) Attrs(func(Attr) bool) #59060
pkg log/slog, method (Record) Clone() Record #56345
pkg log/slog, method (Record) NumAttrs() int #56345
pkg log/slog, method (*TextHandler) Enabled(context.Context, Level) bool #56345
pkg log/slog, method (*TextHandler) Handle(context.Context, Record) error #56345
pkg log/slog, method (*TextHandler) WithAttrs([]Attr) Handler #56345
pkg log/slog, method (*TextHandler) WithGroup(string) Handler #56345
pkg log/slog, method (Value) Any() interface{} #56345
pkg log/slog, method (Value) Bool() bool #56345
pkg log/slog, method (Value) Duration() time.Duration #56345
pkg log/slog, method (Value) Equal(Value) bool #56345
pkg log/slog, method (Value) Float64() float64 #56345
pkg log/slog, method (Value) Group() []Attr #56345
pkg log/slog, method (Value) Int64() int64 #56345
pkg log/slog, method (Value) Kind() Kind #56345
pkg log/slog, method (Value) LogValuer() LogValuer #56345
pkg log/slog, method (Value) Resolve() Value #56345
pkg log/slog, method (Value) String() string #56345
pkg log/slog, method (Value) Time() time.Time #56345
pkg log/slog, method (Value) Uint64() uint64 #56345
pkg log/slog, type Attr struct #56345
pkg log/slog, type Attr struct, Key string #56345
pkg log/slog, type Attr struct, Value Value #56345
pkg log/slog, type Handler interface, Enabled(context.Context, Level) bool #56345
pkg log/slog, type Handler interface { Enabled, Handle, WithAttrs, WithGroup } #56345
pkg log/slog, type Handler interface, Handle(context.Context, Record) error #56345
pkg log/slog, type Handler interface, WithAttrs([]Attr) Handler #56345
pkg log/slog, type Handler interface, WithGroup(string) Handler #56345
pkg log/slog, type HandlerOptions struct #56345
pkg log/slog, type HandlerOptions struct, AddSource bool #56345
pkg log/slog, type HandlerOptions struct, Level Leveler #56345
pkg log/slog, type HandlerOptions struct, ReplaceAttr func([]string, Attr) Attr #56345
pkg log/slog, type JSONHandler struct #56345
pkg log/slog, type Kind int #56345
pkg log/slog, type Leveler interface { Level } #56345
pkg log/slog, type Leveler interface, Level() Level #56345
pkg log/slog, type Level int #56345
pkg log/slog, type LevelVar struct #56345
pkg log/slog, type Logger struct #56345
pkg log/slog, type LogValuer interface { LogValue } #56345
pkg log/slog, type LogValuer interface, LogValue() Value #56345
pkg log/slog, type Record struct #56345
pkg log/slog, type Record struct, Level Level #56345
pkg log/slog, type Record struct, Message string #56345
pkg log/slog, type Record struct, PC uintptr #56345
pkg log/slog, type Record struct, Time time.Time #56345
pkg log/slog, type Source struct #59280
pkg log/slog, type Source struct, File string #59280
pkg log/slog, type Source struct, Function string #59280
pkg log/slog, type Source struct, Line int #59280
pkg log/slog, type TextHandler struct #56345
pkg log/slog, type Value struct #56345
pkg maps, func Clone[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) $0 #57436
pkg maps, func Copy[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$3 }, $2 comparable, $3 interface{}]($0, $1) #57436
pkg maps, func DeleteFunc[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0, func($1, $2) bool) #57436
pkg maps, func Equal[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$3 }, $2 comparable, $3 comparable]($0, $1) bool #57436
pkg maps, func EqualFunc[$0 interface{ ~map[$2]$3 }, $1 interface{ ~map[$2]$4 }, $2 comparable, $3 interface{}, $4 interface{}]($0, $1, func($3, $4) bool) bool #57436
pkg maps, func Keys[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$1 #57436
pkg maps, func Values[$0 interface{ ~map[$1]$2 }, $1 comparable, $2 interface{}]($0) []$2 #57436
pkg math/big, method (*Int) Float64() (float64, Accuracy) #56984
pkg net/http, method (*ProtocolError) Is(error) bool #41198
pkg net/http, method (*ResponseController) EnableFullDuplex() error #57786
pkg net/http, var ErrSchemeMismatch error #44855
pkg net, method (*Dialer) MultipathTCP() bool #56539
pkg net, method (*Dialer) SetMultipathTCP(bool) #56539
pkg net, method (*ListenConfig) MultipathTCP() bool #56539
pkg net, method (*ListenConfig) SetMultipathTCP(bool) #56539
pkg net, method (*TCPConn) MultipathTCP() (bool, error) #59166
pkg reflect, method (Value) Clear() #55002
pkg reflect, type SliceHeader //deprecated #56906
pkg reflect, type StringHeader //deprecated #56906
pkg regexp, method (*Regexp) MarshalText() ([]uint8, error) #46159
pkg regexp, method (*Regexp) UnmarshalText([]uint8) error #46159
pkg runtime, method (*PanicNilError) Error() string #25448
pkg runtime, method (*PanicNilError) RuntimeError() #25448
pkg runtime, method (*Pinner) Pin(interface{}) #46787
pkg runtime, method (*Pinner) Unpin() #46787
pkg runtime, type PanicNilError struct #25448
pkg runtime, type Pinner struct #46787
pkg slices, func BinarySearch[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0, $1) (int, bool) #60091
pkg slices, func BinarySearchFunc[$0 interface{ ~[]$1 }, $1 interface{}, $2 interface{}]($0, $2, func($1, $2) int) (int, bool) #60091
pkg slices, func Clip[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0 #57433
pkg slices, func Clone[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0 #57433
pkg slices, func Compact[$0 interface{ ~[]$1 }, $1 comparable]($0) $0 #57433
pkg slices, func CompactFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) bool) $0 #57433
pkg slices, func Compare[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0, $0) int #60091
pkg slices, func CompareFunc[$0 interface{ ~[]$2 }, $1 interface{ ~[]$3 }, $2 interface{}, $3 interface{}]($0, $1, func($2, $3) int) int #60091
pkg slices, func Contains[$0 interface{ ~[]$1 }, $1 comparable]($0, $1) bool #57433
pkg slices, func ContainsFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) bool #57433
pkg slices, func Delete[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, int) $0 #57433
pkg slices, func DeleteFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) $0 #54768
pkg slices, func Equal[$0 interface{ ~[]$1 }, $1 comparable]($0, $0) bool #57433
pkg slices, func EqualFunc[$0 interface{ ~[]$2 }, $1 interface{ ~[]$3 }, $2 interface{}, $3 interface{}]($0, $1, func($2, $3) bool) bool #57433
pkg slices, func Grow[$0 interface{ ~[]$1 }, $1 interface{}]($0, int) $0 #57433
pkg slices, func Index[$0 interface{ ~[]$1 }, $1 comparable]($0, $1) int #57433
pkg slices, func IndexFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1) bool) int #57433
pkg slices, func Insert[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, ...$1) $0 #57433
pkg slices, func IsSorted[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) bool #60091
pkg slices, func IsSortedFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) bool #60091
pkg slices, func Max[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) $1 #60091
pkg slices, func MaxFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) $1 #60091
pkg slices, func Min[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) $1 #60091
pkg slices, func MinFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) $1 #60091
pkg slices, func Replace[$0 interface{ ~[]$1 }, $1 interface{}]($0, int, int, ...$1) $0 #57433
pkg slices, func Reverse[$0 interface{ ~[]$1 }, $1 interface{}]($0) #58565
pkg slices, func Sort[$0 interface{ ~[]$1 }, $1 cmp.Ordered]($0) #60091
pkg slices, func SortFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) #60091
pkg slices, func SortStableFunc[$0 interface{ ~[]$1 }, $1 interface{}]($0, func($1, $1) int) #60091
pkg strings, func ContainsFunc(string, func(int32) bool) bool #54386
pkg sync, func OnceFunc(func()) func() #56102
pkg sync, func OnceValue[$0 interface{}](func() $0) func() $0 #56102
pkg sync, func OnceValues[$0 interface{}, $1 interface{}](func() ($0, $1)) func() ($0, $1) #56102
pkg syscall (freebsd-386-cgo), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-386), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-amd64-cgo), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-amd64), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-arm64-cgo), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-arm64), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-arm-cgo), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-arm), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-riscv64-cgo), type SysProcAttr struct, Jail int #46259
pkg syscall (freebsd-riscv64), type SysProcAttr struct, Jail int #46259
pkg testing, func Testing() bool #52600
pkg testing/slogtest, func TestHandler(slog.Handler, func() []map[string]interface{}) error #56345
pkg unicode, const Version = "15.0.0" #55079
pkg unicode, var Cypro_Minoan *RangeTable #55079
pkg unicode, var Kawi *RangeTable #55079
pkg unicode, var Nag_Mundari *RangeTable #55079
pkg unicode, var Old_Uyghur *RangeTable #55079
pkg unicode, var Tangsa *RangeTable #55079
pkg unicode, var Toto *RangeTable #55079
pkg unicode, var Vithkuqi *RangeTable #55079

View File

@@ -1,2 +1,2 @@
branch: dev.inline
branch: release-branch.go1.20
parent-branch: master

1246
doc/go1.20.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of June 14, 2023",
"Subtitle": "Version of December 15, 2022",
"Path": "/ref/spec"
}-->
@@ -643,7 +643,6 @@ an identifier denoting a constant,
a <a href="#Constant_expressions">constant expression</a>,
a <a href="#Conversions">conversion</a> with a result that is a constant, or
the result value of some built-in functions such as
<code>min</code> or <code>max</code> applied to constant arguments,
<code>unsafe.Sizeof</code> applied to <a href="#Package_unsafe">certain values</a>,
<code>cap</code> or <code>len</code> applied to
<a href="#Length_and_capacity">some expressions</a>,
@@ -691,7 +690,7 @@ constant is implicitly converted in contexts where a typed value is required,
for instance, in a <a href="#Short_variable_declarations">short variable declaration</a>
such as <code>i := 0</code> where there is no explicit type.
The default type of an untyped constant is <code>bool</code>, <code>rune</code>,
<code>int</code>, <code>float64</code>, <code>complex128</code>, or <code>string</code>
<code>int</code>, <code>float64</code>, <code>complex128</code> or <code>string</code>
respectively, depending on whether it is a boolean, rune, integer, floating-point,
complex, or string constant.
</p>
@@ -1645,10 +1644,8 @@ built-in function <a href="#Length_and_capacity"><code>len</code></a>
and may change during execution. Elements may be added during execution
using <a href="#Assignment_statements">assignments</a> and retrieved with
<a href="#Index_expressions">index expressions</a>; they may be removed with the
<a href="#Deletion_of_map_elements"><code>delete</code></a> and
<a href="#Clear"><code>clear</code></a> built-in function.
<a href="#Deletion_of_map_elements"><code>delete</code></a> built-in function.
</p>
<p>
A new, empty map value is made using the built-in
function <a href="#Making_slices_maps_and_channels"><code>make</code></a>,
@@ -1886,7 +1883,7 @@ interface{ ~[]byte | myString } // bytestring
<p>
Note that <code>bytestring</code> is not a real type; it cannot be used to declare
variables or compose other types. It exists solely to describe the behavior of some
variables are compose other types. It exists solely to describe the behavior of some
operations that read from a sequence of bytes, which may be a byte slice or a string.
</p>
@@ -2319,8 +2316,8 @@ Zero value:
nil
Functions:
append cap clear close complex copy delete imag len
make max min new panic print println real recover
append cap close complex copy delete imag len
make new panic print println real recover
</pre>
<h3 id="Exported_identifiers">Exported identifiers</h3>
@@ -2648,7 +2645,7 @@ TypeParamDecl = IdentifierList TypeConstraint .
<p>
All non-blank names in the list must be unique.
Each name declares a type parameter, which is a new and different <a href="#Types">named type</a>
that acts as a placeholder for an (as of yet) unknown type in the declaration.
that acts as a place holder for an (as of yet) unknown type in the declaration.
The type parameter is replaced with a <i>type argument</i> upon
<a href="#Instantiations">instantiation</a> of the generic function or type.
</p>
@@ -2762,7 +2759,7 @@ However, they <a href="#Satisfying_a_type_constraint">satisfy</a> <code>comparab
int // implements comparable (int is strictly comparable)
[]byte // does not implement comparable (slices cannot be compared)
interface{} // does not implement comparable (see above)
interface{ ~int | ~string } // type parameter only: implements comparable (int, string types are strictly comparable)
interface{ ~int | ~string } // type parameter only: implements comparable (int, string types are stricly comparable)
interface{ comparable } // type parameter only: implements comparable (comparable implements itself)
interface{ ~int | ~[]byte } // type parameter only: does not implement comparable (slices are not comparable)
interface{ ~struct{ any } } // type parameter only: does not implement comparable (field any is not strictly comparable)
@@ -2805,7 +2802,7 @@ A type T <i>satisfies</i> a constraint <code>C</code> if
type argument type constraint // constraint satisfaction
int interface{ ~int } // satisfied: int implements interface{ ~int }
string comparable // satisfied: string implements comparable (string is strictly comparable)
string comparable // satisfied: string implements comparable (string is stricty comparable)
[]byte comparable // not satisfied: slices are not comparable
any interface{ comparable; int } // not satisfied: any does not implement interface{ int }
any comparable // satisfied: any is comparable and implements the basic interface any
@@ -4340,46 +4337,24 @@ type parameter list type arguments after substitution
</pre>
<p>
When using a generic function, type arguments may be provided explicitly,
or they may be partially or completely <a href="#Type_inference">inferred</a>
from the context in which the function is used.
Provided that they can be inferred, type arguments may be omitted entirely if the function is:
</p>
<ul>
<li>
<a href="#Calls">called</a> with ordinary arguments,
</li>
<li>
<a href="#Assignment_statements">assigned</a> to a variable with an explicitly declared type,
</li>
<li>
<a href="#Calls">passed as an argument</a> to another function, or
</li>
<li>
<a href="#Return_statements">returned as a result</a>.
</li>
</ul>
<p>
In all other cases, a (possibly partial) type argument list must be present.
If a type argument list is absent or partial, all missing type arguments
must be inferrable from the context in which the function is used.
For a generic function, type arguments may be provided explicitly, or they
may be partially or completely <a href="#Type_inference">inferred</a>.
A generic function that is <i>not</i> <a href="#Calls">called</a> requires a
type argument list for instantiation; if the list is partial, all
remaining type arguments must be inferrable.
A generic function that is called may provide a (possibly partial) type
argument list, or may omit it entirely if the omitted type arguments are
inferrable from the ordinary (non-type) function arguments.
</p>
<pre>
// sum returns the sum (concatenation, for strings) of its arguments.
func sum[T ~int | ~float64 | ~string](x... T) T { … }
func min[T ~int|~float64](x, y T) T { … }
x := sum // illegal: sum must have a type argument (x is a variable without a declared type)
intSum := sum[int] // intSum has type func(x... int) int
a := intSum(2, 3) // a has value 5 of type int
b := sum[float64](2.0, 3) // b has value 5.0 of type float64
c := sum(b, -1) // c has value 4.0 of type float64
type sumFunc func(x... string) string
var f sumFunc = sum // same as var f sumFunc = sum[string]
f = sum // same as f = sum[string]
f := min // illegal: min must be instantiated with type arguments when used without being called
minInt := min[int] // minInt has type func(x, y int) int
a := minInt(2, 3) // a has value 2 of type int
b := min[float64](2.0, 3) // b has value 2.0 of type float64
c := min(b, -1) // c has value -1.0 of type float64
</pre>
<p>
@@ -4405,10 +4380,6 @@ For a generic type, all type arguments must always be provided explicitly.
<h3 id="Type_inference">Type inference</h3>
<p>
<em>NOTE: This section is not yet up-to-date for Go 1.21.</em>
</p>
<p>
Missing function type arguments may be <i>inferred</i> by a series of steps, described below.
Each step attempts to use known information to infer additional type arguments.
@@ -5609,6 +5580,21 @@ succeeds but the result value is implementation-dependent.
<h4 id="Conversions_to_and_from_a_string_type">Conversions to and from a string type</h4>
<ol>
<li>
Converting a signed or unsigned integer value to a string type yields a
string containing the UTF-8 representation of the integer. Values outside
the range of valid Unicode code points are converted to <code>"\uFFFD"</code>.
<pre>
string('a') // "a"
string(-1) // "\ufffd" == "\xef\xbf\xbd"
string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8"
type myString string
myString(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5"
</pre>
</li>
<li>
Converting a slice of bytes to a string type yields
a string whose successive bytes are the elements of the slice.
@@ -5675,31 +5661,6 @@ runes("白鵬翔") // []rune{0x767d, 0x9d6c, 0x7fd4}
[]myRune(myString("🌐")) // []myRune{0x1f310}
</pre>
</li>
<li>
Finally, for historical reasons, an integer value may be converted to a string type.
This form of conversion yields a string containing the (possibly multi-byte) UTF-8
representation of the Unicode code point with the given integer value.
Values outside the range of valid Unicode code points are converted to <code>"\uFFFD"</code>.
<pre>
string('a') // "a"
string(65) // "A"
string('\xf8') // "\u00f8" == "ø" == "\xc3\xb8"
string(-1) // "\ufffd" == "\xef\xbf\xbd"
type myString string
myString('\u65e5') // "\u65e5" == "日" == "\xe6\x97\xa5"
</pre>
Note: This form of conversion may eventually be removed from the language.
The <a href="/pkg/cmd/vet"><code>go vet</code></a> tool flags certain
integer-to-string conversions as potential errors.
Library functions such as
<a href="/pkg/unicode/utf8#AppendRune"><code>utf8.AppendRune</code></a> or
<a href="/pkg/unicode/utf8#EncodeRune"><code>utf8.EncodeRune</code></a>
should be used instead.
</li>
</ol>
<h4 id="Conversions_from_slice_to_array_or_array_pointer">Conversions from slice to array or array pointer</h4>
@@ -6066,7 +6027,7 @@ The following built-in functions are not permitted in statement context:
<pre>
append cap complex imag len make new real
unsafe.Add unsafe.Alignof unsafe.Offsetof unsafe.Sizeof unsafe.Slice unsafe.SliceData unsafe.String unsafe.StringData
unsafe.Add unsafe.Alignof unsafe.Offsetof unsafe.Sizeof unsafe.Slice
</pre>
<pre>
@@ -6248,7 +6209,7 @@ x = []int{3, 5, 7}
for i, x[i] = range x { // set i, x[2] = 0, x[0]
break
}
// after this loop, i == 0 and x is []int{3, 5, 3}
// after this loop, i == 0 and x == []int{3, 5, 3}
</pre>
<p>
@@ -7220,120 +7181,6 @@ so they can only appear in <a href="#Calls">call expressions</a>;
they cannot be used as function values.
</p>
<h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
<p>
The built-in functions <code>append</code> and <code>copy</code> assist in
common slice operations.
For both functions, the result is independent of whether the memory referenced
by the arguments overlaps.
</p>
<p>
The <a href="#Function_types">variadic</a> function <code>append</code>
appends zero or more values <code>x</code> to a slice <code>s</code>
and returns the resulting slice of the same type as <code>s</code>.
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
of type <code>[]E</code>.
The values <code>x</code> are passed to a parameter of type <code>...E</code>
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
passing rules</a> apply.
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
<code>append</code> also accepts a second argument with core type
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
This form appends the bytes of the byte slice or string.
</p>
<pre class="grammar">
append(s S, x ...E) S // core type of S is []E
</pre>
<p>
If the capacity of <code>s</code> is not large enough to fit the additional
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
array that fits both the existing slice elements and the additional values.
Otherwise, <code>append</code> re-uses the underlying array.
</p>
<pre>
s0 := []int{0, 0}
s1 := append(s0, 2) // append a single element s1 is []int{0, 0, 2}
s2 := append(s1, 3, 5, 7) // append multiple elements s2 is []int{0, 0, 2, 3, 5, 7}
s3 := append(s2, s0...) // append a slice s3 is []int{0, 0, 2, 3, 5, 7, 0, 0}
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 is []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
var t []interface{}
t = append(t, 42, 3.1415, "foo") // t is []interface{}{42, 3.1415, "foo"}
var b []byte
b = append(b, "bar"...) // append string contents b is []byte{'b', 'a', 'r' }
</pre>
<p>
The function <code>copy</code> copies slice elements from
a source <code>src</code> to a destination <code>dst</code> and returns the
number of elements copied.
The <a href="#Core_types">core types</a> of both arguments must be slices
with <a href="#Type_identity">identical</a> element type.
The number of elements copied is the minimum of
<code>len(src)</code> and <code>len(dst)</code>.
As a special case, if the destination's core type is <code>[]byte</code>,
<code>copy</code> also accepts a source argument with core type
</a> <a href="#Core_types"><code>bytestring</code></a>.
This form copies the bytes from the byte slice or string into the byte slice.
</p>
<pre class="grammar">
copy(dst, src []T) int
copy(dst []byte, src string) int
</pre>
<p>
Examples:
</p>
<pre>
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
var s = make([]int, 6)
var b = make([]byte, 5)
n1 := copy(s, a[0:]) // n1 == 6, s is []int{0, 1, 2, 3, 4, 5}
n2 := copy(s, s[2:]) // n2 == 4, s is []int{2, 3, 4, 5, 4, 5}
n3 := copy(b, "Hello, World!") // n3 == 5, b is []byte("Hello")
</pre>
<h3 id="Clear">Clear</h3>
<p>
The built-in function <code>clear</code> takes an argument of <a href="#Map_types">map</a>,
<a href="#Slice_types">slice</a>, or <a href="#Type_parameter_declarations">type parameter</a> type,
and deletes or zeroes out all elements.
</p>
<pre class="grammar">
Call Argument type Result
clear(m) map[K]T deletes all entries, resulting in an
empty map (len(m) == 0)
clear(s) []T sets all elements up to the length of
<code>s</code> to the zero value of T
clear(t) type parameter see below
</pre>
<p>
If the argument type is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be maps or slices, and <code>clear</code>
performs the operation corresponding to the actual type argument.
</p>
<p>
If the map or slice is <code>nil</code>, <code>clear</code> is a no-op.
</p>
<h3 id="Close">Close</h3>
<p>
@@ -7350,100 +7197,6 @@ The multi-valued <a href="#Receive_operator">receive operation</a>
returns a received value along with an indication of whether the channel is closed.
</p>
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
<p>
Three functions assemble and disassemble complex numbers.
The built-in function <code>complex</code> constructs a complex
value from a floating-point real and imaginary part, while
<code>real</code> and <code>imag</code>
extract the real and imaginary parts of a complex value.
</p>
<pre class="grammar">
complex(realPart, imaginaryPart floatT) complexT
real(complexT) floatT
imag(complexT) floatT
</pre>
<p>
The type of the arguments and return value correspond.
For <code>complex</code>, the two arguments must be of the same
<a href="#Numeric_types">floating-point type</a> and the return type is the
<a href="#Numeric_types">complex type</a>
with the corresponding floating-point constituents:
<code>complex64</code> for <code>float32</code> arguments, and
<code>complex128</code> for <code>float64</code> arguments.
If one of the arguments evaluates to an untyped constant, it is first implicitly
<a href="#Conversions">converted</a> to the type of the other argument.
If both arguments evaluate to untyped constants, they must be non-complex
numbers or their imaginary parts must be zero, and the return value of
the function is an untyped complex constant.
</p>
<p>
For <code>real</code> and <code>imag</code>, the argument must be
of complex type, and the return type is the corresponding floating-point
type: <code>float32</code> for a <code>complex64</code> argument, and
<code>float64</code> for a <code>complex128</code> argument.
If the argument evaluates to an untyped constant, it must be a number,
and the return value of the function is an untyped floating-point constant.
</p>
<p>
The <code>real</code> and <code>imag</code> functions together form the inverse of
<code>complex</code>, so for a value <code>z</code> of a complex type <code>Z</code>,
<code>z&nbsp;==&nbsp;Z(complex(real(z),&nbsp;imag(z)))</code>.
</p>
<p>
If the operands of these functions are all constants, the return
value is a constant.
</p>
<pre>
var a = complex(2, -2) // complex128
const b = complex(1.0, -1.4) // untyped complex constant 1 - 1.4i
x := float32(math.Cos(math.Pi/2)) // float32
var c64 = complex(5, -x) // complex64
var s int = complex(1, 0) // untyped complex constant 1 + 0i can be converted to int
_ = complex(1, 2&lt;&lt;s) // illegal: 2 assumes floating-point type, cannot shift
var rl = real(c64) // float32
var im = imag(a) // float64
const c = imag(b) // untyped constant -1.4
_ = imag(3 &lt;&lt; s) // illegal: 3 assumes complex type, cannot shift
</pre>
<p>
Arguments of type parameter type are not permitted.
</p>
<h3 id="Deletion_of_map_elements">Deletion of map elements</h3>
<p>
The built-in function <code>delete</code> removes the element with key
<code>k</code> from a <a href="#Map_types">map</a> <code>m</code>. The
value <code>k</code> must be <a href="#Assignability">assignable</a>
to the key type of <code>m</code>.
</p>
<pre class="grammar">
delete(m, k) // remove element m[k] from map m
</pre>
<p>
If the type of <code>m</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in that type set must be maps, and they must all have identical key types.
</p>
<p>
If the map <code>m</code> is <code>nil</code> or the element <code>m[k]</code>
does not exist, <code>delete</code> is a no-op.
</p>
<h3 id="Length_and_capacity">Length and capacity</h3>
<p>
@@ -7514,124 +7267,6 @@ const (
var z complex128
</pre>
<h3 id="Making_slices_maps_and_channels">Making slices, maps and channels</h3>
<p>
The built-in function <code>make</code> takes a type <code>T</code>,
optionally followed by a type-specific list of expressions.
The <a href="#Core_types">core type</a> of <code>T</code> must
be a slice, map or channel.
It returns a value of type <code>T</code> (not <code>*T</code>).
The memory is initialized as described in the section on
<a href="#The_zero_value">initial values</a>.
</p>
<pre class="grammar">
Call Core type Result
make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
make(T) map map of type T
make(T, n) map map of type T with initial space for approximately n elements
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
</pre>
<p>
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
have a <a href="#Interface_types">type set</a> containing only integer types,
or be an untyped <a href="#Constants">constant</a>.
A constant size argument must be non-negative and <a href="#Representability">representable</a>
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
If both <code>n</code> and <code>m</code> are provided and are constant, then
<code>n</code> must be no larger than <code>m</code>.
For slices and channels, if <code>n</code> is negative or larger than <code>m</code> at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs.
</p>
<pre>
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
s := make([]int, 1&lt;&lt;63) // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0) // illegal: len(s) > cap(s)
c := make(chan int, 10) // channel with a buffer size of 10
m := make(map[string]int, 100) // map with initial space for approximately 100 elements
</pre>
<p>
Calling <code>make</code> with a map type and size hint <code>n</code> will
create a map with initial space to hold <code>n</code> map elements.
The precise behavior is implementation-dependent.
</p>
<h3 id="Min_and_max">Min and max</h3>
<p>
The built-in functions <code>min</code> and <code>max</code> compute the
smallest&mdash;or largest, respectively&mdash;value of a fixed number of
arguments of <a href="#Comparison_operators">ordered types</a>.
There must be at least one argument.
</p>
<p>
The same type rules as for <a href="#Operators">operators</a> apply:
for <a href="#Comparison_operators">ordered</a> arguments <code>x</code> and
<code>y</code>, <code>min(x, y)</code> is valid if <code>x + y</code> is valid,
and the type of <code>min(x, y)</code> is the type of <code>x + y</code>
(and similarly for <code>max</code>).
If all arguments are constant, the result is constant.
</p>
<pre>
var x, y int
m := min(x) // m == x
m := min(x, y) // m is the smaller of x and y
m := max(x, y, 10) // m is the larger of x and y but at least 10
c := max(1, 2.0, 10) // c == 10.0 (floating-point kind)
f := max(0, float32(x)) // type of f is float32
var s []string
_ = min(s...) // invalid: slice arguments are not permitted
t := max("", "foo", "bar") // t == "foo" (string kind)
</pre>
<p>
For numeric arguments, assuming all NaNs are equal, <code>min</code> and <code>max</code> are
commutative and associative:
</p>
<pre>
min(x, y) == min(y, x)
min(x, y, z) == min(min(x, y), z) == min(x, min(y, z))
</pre>
<p>
For floating-point arguments negative zero, NaN, and infinity the following rules apply:
</p>
<pre>
x y min(x, y) max(x, y)
-0.0 0.0 -0.0 0.0 // negative zero is smaller than (non-negative) zero
-Inf y -Inf y // negative infinity is smaller than any other number
+Inf y y +Inf // positive infinity is larger than any other number
NaN y NaN NaN // if any argument is a NaN, the result is a NaN
</pre>
<p>
For string arguments the result for <code>min</code> is the first argument
with the smallest (or for <code>max</code>, largest) value,
compared lexically byte-wise:
</p>
<pre>
min(x, y) == if x <= y then x else y
min(x, y, z) == min(min(x, y), z)
</pre>
<h3 id="Allocation">Allocation</h3>
<p>
@@ -7663,6 +7298,233 @@ and returns a value of type <code>*S</code> containing the address
of the location.
</p>
<h3 id="Making_slices_maps_and_channels">Making slices, maps and channels</h3>
<p>
The built-in function <code>make</code> takes a type <code>T</code>,
optionally followed by a type-specific list of expressions.
The <a href="#Core_types">core type</a> of <code>T</code> must
be a slice, map or channel.
It returns a value of type <code>T</code> (not <code>*T</code>).
The memory is initialized as described in the section on
<a href="#The_zero_value">initial values</a>.
</p>
<pre class="grammar">
Call Core type Result
make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
make(T) map map of type T
make(T, n) map map of type T with initial space for approximately n elements
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
</pre>
<p>
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
have a <a href="#Interface_types">type set</a> containing only integer types,
or be an untyped <a href="#Constants">constant</a>.
A constant size argument must be non-negative and <a href="#Representability">representable</a>
by a value of type <code>int</code>; if it is an untyped constant it is given type <code>int</code>.
If both <code>n</code> and <code>m</code> are provided and are constant, then
<code>n</code> must be no larger than <code>m</code>.
For slices and channels, if <code>n</code> is negative or larger than <code>m</code> at run time,
a <a href="#Run_time_panics">run-time panic</a> occurs.
</p>
<pre>
s := make([]int, 10, 100) // slice with len(s) == 10, cap(s) == 100
s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
s := make([]int, 1&lt;&lt;63) // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0) // illegal: len(s) > cap(s)
c := make(chan int, 10) // channel with a buffer size of 10
m := make(map[string]int, 100) // map with initial space for approximately 100 elements
</pre>
<p>
Calling <code>make</code> with a map type and size hint <code>n</code> will
create a map with initial space to hold <code>n</code> map elements.
The precise behavior is implementation-dependent.
</p>
<h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
<p>
The built-in functions <code>append</code> and <code>copy</code> assist in
common slice operations.
For both functions, the result is independent of whether the memory referenced
by the arguments overlaps.
</p>
<p>
The <a href="#Function_types">variadic</a> function <code>append</code>
appends zero or more values <code>x</code> to a slice <code>s</code>
and returns the resulting slice of the same type as <code>s</code>.
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
of type <code>[]E</code>.
The values <code>x</code> are passed to a parameter of type <code>...E</code>
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
passing rules</a> apply.
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
<code>append</code> also accepts a second argument with core type
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
This form appends the bytes of the byte slice or string.
</p>
<pre class="grammar">
append(s S, x ...E) S // core type of S is []E
</pre>
<p>
If the capacity of <code>s</code> is not large enough to fit the additional
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
array that fits both the existing slice elements and the additional values.
Otherwise, <code>append</code> re-uses the underlying array.
</p>
<pre>
s0 := []int{0, 0}
s1 := append(s0, 2) // append a single element s1 == []int{0, 0, 2}
s2 := append(s1, 3, 5, 7) // append multiple elements s2 == []int{0, 0, 2, 3, 5, 7}
s3 := append(s2, s0...) // append a slice s3 == []int{0, 0, 2, 3, 5, 7, 0, 0}
s4 := append(s3[3:6], s3[2:]...) // append overlapping slice s4 == []int{3, 5, 7, 2, 3, 5, 7, 0, 0}
var t []interface{}
t = append(t, 42, 3.1415, "foo") // t == []interface{}{42, 3.1415, "foo"}
var b []byte
b = append(b, "bar"...) // append string contents b == []byte{'b', 'a', 'r' }
</pre>
<p>
The function <code>copy</code> copies slice elements from
a source <code>src</code> to a destination <code>dst</code> and returns the
number of elements copied.
The <a href="#Core_types">core types</a> of both arguments must be slices
with <a href="#Type_identity">identical</a> element type.
The number of elements copied is the minimum of
<code>len(src)</code> and <code>len(dst)</code>.
As a special case, if the destination's core type is <code>[]byte</code>,
<code>copy</code> also accepts a source argument with core type
</a> <a href="#Core_types"><code>bytestring</code></a>.
This form copies the bytes from the byte slice or string into the byte slice.
</p>
<pre class="grammar">
copy(dst, src []T) int
copy(dst []byte, src string) int
</pre>
<p>
Examples:
</p>
<pre>
var a = [...]int{0, 1, 2, 3, 4, 5, 6, 7}
var s = make([]int, 6)
var b = make([]byte, 5)
n1 := copy(s, a[0:]) // n1 == 6, s == []int{0, 1, 2, 3, 4, 5}
n2 := copy(s, s[2:]) // n2 == 4, s == []int{2, 3, 4, 5, 4, 5}
n3 := copy(b, "Hello, World!") // n3 == 5, b == []byte("Hello")
</pre>
<h3 id="Deletion_of_map_elements">Deletion of map elements</h3>
<p>
The built-in function <code>delete</code> removes the element with key
<code>k</code> from a <a href="#Map_types">map</a> <code>m</code>. The
value <code>k</code> must be <a href="#Assignability">assignable</a>
to the key type of <code>m</code>.
</p>
<pre class="grammar">
delete(m, k) // remove element m[k] from map m
</pre>
<p>
If the type of <code>m</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in that type set must be maps, and they must all have identical key types.
</p>
<p>
If the map <code>m</code> is <code>nil</code> or the element <code>m[k]</code>
does not exist, <code>delete</code> is a no-op.
</p>
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
<p>
Three functions assemble and disassemble complex numbers.
The built-in function <code>complex</code> constructs a complex
value from a floating-point real and imaginary part, while
<code>real</code> and <code>imag</code>
extract the real and imaginary parts of a complex value.
</p>
<pre class="grammar">
complex(realPart, imaginaryPart floatT) complexT
real(complexT) floatT
imag(complexT) floatT
</pre>
<p>
The type of the arguments and return value correspond.
For <code>complex</code>, the two arguments must be of the same
<a href="#Numeric_types">floating-point type</a> and the return type is the
<a href="#Numeric_types">complex type</a>
with the corresponding floating-point constituents:
<code>complex64</code> for <code>float32</code> arguments, and
<code>complex128</code> for <code>float64</code> arguments.
If one of the arguments evaluates to an untyped constant, it is first implicitly
<a href="#Conversions">converted</a> to the type of the other argument.
If both arguments evaluate to untyped constants, they must be non-complex
numbers or their imaginary parts must be zero, and the return value of
the function is an untyped complex constant.
</p>
<p>
For <code>real</code> and <code>imag</code>, the argument must be
of complex type, and the return type is the corresponding floating-point
type: <code>float32</code> for a <code>complex64</code> argument, and
<code>float64</code> for a <code>complex128</code> argument.
If the argument evaluates to an untyped constant, it must be a number,
and the return value of the function is an untyped floating-point constant.
</p>
<p>
The <code>real</code> and <code>imag</code> functions together form the inverse of
<code>complex</code>, so for a value <code>z</code> of a complex type <code>Z</code>,
<code>z&nbsp;==&nbsp;Z(complex(real(z),&nbsp;imag(z)))</code>.
</p>
<p>
If the operands of these functions are all constants, the return
value is a constant.
</p>
<pre>
var a = complex(2, -2) // complex128
const b = complex(1.0, -1.4) // untyped complex constant 1 - 1.4i
x := float32(math.Cos(math.Pi/2)) // float32
var c64 = complex(5, -x) // complex64
var s int = complex(1, 0) // untyped complex constant 1 + 0i can be converted to int
_ = complex(1, 2&lt;&lt;s) // illegal: 2 assumes floating-point type, cannot shift
var rl = real(c64) // float32
var im = imag(a) // float64
const c = imag(b) // untyped constant -1.4
_ = imag(3 &lt;&lt; s) // illegal: 3 assumes complex type, cannot shift
</pre>
<p>
Arguments of type parameter type are not permitted.
</p>
<h3 id="Handling_panics">Handling panics</h3>
@@ -7712,13 +7574,19 @@ execution terminates by returning to its caller.
</p>
<p>
The return value of <code>recover</code> is <code>nil</code> when the
goroutine is not panicking or <code>recover</code> was not called directly by a deferred function.
Conversely, if a goroutine is panicking and <code>recover</code> was called directly by a deferred function,
the return value of <code>recover</code> is guaranteed not to be <code>nil</code>.
To ensure this, calling <code>panic</code> with a <code>nil</code> interface value (or an untyped <code>nil</code>)
causes a <a href="#Run_time_panics">run-time panic</a>.
The return value of <code>recover</code> is <code>nil</code> if any of the following conditions holds:
</p>
<ul>
<li>
<code>panic</code>'s argument was <code>nil</code>;
</li>
<li>
the goroutine is not panicking;
</li>
<li>
<code>recover</code> was not called directly by a deferred function.
</li>
</ul>
<p>
The <code>protect</code> function in the example below invokes
@@ -7761,7 +7629,6 @@ accept arbitrary argument types, but printing of boolean, numeric, and string
<a href="#Types">types</a> must be supported.
</p>
<h2 id="Packages">Packages</h2>
<p>
@@ -8035,9 +7902,6 @@ The declaration order of variables declared in multiple files is determined
by the order in which the files are presented to the compiler: Variables
declared in the first file are declared before any of the variables declared
in the second file, and so on.
To ensure reproducible initialization behavior, build systems are encouraged
to present multiple files belonging to the same package in lexical file name
order to a compiler.
</p>
<p>
@@ -8148,30 +8012,15 @@ in a program.
</p>
<p>
The entire package is initialized by assigning initial values
to all its package-level variables followed by calling
all <code>init</code> functions in the order they appear
in the source, possibly in multiple files, as presented
to the compiler.
</p>
<h3 id="Program_initialization">Program initialization</h3>
<p>
The packages of a complete program are initialized stepwise, one package at a time.
A package with no imports is initialized by assigning initial values
to all its package-level variables followed by calling all <code>init</code>
functions in the order they appear in the source, possibly in multiple files,
as presented to the compiler.
If a package has imports, the imported packages are initialized
before initializing the package itself. If multiple packages import
a package, the imported package will be initialized only once.
The importing of packages, by construction, guarantees that there
can be no cyclic initialization dependencies.
More precisely:
</p>
<p>
Given the list of all packages, sorted by import path, in each step the first
uninitialized package in the list for which all imported packages (if any) are
already initialized is <a href="#Package_initialization">initialized</a>.
This step is repeated until all packages are initialized.
</p>
<p>
@@ -8185,6 +8034,13 @@ the <code>init</code> functions: it will not invoke the next one
until the previous one has returned.
</p>
<p>
To ensure reproducible initialization behavior, build systems are encouraged
to present multiple files belonging to the same package in lexical file name
order to a compiler.
</p>
<h3 id="Program_execution">Program execution</h3>
<p>
A complete program is created by linking a single, unimported package
@@ -8200,8 +8056,8 @@ func main() { … }
</pre>
<p>
Program execution begins by <a href="#Program_initialization">initializing the program</a>
and then invoking the function <code>main</code> in package <code>main</code>.
Program execution begins by initializing the main package and then
invoking the function <code>main</code>.
When that function invocation returns, the program exits.
It does not wait for other (non-<code>main</code>) goroutines to complete.
</p>

View File

@@ -1,201 +0,0 @@
---
title: "Go, Backwards Compatibility, and GODEBUG"
layout: article
---
<!--
This document is kept in the Go repo, not x/website,
because it documents the full list of known GODEBUG settings,
which are tied to a specific release.
-->
## Introduction {#intro}
Go's emphasis on backwards compatibility is one of its key strengths.
There are, however, times when we cannot maintain complete compatibility.
If code depends on buggy (including insecure) behavior,
then fixing the bug will break that code.
New features can also have similar impacts:
enabling the HTTP/2 use by the HTTP client broke programs
connecting to servers with buggy HTTP/2 implementations.
These kinds of changes are unavoidable and
[permitted by the Go 1 compatibility rules](/doc/go1compat).
Even so, Go provides a mechanism called GODEBUG to
reduce the impact such changes have on Go developers
using newer toolchains to compile old code.
A GODEBUG setting is a `key=value` pair
that controls the execution of certain parts of a Go program.
The environment variable `GODEBUG`
can hold a comma-separated list of these settings.
For example, if a Go program is running in an environment that contains
GODEBUG=http2client=0,http2server=0
then that Go program will disable the use of HTTP/2 by default in both
the HTTP client and the HTTP server.
It is also possible to set the default `GODEBUG` for a given program
(discussed below).
When preparing any change that is permitted by Go 1 compatibility
but may nonetheless break some existing programs,
we first engineer the change to keep as many existing programs working as possible.
For the remaining programs,
we define a new GODEBUG setting that
allows individual programs to opt back in to the old behavior.
A GODEBUG setting may not be added if doing so is infeasible,
but that should be extremely rare.
GODEBUG settings added for compatibility will be maintained
for a minimum of two years (four Go releases).
Some, such as `http2client` and `http2server`,
will be maintained much longer, even indefinitely.
When possible, each GODEBUG setting has an associated
[runtime/metrics](/pkg/runtime/metrics/) counter
named `/godebug/non-default-behavior/<name>:events`
that counts the number of times a particular program's
behavior has changed based on a non-default value
for that setting.
For example, when `GODEBUG=http2client=0` is set,
`/godebug/non-default-behavior/http2client:events`
counts the number of HTTP transports that the program
has configured without HTTP/2 support.
## Default GODEBUG Values {#default}
When a GODEBUG setting is not listed in the environment variable,
its value is derived from three sources:
the defaults for the Go toolchain used to build the program,
amended to match the Go version listed in `go.mod`,
and then overridden by explicit `//go:debug` lines in the program.
The [GODEBUG History](#history) gives the exact defaults for each Go toolchain version.
For example, Go 1.21 introduces the `panicnil` setting,
controlling whether `panic(nil)` is allowed;
it defaults to `panicnil=0`, making `panic(nil)` a run-time error.
Using `panicnil=1` restores the behavior of Go 1.20 and earlier.
When compiling a work module or workspace that declares
an older Go version, the Go toolchain amends its defaults
to match that older Go version as closely as possible.
For example, when a Go 1.21 toolchain compiles a program,
if the work module's `go.mod` or the workspace's `go.work`
says `go` `1.20`, then the program defaults to `panicnil=1`,
matching Go 1.20 instead of Go 1.21.
Because this method of setting GODEBUG defaults was introduced only in Go 1.21,
programs listing versions of Go earlier than Go 1.20 are configured to match Go 1.20,
not the older version.
To override these defaults, a main package's source files
can include one or more `//go:debug` directives at the top of the file
(preceding the `package` statement).
Continuing the `panicnil` example, if the module or workspace is updated
to say `go` `1.21`, the program can opt back into the old `panic(nil)`
behavior by including this directive:
//go:debug panicnil=1
Starting in Go 1.21, the Go toolchain treats a `//go:debug` directive
with an unrecognized GODEBUG setting as an invalid program.
Programs with more than one `//go:debug` line for a given setting
are also treated as invalid.
(Older toolchains ignore `//go:debug` directives entirely.)
The defaults that will be compiled into a main package
are reported by the command:
{{raw `
go list -f '{{.DefaultGODEBUG}}' my/main/package
`}}
Only differences from the base Go toolchain defaults are reported.
When testing a package, `//go:debug` lines in the `*_test.go`
files are treated as directives for the test's main package.
In any other context, `//go:debug` lines are ignored by the toolchain;
`go` `vet` reports such lines as misplaced.
## GODEBUG History {#history}
This section documents the GODEBUG settings introduced and removed in each major Go release
for compatibility reasons.
Packages or programs may define additional settings for internal debugging purposes;
for example,
see the [runtime documentation](/pkg/runtime#hdr-Environment_Variables)
and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
### Go 1.21
Go 1.21 made it a run-time error to call `panic` with a nil interface value,
controlled by the [`panicnil` setting](/pkg/builtin/#panic).
Go 1.21 made it an error for html/template actions to appear inside of an ECMAScript 6
template literal, controlled by the
[`jstmpllitinterp` setting](/pkg/html/template#hdr-Security_Model).
This behavior was backported to Go 1.19.8+ and Go 1.20.3+.
Go 1.21 introduced a limit on the maximum number of MIME headers and multipart
forms, controlled by the
[`multipartmaxheaders` and `multipartmaxparts` settings](/pkg/mime/multipart#hdr-Limits)
respectively.
This behavior was backported to Go 1.19.8+ and Go 1.20.3+.
There is no plan to remove any of these settings.
### Go 1.20
Go 1.20 introduced support for rejecting insecure paths in tar and zip archives,
controlled by the [`tarinsecurepath` setting](/pkg/archive/tar/#Reader.Next)
and the [`zipinsecurepath` setting](/pkg/archive/zip/#NewReader).
These default to `tarinsecurepath=1` and `zipinsecurepath=1`,
preserving the behavior of earlier versions of Go.
A future version of Go may change the defaults to
`tarinsecurepath=0` and `zipinsecurepath=0`.
Go 1.20 introduced automatic seeding of the
[`math/rand`](/pkg/math/rand) global random number generator,
controlled by the [`randautoseed` setting](/pkg/math/rand/#Seed).
Go 1.20 introduced the concept of fallback roots for use during certificate verification,
controlled by the [`x509usefallbackroots` setting](/pkg/crypto/x509/#SetFallbackRoots).
Go 1.20 removed the preinstalled `.a` files for the standard library
from the Go distribution.
Installations now build and cache the standard library like
packages in other modules.
The [`installgoroot` setting](/cmd/go#hdr-Compile_and_install_packages_and_dependencies)
restores the installation and use of preinstalled `.a` files.
There is no plan to remove any of these settings.
### Go 1.19
Go 1.19 made it an error for path lookups to resolve to binaries in the current directory,
controlled by the [`execerrdot` setting](/pkg/os/exec#hdr-Executables_in_the_current_directory).
There is no plan to remove this setting.
### Go 1.18
Go 1.18 removed support for SHA1 in most X.509 certificates,
controlled by the [`x509sha1` setting](/crypto/x509#InsecureAlgorithmError).
This setting will be removed in a future release, Go 1.22 at the earliest.
### Go 1.10
Go 1.10 changed how build caching worked and added test caching, along
with the [`gocacheverify`, `gocachehash`, and `gocachetest` settings](/cmd/go/#hdr-Build_and_test_caching).
There is no plan to remove these settings.
### Go 1.6
Go 1.6 introduced transparent support for HTTP/2,
controlled by the [`http2client`, `http2server`, and `http2debug` settings](/pkg/net/http/#hdr-HTTP_2).
There is no plan to remove these settings.
### Go 1.5
Go 1.5 introduced a pure Go DNS resolver,
controlled by the [`netdns` setting](/pkg/net/#hdr-Name_Resolution).
There is no plan to remove this setting.

12
go.env
View File

@@ -1,12 +0,0 @@
# This file contains the initial defaults for go command configuration.
# Values set by 'go env -w' and written to the user's go/env file override these.
# The environment overrides everything else.
# Use the Go module mirror and checksum database by default.
# See https://proxy.golang.org for details.
GOPROXY=https://proxy.golang.org,direct
GOSUMDB=sum.golang.org
# Automatically download newer toolchains as directed by go.mod files.
# See https://go.dev/doc/toolchain for details.
GOTOOLCHAIN=auto

View File

@@ -24,8 +24,8 @@
# in the CL match the update.bash in the CL.
# Versions to use.
CODE=2023c
DATA=2023c
CODE=2022g
DATA=2022g
set -e
@@ -48,8 +48,9 @@ fi
cd zoneinfo
../mkzip ../../zoneinfo.zip
cd ../..
go generate time/tzdata
files="update.bash zoneinfo.zip"
files="update.bash zoneinfo.zip ../../src/time/tzdata/zipdata.go"
modified=true
if git diff --quiet $files; then
modified=false

Binary file not shown.

View File

@@ -0,0 +1,340 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build ignore
// +build ignore
// This program can be used as go_android_GOARCH_exec by the Go tool.
// It executes binaries on an android device using adb.
package main
import (
"errors"
"fmt"
"go/build"
"io"
"log"
"os"
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"strconv"
"strings"
"syscall"
)
func run(args ...string) (string, error) {
cmd := adbCmd(args...)
buf := new(strings.Builder)
cmd.Stdout = io.MultiWriter(os.Stdout, buf)
// If the adb subprocess somehow hangs, go test will kill this wrapper
// and wait for our os.Stderr (and os.Stdout) to close as a result.
// However, if the os.Stderr (or os.Stdout) file descriptors are
// passed on, the hanging adb subprocess will hold them open and
// go test will hang forever.
//
// Avoid that by wrapping stderr, breaking the short circuit and
// forcing cmd.Run to use another pipe and goroutine to pass
// along stderr from adb.
cmd.Stderr = struct{ io.Writer }{os.Stderr}
err := cmd.Run()
if err != nil {
return "", fmt.Errorf("adb %s: %v", strings.Join(args, " "), err)
}
return buf.String(), nil
}
func adb(args ...string) error {
if out, err := adbCmd(args...).CombinedOutput(); err != nil {
fmt.Fprintf(os.Stderr, "adb %s\n%s", strings.Join(args, " "), out)
return err
}
return nil
}
func adbCmd(args ...string) *exec.Cmd {
if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" {
args = append(strings.Split(flags, " "), args...)
}
return exec.Command("adb", args...)
}
const (
deviceRoot = "/data/local/tmp/go_android_exec"
deviceGoroot = deviceRoot + "/goroot"
)
func main() {
log.SetFlags(0)
log.SetPrefix("go_android_exec: ")
exitCode, err := runMain()
if err != nil {
log.Fatal(err)
}
os.Exit(exitCode)
}
func runMain() (int, error) {
// Concurrent use of adb is flaky, so serialize adb commands.
// See https://github.com/golang/go/issues/23795 or
// https://issuetracker.google.com/issues/73230216.
lockPath := filepath.Join(os.TempDir(), "go_android_exec-adb-lock")
lock, err := os.OpenFile(lockPath, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return 0, err
}
defer lock.Close()
if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX); err != nil {
return 0, err
}
// In case we're booting a device or emulator alongside all.bash, wait for
// it to be ready. adb wait-for-device is not enough, we have to
// wait for sys.boot_completed.
if err := adb("wait-for-device", "exec-out", "while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;"); err != nil {
return 0, err
}
// Done once per make.bash.
if err := adbCopyGoroot(); err != nil {
return 0, err
}
// Prepare a temporary directory that will be cleaned up at the end.
// Binary names can conflict.
// E.g. template.test from the {html,text}/template packages.
binName := filepath.Base(os.Args[1])
deviceGotmp := fmt.Sprintf(deviceRoot+"/%s-%d", binName, os.Getpid())
deviceGopath := deviceGotmp + "/gopath"
defer adb("exec-out", "rm", "-rf", deviceGotmp) // Clean up.
// Determine the package by examining the current working
// directory, which will look something like
// "$GOROOT/src/mime/multipart" or "$GOPATH/src/golang.org/x/mobile".
// We extract everything after the $GOROOT or $GOPATH to run on the
// same relative directory on the target device.
subdir, inGoRoot, err := subdir()
if err != nil {
return 0, err
}
deviceCwd := filepath.Join(deviceGopath, subdir)
if inGoRoot {
deviceCwd = filepath.Join(deviceGoroot, subdir)
} else {
if err := adb("exec-out", "mkdir", "-p", deviceCwd); err != nil {
return 0, err
}
if err := adbCopyTree(deviceCwd, subdir); err != nil {
return 0, err
}
// Copy .go files from the package.
goFiles, err := filepath.Glob("*.go")
if err != nil {
return 0, err
}
if len(goFiles) > 0 {
args := append(append([]string{"push"}, goFiles...), deviceCwd)
if err := adb(args...); err != nil {
return 0, err
}
}
}
deviceBin := fmt.Sprintf("%s/%s", deviceGotmp, binName)
if err := adb("push", os.Args[1], deviceBin); err != nil {
return 0, err
}
// Forward SIGQUIT from the go command to show backtraces from
// the binary instead of from this wrapper.
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGQUIT)
go func() {
for range quit {
// We don't have the PID of the running process; use the
// binary name instead.
adb("exec-out", "killall -QUIT "+binName)
}
}()
// In light of
// https://code.google.com/p/android/issues/detail?id=3254
// dont trust the exitcode of adb. Instead, append the exitcode to
// the output and parse it from there.
const exitstr = "exitcode="
cmd := `export TMPDIR="` + deviceGotmp + `"` +
`; export GOROOT="` + deviceGoroot + `"` +
`; export GOPATH="` + deviceGopath + `"` +
`; export CGO_ENABLED=0` +
`; export GOPROXY=` + os.Getenv("GOPROXY") +
`; export GOCACHE="` + deviceRoot + `/gocache"` +
`; export PATH=$PATH:"` + deviceGoroot + `/bin"` +
`; cd "` + deviceCwd + `"` +
"; '" + deviceBin + "' " + strings.Join(os.Args[2:], " ") +
"; echo -n " + exitstr + "$?"
output, err := run("exec-out", cmd)
signal.Reset(syscall.SIGQUIT)
close(quit)
if err != nil {
return 0, err
}
exitIdx := strings.LastIndex(output, exitstr)
if exitIdx == -1 {
return 0, fmt.Errorf("no exit code: %q", output)
}
code, err := strconv.Atoi(output[exitIdx+len(exitstr):])
if err != nil {
return 0, fmt.Errorf("bad exit code: %v", err)
}
return code, nil
}
// subdir determines the package based on the current working directory,
// and returns the path to the package source relative to $GOROOT (or $GOPATH).
func subdir() (pkgpath string, underGoRoot bool, err error) {
cwd, err := os.Getwd()
if err != nil {
return "", false, err
}
cwd, err = filepath.EvalSymlinks(cwd)
if err != nil {
return "", false, err
}
goroot, err := filepath.EvalSymlinks(runtime.GOROOT())
if err != nil {
return "", false, err
}
if subdir, err := filepath.Rel(goroot, cwd); err == nil {
if !strings.Contains(subdir, "..") {
return subdir, true, nil
}
}
for _, p := range filepath.SplitList(build.Default.GOPATH) {
pabs, err := filepath.EvalSymlinks(p)
if err != nil {
return "", false, err
}
if subdir, err := filepath.Rel(pabs, cwd); err == nil {
if !strings.Contains(subdir, "..") {
return subdir, false, nil
}
}
}
return "", false, fmt.Errorf("the current path %q is not in either GOROOT(%q) or GOPATH(%q)",
cwd, runtime.GOROOT(), build.Default.GOPATH)
}
// adbCopyTree copies testdata, go.mod, go.sum files from subdir
// and from parent directories all the way up to the root of subdir.
// go.mod and go.sum files are needed for the go tool modules queries,
// and the testdata directories for tests. It is common for tests to
// reach out into testdata from parent packages.
func adbCopyTree(deviceCwd, subdir string) error {
dir := ""
for {
for _, path := range []string{"testdata", "go.mod", "go.sum"} {
path := filepath.Join(dir, path)
if _, err := os.Stat(path); err != nil {
continue
}
devicePath := filepath.Join(deviceCwd, dir)
if err := adb("exec-out", "mkdir", "-p", devicePath); err != nil {
return err
}
if err := adb("push", path, devicePath); err != nil {
return err
}
}
if subdir == "." {
break
}
subdir = filepath.Dir(subdir)
dir = filepath.Join(dir, "..")
}
return nil
}
// adbCopyGoroot clears deviceRoot for previous versions of GOROOT, GOPATH
// and temporary data. Then, it copies relevant parts of GOROOT to the device,
// including the go tool built for android.
// A lock file ensures this only happens once, even with concurrent exec
// wrappers.
func adbCopyGoroot() error {
// Also known by cmd/dist. The bootstrap command deletes the file.
statPath := filepath.Join(os.TempDir(), "go_android_exec-adb-sync-status")
stat, err := os.OpenFile(statPath, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
return err
}
defer stat.Close()
// Serialize check and copying.
if err := syscall.Flock(int(stat.Fd()), syscall.LOCK_EX); err != nil {
return err
}
s, err := io.ReadAll(stat)
if err != nil {
return err
}
if string(s) == "done" {
return nil
}
// Delete GOROOT, GOPATH and any leftover test data.
if err := adb("exec-out", "rm", "-rf", deviceRoot); err != nil {
return err
}
deviceBin := filepath.Join(deviceGoroot, "bin")
if err := adb("exec-out", "mkdir", "-p", deviceBin); err != nil {
return err
}
goroot := runtime.GOROOT()
// Build go for android.
goCmd := filepath.Join(goroot, "bin", "go")
tmpGo, err := os.CreateTemp("", "go_android_exec-cmd-go-*")
if err != nil {
return err
}
tmpGo.Close()
defer os.Remove(tmpGo.Name())
if out, err := exec.Command(goCmd, "build", "-o", tmpGo.Name(), "cmd/go").CombinedOutput(); err != nil {
return fmt.Errorf("failed to build go tool for device: %s\n%v", out, err)
}
deviceGo := filepath.Join(deviceBin, "go")
if err := adb("push", tmpGo.Name(), deviceGo); err != nil {
return err
}
for _, dir := range []string{"src", "test", "lib", "api"} {
if err := adb("push", filepath.Join(goroot, dir), filepath.Join(deviceGoroot)); err != nil {
return err
}
}
// Copy only the relevant from pkg.
if err := adb("exec-out", "mkdir", "-p", filepath.Join(deviceGoroot, "pkg", "tool")); err != nil {
return err
}
if err := adb("push", filepath.Join(goroot, "pkg", "include"), filepath.Join(deviceGoroot, "pkg")); err != nil {
return err
}
runtimea, err := exec.Command(goCmd, "list", "-f", "{{.Target}}", "runtime").Output()
pkgdir := filepath.Dir(string(runtimea))
if pkgdir == "" {
return errors.New("could not find android pkg dir")
}
if err := adb("push", pkgdir, filepath.Join(deviceGoroot, "pkg")); err != nil {
return err
}
tooldir := filepath.Join(goroot, "pkg", "tool", filepath.Base(pkgdir))
if err := adb("push", tooldir, filepath.Join(deviceGoroot, "pkg", "tool")); err != nil {
return err
}
if _, err := stat.Write([]byte("done")); err != nil {
return err
}
return nil
}

58
misc/arm/a Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Copyright 2010 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# This is a small script for executing go binaries on the android platform.
#
# example:
# ./a 5.out foo bar baz
#
# The script exports the local values of GOARCH, GOTRACEBACK and GOGC
# to the android environment.
#
# Known issues:
# The script fails unless the last character output by the program is "\n"
#
# TODO(kaib): add gdb bridge support
exp ()
{
if [ ${!1} ]; then
echo "export $1=\"${!1}\"; "
fi
}
# adb does not correctly return the exit value of the executed program. use this
# wrapper to manually extract the exit value
rloc=/data/local/tmp/retval
rsize=$(adb shell "ls -l $rloc"|tr -s ' '|cut -d' ' -f4)
rcheck=38
if [ "$rsize" != "$rcheck" ]; then
# echo "debug: retval size incorrect want $rcheck, got $rsize. uploading"
echo >/tmp/adb.retval '#!/system/bin/sh
"$@"
echo RETVAL: $?'
adb push /tmp/adb.retval $rloc >/dev/null 2>&1
adb shell chmod 755 $rloc
fi
# run the main binary
if [ "-g" == "$1" ]; then
adb forward tcp:$2 tcp:$2
args=$(echo $*| cut -d' ' -f4-)
adb push $3 /data/local/tmp/$3 >/dev/null 2>&1
adb shell "$(exp GOARCH) $(exp GOTRACEBACK) $(exp GOGC) \
gdbserver :$2 /data/local/tmp/retval /data/local/tmp/$3 $args" \
2>&1|tr -d '\r' |tee /tmp/adb.out|grep -v RETVAL
else
if [ "$*" != "$1" ]; then
args=$(echo $*| cut -d' ' -f2-)
fi
adb push $1 /data/local/tmp/$1 >/dev/null 2>&1
adb shell "$(exp GOARCH) $(exp GOTRACEBACK) $(exp GOGC) \
/data/local/tmp/retval /data/local/tmp/$1 $args" \
2>&1|tr -d '\r' |tee /tmp/adb.out|grep -v RETVAL
fi
exit $(grep RETVAL /tmp/adb.out|tr -d '\n\r'| cut -d' ' -f2)

View File

@@ -12,7 +12,6 @@ import (
"go/ast"
"go/parser"
"go/token"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
@@ -66,9 +65,6 @@ func (v *Visitor) Visit(node ast.Node) ast.Visitor {
}
func TestArgumentsPositions(t *testing.T) {
testenv.MustHaveCGO(t)
testenv.MustHaveExec(t)
testdata, err := filepath.Abs("testdata")
if err != nil {
t.Fatal(err)

View File

@@ -6,8 +6,6 @@ package errorstest
import (
"bytes"
"cmd/internal/quoted"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
@@ -41,9 +39,6 @@ func main() {
`
func TestBadSymbol(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
dir := t.TempDir()
mkdir := func(base string) string {
@@ -172,14 +167,7 @@ func TestBadSymbol(t *testing.T) {
}
func cCompilerCmd(t *testing.T) []string {
cc, err := quoted.Split(goEnv(t, "CC"))
if err != nil {
t.Skipf("parsing go env CC: %s", err)
}
if len(cc) == 0 {
t.Skipf("no C compiler")
}
testenv.MustHaveExecPath(t, cc[0])
cc := []string{goEnv(t, "CC")}
out := goEnv(t, "GOGCCFLAGS")
quote := '\000'

View File

@@ -7,7 +7,6 @@ package errorstest
import (
"bytes"
"fmt"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
@@ -23,8 +22,6 @@ func path(file string) string {
func check(t *testing.T, file string) {
t.Run(file, func(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
t.Parallel()
contents, err := os.ReadFile(path(file))
@@ -92,8 +89,6 @@ func expect(t *testing.T, file string, errors []*regexp.Regexp) {
}
func sizeofLongDouble(t *testing.T) int {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
cmd := exec.Command("go", "run", path("long_double_size.go"))
out, err := cmd.CombinedOutput()
if err != nil {
@@ -139,8 +134,6 @@ func TestToleratesOptimizationFlag(t *testing.T) {
} {
cflags := cflags
t.Run(cflags, func(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
t.Parallel()
cmd := exec.Command("go", "build", path("issue14669.go"))
@@ -154,8 +147,6 @@ func TestToleratesOptimizationFlag(t *testing.T) {
}
func TestMallocCrashesOnNil(t *testing.T) {
testenv.MustHaveCGO(t)
testenv.MustHaveGoRun(t)
t.Parallel()
cmd := exec.Command("go", "run", path("malloc.go"))

View File

@@ -10,12 +10,9 @@ import (
"bytes"
"flag"
"fmt"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
"runtime"
"slices"
"strings"
"sync/atomic"
"testing"
@@ -164,17 +161,6 @@ var ptrTests = []ptrTest{
fail: true,
expensive: true,
},
{
// Storing a pinned Go pointer into C memory should succeed.
name: "barrierpinnedok",
c: `#include <stdlib.h>
char **f14a2() { return malloc(sizeof(char*)); }
void f14b2(char **p) {}`,
imports: []string{"runtime"},
body: `var pinr runtime.Pinner; p := C.f14a2(); x := new(C.char); pinr.Pin(x); *p = x; C.f14b2(p); pinr.Unpin()`,
fail: false,
expensive: true,
},
{
// Storing a Go pointer into C memory by assigning a
// large value should fail.
@@ -445,54 +431,10 @@ var ptrTests = []ptrTest{
body: `s := &S40{p: new(int)}; C.f40((*C.struct_S40i)(&s.a))`,
fail: false,
},
{
// Test that we handle unsafe.StringData.
name: "stringdata",
c: `void f41(void* p) {}`,
imports: []string{"unsafe"},
body: `s := struct { a [4]byte; p *int }{p: new(int)}; str := unsafe.String(&s.a[0], 4); C.f41(unsafe.Pointer(unsafe.StringData(str)))`,
fail: false,
},
{
name: "slicedata",
c: `void f42(void* p) {}`,
imports: []string{"unsafe"},
body: `s := []*byte{nil, new(byte)}; C.f42(unsafe.Pointer(unsafe.SliceData(s)))`,
fail: true,
},
{
name: "slicedata2",
c: `void f43(void* p) {}`,
imports: []string{"unsafe"},
body: `s := struct { a [4]byte; p *int }{p: new(int)}; C.f43(unsafe.Pointer(unsafe.SliceData(s.a[:])))`,
fail: false,
},
}
func TestPointerChecks(t *testing.T) {
testenv.MustHaveGoBuild(t)
testenv.MustHaveCGO(t)
if runtime.GOOS == "windows" {
// TODO: Skip just the cases that fail?
t.Skipf("some tests fail to build on %s", runtime.GOOS)
}
var gopath string
var dir string
if *tmp != "" {
gopath = *tmp
dir = ""
} else {
d, err := os.MkdirTemp("", filepath.Base(t.Name()))
if err != nil {
t.Fatal(err)
}
dir = d
gopath = d
}
exe := buildPtrTests(t, gopath, false)
exe2 := buildPtrTests(t, gopath, true)
dir, exe := buildPtrTests(t)
// We (TestPointerChecks) return before the parallel subtest functions do,
// so we can't just defer os.RemoveAll(dir). Instead we have to wait for
@@ -509,18 +451,30 @@ func TestPointerChecks(t *testing.T) {
os.RemoveAll(dir)
}
}()
testOne(t, pt, exe, exe2)
testOne(t, pt, exe)
})
}
}
func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
func buildPtrTests(t *testing.T) (dir, exe string) {
var gopath string
if *tmp != "" {
gopath = *tmp
dir = ""
} else {
d, err := os.MkdirTemp("", filepath.Base(t.Name()))
if err != nil {
t.Fatal(err)
}
dir = d
gopath = d
}
src := filepath.Join(gopath, "src", "ptrtest")
if err := os.MkdirAll(src, 0777); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(src, "go.mod"), []byte("module ptrtest\ngo 1.20"), 0666); err != nil {
if err := os.WriteFile(filepath.Join(src, "go.mod"), []byte("module ptrtest"), 0666); err != nil {
t.Fatal(err)
}
@@ -587,38 +541,15 @@ func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
t.Fatal(err)
}
exeName := "ptrtest.exe"
if cgocheck2 {
exeName = "ptrtest2.exe"
}
cmd := exec.Command("go", "build", "-o", exeName)
cmd := exec.Command("go", "build", "-o", "ptrtest.exe")
cmd.Dir = src
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
// Set or remove cgocheck2 from the environment.
goexperiment := strings.Split(os.Getenv("GOEXPERIMENT"), ",")
if len(goexperiment) == 1 && goexperiment[0] == "" {
goexperiment = nil
}
i := slices.Index(goexperiment, "cgocheck2")
changed := false
if cgocheck2 && i < 0 {
goexperiment = append(goexperiment, "cgocheck2")
changed = true
} else if !cgocheck2 && i >= 0 {
goexperiment = append(goexperiment[:i], goexperiment[i+1:]...)
changed = true
}
if changed {
cmd.Env = append(cmd.Env, "GOEXPERIMENT="+strings.Join(goexperiment, ","))
}
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("go build: %v\n%s", err, out)
}
return filepath.Join(src, exeName)
return dir, filepath.Join(src, "ptrtest.exe")
}
const ptrTestMain = `
@@ -635,7 +566,7 @@ func main() {
var csem = make(chan bool, 16)
func testOne(t *testing.T, pt ptrTest, exe, exe2 string) {
func testOne(t *testing.T, pt ptrTest, exe string) {
t.Parallel()
// Run the tests in parallel, but don't run too many
@@ -643,12 +574,7 @@ func testOne(t *testing.T, pt ptrTest, exe, exe2 string) {
runcmd := func(cgocheck string) ([]byte, error) {
csem <- true
defer func() { <-csem }()
x := exe
if cgocheck == "2" {
x = exe2
cgocheck = "1"
}
cmd := exec.Command(x, pt.name)
cmd := exec.Command(exe, pt.name)
cmd.Env = append(os.Environ(), "GODEBUG=cgocheck="+cgocheck)
return cmd.CombinedOutput()
}

View File

@@ -6,7 +6,6 @@ package fortran
import (
"fmt"
"internal/testenv"
"os"
"os/exec"
"path/filepath"
@@ -16,9 +15,6 @@ import (
)
func TestFortran(t *testing.T) {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
// Find the FORTRAN compiler.
fc := os.Getenv("FC")
if fc == "" {
@@ -67,7 +63,7 @@ func TestFortran(t *testing.T) {
}
// Do a test build that doesn't involve Go FORTRAN support.
fcArgs := append([]string{"testdata/helloworld/helloworld.f90", "-o", "/dev/null"}, fcExtra...)
fcArgs := append([]string{"helloworld/helloworld.f90", "-o", "/dev/null"}, fcExtra...)
t.Logf("%s %s", fc, fcArgs)
if err := exec.Command(fc, fcArgs...).Run(); err != nil {
t.Skipf("skipping Fortran test: could not build helloworld.f90 with %s: %s", fc, err)

View File

@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
//go:build ignore
// +build ignore
// Compute Fibonacci numbers with two goroutines
// that pass integers back and forth. No actual

View File

@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
//go:build ignore
// +build ignore
package main

View File

@@ -6,12 +6,11 @@ package life_test
import (
"bytes"
"cmd/cgo/internal/cgotest"
"internal/testenv"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
)
@@ -31,7 +30,7 @@ func testMain(m *testing.M) int {
// Copy testdata into GOPATH/src/cgolife, along with a go.mod file
// declaring the same path.
modRoot := filepath.Join(GOPATH, "src", "cgolife")
if err := cgotest.OverlayDir(modRoot, "testdata"); err != nil {
if err := overlayDir(modRoot, "testdata"); err != nil {
log.Panic(err)
}
if err := os.Chdir(modRoot); err != nil {
@@ -45,21 +44,20 @@ func testMain(m *testing.M) int {
return m.Run()
}
// TestTestRun runs a test case for cgo //export.
func TestTestRun(t *testing.T) {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
if os.Getenv("GOOS") == "android" {
t.Skip("the go tool runs with CGO_ENABLED=0 on the android device")
}
out, err := exec.Command("go", "env", "GOROOT").Output()
if err != nil {
t.Fatal(err)
}
GOROOT := string(bytes.TrimSpace(out))
cmd := exec.Command("go", "run", "main.go")
got, err := cmd.CombinedOutput()
cmd := exec.Command("go", "run", filepath.Join(GOROOT, "test", "run.go"), "-", ".")
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("%v: %s\n%s", cmd, err, got)
}
want, err := os.ReadFile("main.out")
if err != nil {
t.Fatal("reading golden output:", err)
}
if !bytes.Equal(got, want) {
t.Errorf("'%v' output does not match expected in main.out. Instead saw:\n%s", cmd, got)
t.Fatalf("%s: %s\n%s", strings.Join(cmd.Args, " "), err, out)
}
t.Logf("%s:\n%s", strings.Join(cmd.Args, " "), out)
}

View File

@@ -0,0 +1,78 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package life_test
import (
"io"
"os"
"path/filepath"
"strings"
)
// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added.
//
// TODO: Once we no longer need to support the misc module in GOPATH mode,
// factor this function out into a package to reduce duplication.
func overlayDir(dstRoot, srcRoot string) error {
dstRoot = filepath.Clean(dstRoot)
if err := os.MkdirAll(dstRoot, 0777); err != nil {
return err
}
srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
if err != nil || srcPath == srcRoot {
return err
}
suffix := strings.TrimPrefix(srcPath, srcRoot)
for len(suffix) > 0 && suffix[0] == filepath.Separator {
suffix = suffix[1:]
}
dstPath := filepath.Join(dstRoot, suffix)
perm := info.Mode() & os.ModePerm
if info.Mode()&os.ModeSymlink != 0 {
info, err = os.Stat(srcPath)
if err != nil {
return err
}
perm = info.Mode() & os.ModePerm
}
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}
// Otherwise, copy the bytes.
src, err := os.Open(srcPath)
if err != nil {
return err
}
defer src.Close()
dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
return err
}
_, err = io.Copy(dst, src)
if closeErr := dst.Close(); err == nil {
err = closeErr
}
return err
})
}

View File

@@ -1,3 +1,5 @@
// skip
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -20,9 +22,8 @@ func Run(gen, x, y int, a []int32) {
// Keep the channels visible from Go.
var chans [4]chan bool
// Double return value is just for testing.
//
//export GoStart
// Double return value is just for testing.
func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) {
c := make(chan bool, int(C.MYCONST))
go func() {

View File

@@ -1,8 +1,10 @@
// run -tags=use_go_run
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build test_run
// +build test_run
// Run the game of life in C using Go for parallelization.

View File

@@ -0,0 +1,78 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package stdio_test
import (
"io"
"os"
"path/filepath"
"strings"
)
// overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added.
//
// TODO: Once we no longer need to support the misc module in GOPATH mode,
// factor this function out into a package to reduce duplication.
func overlayDir(dstRoot, srcRoot string) error {
dstRoot = filepath.Clean(dstRoot)
if err := os.MkdirAll(dstRoot, 0777); err != nil {
return err
}
srcRoot, err := filepath.Abs(srcRoot)
if err != nil {
return err
}
return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
if err != nil || srcPath == srcRoot {
return err
}
suffix := strings.TrimPrefix(srcPath, srcRoot)
for len(suffix) > 0 && suffix[0] == filepath.Separator {
suffix = suffix[1:]
}
dstPath := filepath.Join(dstRoot, suffix)
perm := info.Mode() & os.ModePerm
if info.Mode()&os.ModeSymlink != 0 {
info, err = os.Stat(srcPath)
if err != nil {
return err
}
perm = info.Mode() & os.ModePerm
}
// Always copy directories (don't symlink them).
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
return os.MkdirAll(dstPath, perm|0200)
}
// If the OS supports symlinks, use them instead of copying bytes.
if err := os.Symlink(srcPath, dstPath); err == nil {
return nil
}
// Otherwise, copy the bytes.
src, err := os.Open(srcPath)
if err != nil {
return err
}
defer src.Close()
dst, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, perm)
if err != nil {
return err
}
_, err = io.Copy(dst, src)
if closeErr := dst.Close(); err == nil {
err = closeErr
}
return err
})
}

View File

@@ -6,8 +6,6 @@ package stdio_test
import (
"bytes"
"cmd/cgo/internal/cgotest"
"internal/testenv"
"log"
"os"
"os/exec"
@@ -32,7 +30,7 @@ func testMain(m *testing.M) int {
// Copy testdata into GOPATH/src/cgostdio, along with a go.mod file
// declaring the same path.
modRoot := filepath.Join(GOPATH, "src", "cgostdio")
if err := cgotest.OverlayDir(modRoot, "testdata"); err != nil {
if err := overlayDir(modRoot, "testdata"); err != nil {
log.Panic(err)
}
if err := os.Chdir(modRoot); err != nil {
@@ -46,32 +44,20 @@ func testMain(m *testing.M) int {
return m.Run()
}
// TestTestRun runs a cgo test that doesn't depend on non-standard libraries.
func TestTestRun(t *testing.T) {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
for _, file := range [...]string{
"chain.go",
"fib.go",
"hello.go",
} {
file := file
wantFile := strings.Replace(file, ".go", ".out", 1)
t.Run(file, func(t *testing.T) {
cmd := exec.Command("go", "run", file)
got, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%v: %s\n%s", cmd, err, got)
}
got = bytes.ReplaceAll(got, []byte("\r\n"), []byte("\n"))
want, err := os.ReadFile(wantFile)
if err != nil {
t.Fatal("reading golden output:", err)
}
if !bytes.Equal(got, want) {
t.Errorf("'%v' output does not match expected in %s. Instead saw:\n%s", cmd, wantFile, got)
}
})
if os.Getenv("GOOS") == "android" {
t.Skip("subpackage stdio is not available on android")
}
out, err := exec.Command("go", "env", "GOROOT").Output()
if err != nil {
t.Fatal(err)
}
GOROOT := string(bytes.TrimSpace(out))
cmd := exec.Command("go", "run", filepath.Join(GOROOT, "test", "run.go"), "-", ".")
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("%s: %s\n%s", strings.Join(cmd.Args, " "), err, out)
}
t.Logf("%s:\n%s", strings.Join(cmd.Args, " "), out)
}

View File

@@ -1,8 +1,10 @@
// run -tags=use_go_run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build test_run
// +build test_run
// Pass numbers along a chain of threads.

View File

@@ -1,8 +1,10 @@
// run -tags=use_go_run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build test_run
// +build test_run
// Compute Fibonacci numbers with two goroutines
// that pass integers back and forth. No actual

View File

@@ -1,8 +1,10 @@
// run -tags=use_go_run
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build test_run
// +build test_run
package main

150
misc/cgo/stdio/testdata/run.out vendored Normal file
View File

@@ -0,0 +1,150 @@
* hello
hello, world
* fib
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
1836311903
2971215073
4807526976
7778742049
12586269025
20365011074
32951280099
53316291173
86267571272
139583862445
225851433717
365435296162
591286729879
956722026041
1548008755920
2504730781961
4052739537881
6557470319842
10610209857723
17167680177565
27777890035288
44945570212853
72723460248141
117669030460994
190392490709135
308061521170129
498454011879264
806515533049393
1304969544928657
2111485077978050
3416454622906707
5527939700884757
8944394323791464
14472334024676221
23416728348467685
37889062373143906
61305790721611591
99194853094755497
160500643816367088
259695496911122585
420196140727489673
679891637638612258
1100087778366101931
1779979416004714189
2880067194370816120
* chain
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9
10
0
1
2
3
4
5
6
7
8
9
10

View File

@@ -1,3 +1,5 @@
// skip
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
@@ -5,7 +7,7 @@
/*
A trivial example of wrapping a C library in Go.
For a more complex example and explanation,
see misc/cgo/gmp/gmp.go.
see ../gmp/gmp.go.
*/
package stdio

View File

@@ -1,3 +1,5 @@
// skip
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

View File

@@ -211,7 +211,7 @@ func testCallbackCallers(t *testing.T) {
}
// In module mode, this package has a fully-qualified import path.
// Remove it if present.
fname = strings.TrimPrefix(fname, "cmd/cgo/internal/")
fname = strings.TrimPrefix(fname, "misc/cgo/")
namei := ""
if i < len(name) {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build gc
// +build gc
#include "_cgo_export.h"
#include <stdint.h>

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build gccgo
// +build gccgo
#include "_cgo_export.h"
#include <stdint.h>

View File

@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo
package cgotest
import (

View File

@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo
package cgotest
import "testing"
@@ -106,7 +104,6 @@ func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }
func BenchmarkCGoInCThread(b *testing.B) { benchCGoInCthread(b) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
func BenchmarkGoString(b *testing.B) { benchGoString(b) }
func BenchmarkCGoCallback(b *testing.B) { benchCallback(b) }

View File

@@ -2,25 +2,22 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux
//go:build linux && freebsd && openbsd
// +build linux,freebsd,openbsd
package cgotest
/*
#include <unistd.h>
#include <stdbool.h>
#include <sys/syscall.h>
void Gosched(void);
static bool Ctid(void) {
long tid1 = syscall(SYS_gettid);
Gosched();
return tid1 == syscall(SYS_gettid);
}
static int Ctid(void) { Gosched(); return syscall(SYS_gettid); }
*/
import "C"
import (
"runtime"
"syscall"
"testing"
"time"
)
@@ -50,7 +47,7 @@ func testThreadLock(t *testing.T) {
defer close(stop)
for i := 0; i < 1000; i++ {
if !C.Ctid() {
if C.int(syscall.Gettid()) != C.Ctid() {
t.Fatalf("cgo has not locked OS thread")
}
}

View File

@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo && !windows
//go:build !windows
// +build !windows
package cgotest

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
#include <pthread.h>
#include "_cgo_export.h"
@@ -32,27 +32,3 @@ doAdd(int max, int nthread)
for(i=0; i<nthread; i++)
pthread_join(thread_id[i], 0);
}
static void*
goDummyCallbackThread(void* p)
{
int i, max;
max = *(int*)p;
for(i=0; i<max; i++)
goDummy();
return NULL;
}
int
callGoInCThread(int max)
{
pthread_t thread;
if (pthread_create(&thread, NULL, goDummyCallbackThread, (void*)(&max)) != 0)
return -1;
if (pthread_join(thread, NULL) != 0)
return -1;
return max;
}

View File

@@ -35,25 +35,3 @@ doAdd(int max, int nthread)
CloseHandle((HANDLE)thread_id[i]);
}
}
__stdcall
static unsigned int
goDummyCallbackThread(void* p)
{
int i, max;
max = *(int*)p;
for(i=0; i<max; i++)
goDummy();
return 0;
}
int
callGoInCThread(int max)
{
uintptr_t thread_id;
thread_id = _beginthreadex(0, 0, goDummyCallbackThread, &max, 0, 0);
WaitForSingleObject((HANDLE)thread_id, INFINITE);
CloseHandle((HANDLE)thread_id);
return max;
}

View File

@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo
package cgotest
import (
"testing"
"cmd/cgo/internal/test/gcc68255"
"misc/cgo/test/gcc68255"
)
func testGCC68255(t *testing.T) {

View File

@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
//go:build linux && cgo
// +build linux,cgo
package cgotest

View File

@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo && !windows
//go:build !windows
// +build !windows
// Issue 18146: pthread_create failure during syscall.Exec.

View File

@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
//go:build darwin && cgo && !internal
// +build darwin,cgo,!internal
package cgotest

View File

@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
//go:build !darwin || !cgo || internal
// +build !darwin !cgo internal
package cgotest

View File

@@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo
// Test that we can have two identical cgo packages in a single binary.
// No runtime test; just make sure it compiles.
package cgotest
import (
_ "cmd/cgo/internal/test/issue23555a"
_ "cmd/cgo/internal/test/issue23555b"
_ "misc/cgo/test/issue23555a"
_ "misc/cgo/test/issue23555b"
)

View File

@@ -2,18 +2,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build cgo
package cgotest
import (
"testing"
"cmd/cgo/internal/test/issue24161arg"
"cmd/cgo/internal/test/issue24161e0"
"cmd/cgo/internal/test/issue24161e1"
"cmd/cgo/internal/test/issue24161e2"
"cmd/cgo/internal/test/issue24161res"
"misc/cgo/test/issue24161arg"
"misc/cgo/test/issue24161e0"
"misc/cgo/test/issue24161e1"
"misc/cgo/test/issue24161e2"
"misc/cgo/test/issue24161res"
)
func Test24161Arg(t *testing.T) {

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161arg

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161arg

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161e0

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161e1

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161e2

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin
// +build darwin
package issue24161res

Some files were not shown because too many files have changed in this diff Show More