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

59375 Commits

Author SHA1 Message Date
guoguangwu
1174efb5d6 strings: add strings helpers for prefixes and suffixes
Signed-off-by: guoguangwu <guoguangwug@gmail.com>
2024-03-12 09:42:02 +08:00
Jes Cok
69583738eb unicode/utf8: update doc for RuneLen
As CL 569755 did, for consistency, this CL slightly improves
the documentation for RuneLen.

Change-Id: Ic9776648baf2809af36cd16a94d1313938bb0e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/569816
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-03-08 02:00:36 +00:00
Cuong Manh Le
5a329c3bfb cmd/compile: fix copying SSA-able variables optimization
CL 541715 added an optimization to copy SSA-able variables.

When handling m[k] = append(m[k], ...) case, it uses ir.SameSafeExpr to
check that m[k] expressions are the same, then doing type assertion to
convert the map index to ir.IndexExpr node. However, this assertion is
not safe for m[k] expression in append(m[k], ...), since it may be
wrapped by ir.OCONVNOP node.

Fixing this by un-wrapping any ir.OCONVNOP before doing type assertion.

Fixes #66096

Change-Id: I9ff7165ab97bc7f88d0e9b7b31604da19a8ca206
Reviewed-on: https://go-review.googlesource.com/c/go/+/569716
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-08 02:00:33 +00:00
Alexander Yastrebov
8590f0aef3 net/http: remove persistConn reference from wantConn
Transport getConn creates wantConn w, tries to obtain idle connection for it
based on the w.key and, when there is no idle connection, puts wantConn into
idleConnWait wantConnQueue.

Then getConn dials connection for w in a goroutine and blocks.
After dial succeeds getConn unblocks and returns connection to the caller.

At this point w is stored in the idleConnWait and will not be evicted
until another wantConn with the same w.key is requested or alive
connection returned into the idle pool which may not happen e.g. if
server closes the connection.

The problem is that even after tryDeliver succeeds w references
persistConn wrapper that allocates bufio.Reader and bufio.Writer and
prevents them from being garbage collected.

To fix the problem this change removes persistConn and error references
from wantConn and delivers them via channel to getConn.

This way wantConn could be kept in wantConnQueues arbitrary long.

Fixes #43966
Fixes #50798

Change-Id: I77942552f7db04c225fb40d770b3101a8cfe655d
GitHub-Last-Rev: 027a0833f9
GitHub-Pull-Request: golang/go#62227
Reviewed-on: https://go-review.googlesource.com/c/go/+/522095
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-08 01:59:51 +00:00
apocelipes
b57a544f99 archive/tar: use built-in clear to simplify code
Change-Id: I0e55dd68d92c39aba511b55368bf50d929d75f86
GitHub-Last-Rev: 1743014078
GitHub-Pull-Request: golang/go#66158
Reviewed-on: https://go-review.googlesource.com/c/go/+/569696
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-08 01:59:14 +00:00
Tobias Klauser
80a91d34f4 os: use goarch.BigEndian
Change-Id: I83c23ae0933f6abe4c07144f69c3d9c18aece6e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/569175
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-08 01:59:11 +00:00
Tobias Klauser
1a800d1c88 syscall: use goarch.BigEndian
Change-Id: I99e5f6fab900b0bf301f78460c618c01b231f62b
Reviewed-on: https://go-review.googlesource.com/c/go/+/568956
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 01:59:07 +00:00
Michael Pratt
c57b18b48f cmd/go: always include action mode in trace name
For actions with no package, the title "Executing action" is extremely
vague. Add the action mode so that there is some differentiation.

Change-Id: If6dcf81c7cd1f19a9532e56dd9f88abd1182ea97
Reviewed-on: https://go-review.googlesource.com/c/go/+/567936
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 21:49:37 +00:00
Cuong Manh Le
cb733da42c net/http: set Cache-Control header only if presents on error
CL 544019 changes http.Error to remove misleading response headers.
However, it also adds new "Cache-Control" header unconditionally, which
may breaks existing clients out there, who do not expect to see the
this header in the response like test in golang.org/x/net/http2.

To keep thing backward compatible, http.Error should only add
Cache-Control header if it has been presented.

Updates #50905

Change-Id: I989e9f999a30ec170df4fb28905f50aed0267dad
Reviewed-on: https://go-review.googlesource.com/c/go/+/569815
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-07 20:48:58 +00:00
cui fliter
8d3703ed77 all: remove redundant string conversions when formatting []byte with %s
Change-Id: I1285ee047fd465f48028186ae04d4de60cc9969e
Reviewed-on: https://go-review.googlesource.com/c/go/+/569715
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 20:46:32 +00:00
Alex Driuk
7101fd1e97 sort: fix typo in sort_test.go
Change-Id: Ibc1344b678d5f7c730b924c697717305c90c26e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/569537
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-07 19:41:04 +00:00
Mauri de Souza Meneguzzo
db44044f75 internal/poll: change Fsync to fallback to syscall.Fsync on darwin
In certain scenarios, such as network mounts, calling Fsync results in
ENOTSUP in OSX. This issue was introduced in CL 130676 since
syscall.FSync was not properly flushing contents to disk, and it was
replaced with fcntl(fd, F_FULLSYNC). Most SMB servers, like Windows
Server and Samba don't support F_FULLSYNC.

To avoid such issues fallback to syscall.Fsync if fcntl returns ENOTSUP.

Fixes #64215

Change-Id: I567191e1179b7e70ddffb6b881469de1872746ef
GitHub-Last-Rev: 62e6931cf7
GitHub-Pull-Request: golang/go#64258
Reviewed-on: https://go-review.googlesource.com/c/go/+/543535
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-07 19:20:48 +00:00
Jes Cok
ef4f2a0597 unicode/utf16: add func RuneLen
This CL adds func RuneLen, while here, also uses RuneLen to simplify
code in Encode.

Fixes #44940

Change-Id: Ifd3b537f69880dfd32a69a6733d8d3c2b5d4ecba
Reviewed-on: https://go-review.googlesource.com/c/go/+/569755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-07 19:08:48 +00:00
guoguangwu
e0ba596c15 cmd/link: replace bytes.Compare call with bytes.Equal
Change-Id: Icc254cad3c861fd2b33228aa4d19424ce57a1b55
GitHub-Last-Rev: f557a696e4
GitHub-Pull-Request: golang/go#66153
Reviewed-on: https://go-review.googlesource.com/c/go/+/569695
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 19:08:09 +00:00
guoguangwu
47079b5e80 cmd/trace: fix typo in comment
Change-Id: I6ac2863e2af8c23588d35bf142f607e241f98405
GitHub-Last-Rev: 445cf7b29e
GitHub-Pull-Request: golang/go#66152
Reviewed-on: https://go-review.googlesource.com/c/go/+/569675
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 19:08:04 +00:00
guoguangwu
d44ec4c05f cmd/go: fix typo in comment
Change-Id: I211442f2bbdab29820126a350cbdb0886a10d6e5
GitHub-Last-Rev: 0347054a55
GitHub-Pull-Request: golang/go#66160
Reviewed-on: https://go-review.googlesource.com/c/go/+/569697
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2024-03-07 19:04:09 +00:00
Michael Matloob
f93f6e501e cmd/go: test that each script test increments at least one counter
Add code that will set a scriptGoInvoked bit for the testing.TB when
it invokes the go command. If the go command was invoked, make sure
that at least one counter was incremented.

Also add the counters cmd/go/gomodcache-entry-relative,
cmd/go/gopath-entry-relative, and cmd/go/invalid-toolchain-in-file so
we can increment counters when a test errors out before the flag
subcommand counters are processed. This enforces the invariant that at
least one counter is incremented by every test that invokes the go
command.

Add the counter cmd/go/exec-go-toolchain for when a toolchain switch
happens.

Add cmd/go/subcommand:help for invoking help without arguments and
cmd/go/help-unknown-topic for when an unknown command is provided
to help.

Change-Id: Id90f2bbe4c7e89b846da00ec1ed9595ece2b269c
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/568259
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 18:33:17 +00:00
Andy Pan
da5871d582 net: consolidate the existing Windows version checks
Change-Id: I9c0ad69bd61923e9e272f157dc380a9120f08423
Reviewed-on: https://go-review.googlesource.com/c/go/+/565595
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-07 16:46:10 +00:00
Andy Pan
1cce1a6a11 net: support TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT on newer Windows
Follows up CL 542275

Fixes #65817

Change-Id: I0b77c23f15d595d58492dfa20839a08e8670448b
Reviewed-on: https://go-review.googlesource.com/c/go/+/565495
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-07 16:02:18 +00:00
Joel Sing
997636760e cmd/compile,cmd/internal/obj: provide rotation pseudo-instructions for riscv64
Provide and use rotation pseudo-instructions for riscv64. The RISC-V bitmanip
extension adds support for hardware rotation instructions in the form of ROL,
ROLW, ROR, RORI, RORIW and RORW. These are easily implemented in the assembler
as pseudo-instructions for CPUs that do not support the bitmanip extension.

This approach provides a number of advantages, including reducing the rewrite
rules needed in the compiler, simplifying codegen tests and most importantly,
allowing these instructions to be used in assembly (for example, riscv64
optimised versions of SHA-256 and SHA-512). When bitmanip support is added,
these instruction sequences can simply be replaced with a single instruction
if permitted by the GORISCV64 profile.

Change-Id: Ia23402e1a82f211ac760690deb063386056ae1fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/565015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
2024-03-07 14:57:07 +00:00
Michael Matloob
58052fe8e7 cmd: update telemetry to d5a85b2
commands run:
	go get golang.org/x/telemetry@d5a85b2
	go mod tidy
	go mod vendor

Fixes #66099

Change-Id: Ia9215855f1472fa885792d5b23a986f29759af18
Reviewed-on: https://go-review.googlesource.com/c/go/+/569421
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
2024-03-07 05:27:04 +00:00
Michael Matloob
a062470186 cmd: update to golang.org/x/sys@v0.18.0
This is a requirement of x/telemetry so update it before updating
telemetry.

Commands run (in both std and cmd):
	go get golang.org/x/sys@v0.18.0
	go mod tidy
	go mod vendor

For #66099

Change-Id: I636f0c0be89c05b9213c461b1a2eb2a4afb8a84b
Reviewed-on: https://go-review.googlesource.com/c/go/+/569420
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
2024-03-07 05:26:45 +00:00
Marin Petrunic
90d24b4f4e net/ip: proper ipv6 address parsing
Fixes #57760

Change-Id: Ic3698a18e1c80833b07e0e06bc7328d9714794c6
GitHub-Last-Rev: d185467491
GitHub-Pull-Request: golang/go#57761
Reviewed-on: https://go-review.googlesource.com/c/go/+/461605
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-07 01:17:29 +00:00
guoguangwu
1922cef5d7 internal/fuzz: remove useless code
Change-Id: I4534a116ef421379b2356bbe80760adae8cdd95f
GitHub-Last-Rev: a3fab3f1fa
GitHub-Pull-Request: golang/go#65892
Reviewed-on: https://go-review.googlesource.com/c/go/+/566315
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-03-07 00:20:34 +00:00
Alexander Yastrebov
70fbc88288 net/http: add ResponseController http2 request without body read deadline test
Requires CL 464936

For #58237

Change-Id: I007b61f0f216d759f8e5327d77affbd9e8f8ff23
GitHub-Last-Rev: 30a10909b0
GitHub-Pull-Request: golang/go#58282
Reviewed-on: https://go-review.googlesource.com/c/go/+/465035
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-06 19:20:31 +00:00
qmuntal
911b066bf8 internal/syscall/windows/registry: append .dll when loading kernel32
Win32 LoadLibrary supports loading a DLL omitting the .dll extension,
but it is better to be explicit and include the extension. This is
consistent with all other uses of LoadLibrary in the Go standard
library.

Change-Id: I7349d0a27db5f8ab59061434f37d10918e43b869
Reviewed-on: https://go-review.googlesource.com/c/go/+/569535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-06 19:19:00 +00:00
Jes Cok
e2459e627f encoding/binary: use built-in clear to simplify code
Change-Id: I2f3c7f4a4848ad0fbbf79bd8919b1e2abee72f3f
GitHub-Last-Rev: 06d0047b28
GitHub-Pull-Request: golang/go#66136
Reviewed-on: https://go-review.googlesource.com/c/go/+/569280
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-06 19:15:56 +00:00
Mitar
d463de61b3 net/http: remove misleading response headers on error
ServeContent API is to set some headers you want to see in the response
before calling ServeContent. But if there is an error, those headers
should be removed otherwise they might confused the client.

Removing those headers is useful in general in the case of an error,
so we remove them in http.Error.

Fixes #50905.

Change-Id: If8d2786c1512906ac93e6b388df6ab1c5ecd1ea9
GitHub-Last-Rev: 32b6f045a7
GitHub-Pull-Request: golang/go#64312
Reviewed-on: https://go-review.googlesource.com/c/go/+/544019
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-06 19:15:50 +00:00
guoguangwu
25af691c43 cmd/dist: fix typo in comment
Change-Id: If8bcde960348ebafec2ced0e22f315685de0bb82
GitHub-Last-Rev: 4477ade97f
GitHub-Pull-Request: golang/go#66124
Reviewed-on: https://go-review.googlesource.com/c/go/+/569278
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-06 19:14:39 +00:00
guoguangwu
0e89b67ed2 database/sql: remove useless error check
Change-Id: Id2d45a4b43b05deba4e2c31f7c03008c2f2c18a2
GitHub-Last-Rev: 587bed9a64
GitHub-Pull-Request: golang/go#66110
Reviewed-on: https://go-review.googlesource.com/c/go/+/569075
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-06 19:14:36 +00:00
guoguangwu
f0d1195e13 internal/trace: remove unreachable code
Change-Id: If5c9801e8954ce7f517b90ea6c30ea3e9eec09ee
GitHub-Last-Rev: 135c8473ae
GitHub-Pull-Request: golang/go#66051
Reviewed-on: https://go-review.googlesource.com/c/go/+/568395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2024-03-06 16:24:06 +00:00
Alessandro Arzilli
f048829d70 cmd/compile: mark DIEs of captured variables
Adds a new custom attribute to the DIE of captured variables,
containing the offset for the variable inside the closure struct. This
can be used by debuggers to display the contents of a closure variable.

Based on a sample program (delve) this increases the executable size by 0.06%.

benchstat output:

                         │   old.txt    │                new.txt                │
                         │    sec/op    │     sec/op      vs base               │
Template                   153.0m ±  6%    152.5m ±  14%       ~ (p=0.684 n=10)
Unicode                    100.2m ± 15%    104.9m ±   7%       ~ (p=0.247 n=10)
GoTypes                    943.6m ±  8%    986.2m ±  10%       ~ (p=0.280 n=10)
Compiler                   97.79m ±  6%   101.63m ±  12%       ~ (p=0.393 n=10)
SSA                         6.872 ± 37%     9.413 ± 106%       ~ (p=0.190 n=10)
Flate                      128.0m ± 36%    125.0m ±  56%       ~ (p=0.481 n=10)
GoParser                   214.9m ± 26%    201.4m ±  68%       ~ (p=0.579 n=10)
Reflect                    452.6m ± 22%    412.2m ±  74%       ~ (p=0.739 n=10)
Tar                        166.2m ± 27%    155.9m ±  73%       ~ (p=0.393 n=10)
XML                        219.3m ± 24%    211.3m ±  76%       ~ (p=0.739 n=10)
LinkCompiler               523.2m ± 13%    513.5m ±  47%       ~ (p=0.631 n=10)
ExternalLinkCompiler        1.684 ±  2%     1.659 ±  25%       ~ (p=0.218 n=10)
LinkWithoutDebugCompiler   304.9m ± 12%    309.1m ±   7%       ~ (p=0.631 n=10)
StdCmd                      70.76 ± 14%     68.66 ±  53%       ~ (p=1.000 n=10)
geomean                    511.5m          515.4m         +0.77%

                         │   old.txt    │               new.txt                │
                         │ user-sec/op  │  user-sec/op   vs base               │
Template                   269.6m ± 13%   292.3m ±  17%       ~ (p=0.393 n=10)
Unicode                    110.2m ±  8%   101.7m ±  18%       ~ (p=0.247 n=10)
GoTypes                     2.181 ±  9%    2.356 ±  12%       ~ (p=0.280 n=10)
Compiler                   119.1m ± 11%   121.9m ±  15%       ~ (p=0.481 n=10)
SSA                         17.75 ± 52%    26.94 ± 123%       ~ (p=0.190 n=10)
Flate                      256.2m ± 43%   226.8m ±  73%       ~ (p=0.739 n=10)
GoParser                   427.0m ± 24%   422.3m ±  72%       ~ (p=0.529 n=10)
Reflect                    990.5m ± 23%   905.5m ±  75%       ~ (p=0.912 n=10)
Tar                        307.9m ± 27%   308.9m ±  64%       ~ (p=0.393 n=10)
XML                        432.8m ± 24%   427.6m ±  89%       ~ (p=0.796 n=10)
LinkCompiler               796.9m ± 14%   800.4m ±  56%       ~ (p=0.481 n=10)
ExternalLinkCompiler        1.666 ±  4%    1.671 ±  28%       ~ (p=0.971 n=10)
LinkWithoutDebugCompiler   316.7m ± 12%   325.6m ±   8%       ~ (p=0.579 n=10)
geomean                    579.5m         594.0m         +2.51%

          │   old.txt    │                new.txt                │
          │  text-bytes  │  text-bytes   vs base                 │
HelloSize   842.9Ki ± 0%   842.9Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   10.95Mi ± 0%   10.95Mi ± 0%       ~ (p=1.000 n=10) ¹
geomean     3.003Mi        3.003Mi       +0.00%
¹ all samples are equal

          │   old.txt    │                new.txt                │
          │  data-bytes  │  data-bytes   vs base                 │
HelloSize   15.08Ki ± 0%   15.08Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   314.7Ki ± 0%   314.7Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     68.88Ki        68.88Ki       +0.00%
¹ all samples are equal

          │   old.txt    │                new.txt                │
          │  bss-bytes   │  bss-bytes    vs base                 │
HelloSize   396.8Ki ± 0%   396.8Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   428.8Ki ± 0%   428.8Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     412.5Ki        412.5Ki       +0.00%
¹ all samples are equal

          │   old.txt    │               new.txt               │
          │  exe-bytes   │  exe-bytes    vs base               │
HelloSize   1.310Mi ± 0%   1.310Mi ± 0%  +0.02% (p=0.000 n=10)
CmdGoSize   16.37Mi ± 0%   16.38Mi ± 0%  +0.01% (p=0.000 n=10)
geomean     4.631Mi        4.632Mi       +0.02%

Change-Id: Ib416ee2d916ec61ad4a5c26bab09597595f57e04
Reviewed-on: https://go-review.googlesource.com/c/go/+/563816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-03-06 15:23:18 +00:00
Andrey Bokhanko
e8b5bc63be cmd/dist,internal: add GOARM64 environment variable
Adds GOARM64 environment variable with accepted range of values "v8.{0-9}",
"v9.{0-5}" and optional ",lse" and ",crypto" suffixes.

Right now it doesn't affect anything, but can be used in the future to
selectively target specific versions of different ARM64 hardware.

For #60905

Change-Id: I6d530041b6931aa884e34f719f8ec41b1cb03ece
Reviewed-on: https://go-review.googlesource.com/c/go/+/559555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Shu-Chun Weng <scw@google.com>
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
2024-03-06 01:33:19 +00:00
Ian Lance Taylor
9e3b1d53a0 slices: document that Clone can return extra capacity
Change-Id: I8b9aa1f36ce554d8855ee70e15f0dd0a8cf1097a
Reviewed-on: https://go-review.googlesource.com/c/go/+/568342
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-03-05 20:52:30 +00:00
Damien Neil
16e5d24480 net/textproto, mime/multipart: avoid unbounded read in MIME header
mime/multipart.Reader.ReadForm allows specifying the maximum amount
of memory that will be consumed by the form. While this limit is
correctly applied to the parsed form data structure, it was not
being applied to individual header lines in a form.

For example, when presented with a form containing a header line
that never ends, ReadForm will continue to read the line until it
runs out of memory.

Limit the amount of data consumed when reading a header.

Fixes CVE-2023-45290
Fixes #65383

Change-Id: I7f9264d25752009e95f6b2c80e3d76aaf321d658
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2134435
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/569341
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-05 18:31:56 +00:00
Damien Neil
821bf37819 net/http, net/http/cookiejar: avoid subdomain matches on IPv6 zones
When deciding whether to forward cookies or sensitive headers
across a redirect, do not attempt to interpret an IPv6 address
as a domain name.

Avoids a case where a maliciously-crafted redirect to an
IPv6 address with a scoped addressing zone could be
misinterpreted as a within-domain redirect. For example,
we could interpret "::1%.www.example.com" as a subdomain
of "www.example.com".

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes CVE-2023-45289
Fixes #65065

Change-Id: I8f463f59f0e700c8a18733d2b264a8bcb3a19599
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2131938
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/569340
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-03-05 18:31:54 +00:00
Roland Shoemaker
afb105056d crypto/x509: make sure pub key is non-nil before interface conversion
alreadyInChain assumes all keys fit a interface which contains the
Equal method (which they do), but this ignores that certificates may
have a nil key when PublicKeyAlgorithm is UnknownPublicKeyAlgorithm. In
this case alreadyInChain panics.

Check that the key is non-nil as part of considerCandidate (we are never
going to build a chain containing UnknownPublicKeyAlgorithm anyway).

Fixes #65390
Fixes CVE-2024-24783

Change-Id: Ibdccc0a487e3368b6812be35daad2512220243f3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2137282
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/+/569339
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-03-05 18:28:56 +00:00
qmuntal
5e387b2fee os: fix 63703.md release notes
63703.md contains a paragraph that shouldn't be there,
remove it.

While here, fix a test error message related to the #63703
implementation.

Updates #63703.

Change-Id: I82a8b0b7dfa8f96530fb9a3a3aa971e03970f168
Reviewed-on: https://go-review.googlesource.com/c/go/+/569195
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-05 16:20:15 +00:00
Michael Matloob
5dcc04aeac cmd/go/internal/modload: make it clear -mod can't be set in some cases
We check that -mod can't be set to mod in workspace mode, but then we
set BuildMod to mod for go work sync below. Make it clear that that's
okay because we can't pass -mod=mod to go work sync (or the other go
mod commands that can run in workspace mode that set mod=mod: go mod
graph, go mod verify, and go mod why).

Change-Id: Idfe6fea6a420211886e4f838e050be4bf7d1b71d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497617
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 21:01:23 +00:00
qmuntal
b09ac10bad os: don't normalize volumes to drive letters in os.Readlink
This CL updates os.Readlink so it no longer tries to normalize volumes
to drive letters, which was not always even possible.

This behavior is controlled by the `winreadlinkvolume` setting.
For Go 1.23, it defaults to `winreadlinkvolume=1`.
Previous versions default to `winreadlinkvolume=0`.

Fixes #63703.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Icd6fabbc8f0b78e23a82eef8db89940e89e9222d
Reviewed-on: https://go-review.googlesource.com/c/go/+/567735
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 20:38:54 +00:00
Than McIntosh
2b22fc1045 cmd/go: respect -coverpkg for unselected no-test packages
This patch fixes a bug in the code that reports coverage percentages
and/or profiles for packages without tests. Specifically, the code
added as part of the fix for issue 24570 (in CL 495447) didn't
properly consider the -coverpkg selection and would look for the build
action meta-data file for a package that wasn't actually selected for
coverage.

Fixes #65653.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: I66ffac11783c00a8cbd855fd05b9a90e4e0ed402
Reviewed-on: https://go-review.googlesource.com/c/go/+/568835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-04 20:12:49 +00:00
Keith Randall
f1722e9a6e slices: simplify rotate code
The rotate-by-reverse code in fact does only 2 writes per entry, so
it is fine and simpler.

Change-Id: I5feea9698b5575f1f0ae9069cc1d074643529262
Reviewed-on: https://go-review.googlesource.com/c/go/+/562321
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 20:01:33 +00:00
Dave Russell
f27a57ffb8 net/http: adjust wording on ServeMux godoc
When reading through the docs, I found that the sentence flows better with
the `to` present.

Change-Id: I51c21fa33c7a13748c0814dd87c76b9a8d64e2ec
GitHub-Last-Rev: 0642bd7185
GitHub-Pull-Request: golang/go#63587
Reviewed-on: https://go-review.googlesource.com/c/go/+/535935
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-03-04 19:37:37 +00:00
qmuntal
7986e26a39 os: don't treat mount points as symbolic links
This CL changes the behavior of os.Lstat to stop setting the
os.ModeSymlink type mode bit for mount points on Windows. As a result,
filepath.EvalSymlinks no longer evaluates mount points, which was the
cause of many inconsistencies and bugs.

Additionally, os.Lstat starts setting the os.ModeIrregular type mode bit
for all reparse tags on Windows, except for those that are explicitly
supported by the os package, which, since this CL, doesn't include mount
points. This helps to identify files that need special handling outside
of the os package.

This behavior is controlled by the `winsymlink` GODEBUG setting.
For Go 1.23, it defaults to `winsymlink=1`.
Previous versions default to `winsymlink=0`.

Fixes #39786
Fixes #40176
Fixes #61893
Updates #63703
Updates #40180
Updates #63429

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: I2e7372ab8862f5062667d30db6958d972bce5407
Reviewed-on: https://go-review.googlesource.com/c/go/+/565136
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-04 18:59:50 +00:00
guoguangwu
90796f44d5 net/http/cgi: close res.Body
Change-Id: I4682442f4f9f3d112b78582c3b9fc2d24c2d58a7
GitHub-Last-Rev: 0823701905
GitHub-Pull-Request: golang/go#66049
Reviewed-on: https://go-review.googlesource.com/c/go/+/568316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-04 18:29:59 +00:00
Michael Matloob
c8718f6a3d cmd/go: add file with list of all counters we collect
Maintain a list of counters we collect and test that it hasn't
changed. If it has, fail a test and have the user update the list. The
update process will print a reminder to update the list of collected
counters.

Also run go mod vendor to pull in
golang.org/x/telemetry/counter/countertest.

For #58894

Change-Id: I661a9c3d67cb33f42a5519f4639af7aa05c3821d
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/564555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-03-04 17:57:25 +00:00
apocelipes
de487d5616 cmd/compile/internal: replace direct calls to Sym.LinksymABI
Using (*Sym).LinksymABI(abi) directly is not recommended.

Replace with (*ir.Name).LinksymABI(abi).

Change-Id: I95d5d35240d4e1856ba511d828f6edefcee81b4f
GitHub-Last-Rev: 6787b65716
GitHub-Pull-Request: golang/go#66094
Reviewed-on: https://go-review.googlesource.com/c/go/+/568855
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 17:34:33 +00:00
Pouriya
4c08c12593 runtime: use .Pointers() instead of manual checking
Change-Id: Ib78c1513616089f4942297cd17212b1b11871fd5
GitHub-Last-Rev: f97fe5b5bf
GitHub-Pull-Request: golang/go#65819
Reviewed-on: https://go-review.googlesource.com/c/go/+/565515
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2024-03-04 17:34:30 +00:00
apocelipes
566e08fc64 cmd/compile/internal: use reflectdata.TypeLinksym
As the document of Sym.Linksym said, we replace
reflectdata.TypeSym(t).Linksym() with reflectdata.TypeLinksym(t).

Change-Id: I578eb159e552e60cd05d2aa1560f91797a6629ef
GitHub-Last-Rev: d096cba8f0
GitHub-Pull-Request: golang/go#66088
Reviewed-on: https://go-review.googlesource.com/c/go/+/568715
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 17:34:01 +00:00
aimuz
c2734187cd doc/go1.23: document database/sql wrap errors
For #64707.
For #65614.

Change-Id: Ib07ac67d7652bc7c9e1363f70637938c7bb4bc72
GitHub-Last-Rev: a4d8ecacbc
GitHub-Pull-Request: golang/go#66089
Reviewed-on: https://go-review.googlesource.com/c/go/+/568755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-04 17:32:53 +00:00