]> Cypherpunks repositories - gostls13.git/log
gostls13.git
5 months agocmd/compile: add constant folding for PopCount
Jorropo [Sun, 9 Mar 2025 09:21:06 +0000 (10:21 +0100)]
cmd/compile: add constant folding for PopCount

Change-Id: I6ea3f75ddd5c7af114ef77bc48f28c7f8570997b
Reviewed-on: https://go-review.googlesource.com/c/go/+/656156
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
5 months agolog/slog: use consistent call depth for all output
Örjan Fors [Wed, 5 Mar 2025 22:33:50 +0000 (22:33 +0000)]
log/slog: use consistent call depth for all output

This makes all log functions keep a consistent call structure to be nice
with the handleWriter in the slog package which expects a strict level
of 4.

Fixes #67362.

Change-Id: Ib967c696074b1ca931f6656dd27ff1ec484233b8
GitHub-Last-Rev: 49bc424986875da2dd244b57f8b0851d3bfd1a29
GitHub-Pull-Request: golang/go#67645
Reviewed-on: https://go-review.googlesource.com/c/go/+/588335
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agonet/mail: use sync.OnceValue to build dateLayouts
1911860538 [Sat, 8 Mar 2025 07:47:55 +0000 (07:47 +0000)]
net/mail: use sync.OnceValue to build dateLayouts

Simplify buildDateLayouts with sync.OnceValue.

Change-Id: Ib48ab20ee00f5e44cc1b0f6e1afe3fcd1b7dc3c7
GitHub-Last-Rev: 0866d463de1ec618d0d645b98f5e94917b8c3bde
GitHub-Pull-Request: golang/go#72743
Reviewed-on: https://go-review.googlesource.com/c/go/+/656055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agoruntime/internal: clean up completely
Jes Cok [Fri, 7 Mar 2025 01:04:13 +0000 (01:04 +0000)]
runtime/internal: clean up completely

We've been slowly moving packages from runtime/internal to
internal/runtime. For now, runtime/internal only has test packages.

It's a good chance to clean up the references to runtime/internal
in the toolchain.

For #65355.

Change-Id: Ie6f9091a44511d0db9946ea6de7a78d3afe9f063
GitHub-Last-Rev: fad32e2e81d11508e734c3c3d3b0c1da583f89f5
GitHub-Pull-Request: golang/go#72137
Reviewed-on: https://go-review.googlesource.com/c/go/+/655515
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agonet: unblock UDP Reads upon Close on plan9, add test
Brad Fitzpatrick [Mon, 10 Mar 2025 18:45:10 +0000 (11:45 -0700)]
net: unblock UDP Reads upon Close on plan9, add test

Fixes #72770

Change-Id: I42be7c7349961188f4b5d73287a3550aba323893
Reviewed-on: https://go-review.googlesource.com/c/go/+/656395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
5 months agodebug/dwarf: read DWARF 5 cu base offsets on SeekPC() path
Than McIntosh [Tue, 11 Mar 2025 13:16:05 +0000 (09:16 -0400)]
debug/dwarf: read DWARF 5 cu base offsets on SeekPC() path

This patch fixes a bug in CL 655976 relating to DWARF 5 support; we
were reading in compile unit base offsets on the Seek() path but not
on the corresponding SeekPC path (we need the offsets to be read in
both cases).

Updates #26379.
Fixes #72778.

Change-Id: I02850b786a53142307219292f2c5099eb0271559
Reviewed-on: https://go-review.googlesource.com/c/go/+/656675
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>

5 months agocmd/go: allow symlinks of non-directory files in embed
Michael Matloob [Thu, 16 Jan 2025 20:44:55 +0000 (15:44 -0500)]
cmd/go: allow symlinks of non-directory files in embed

We previously disallowed all non-regular files being embedded. This CL
relaxes the restriction a little: if the GODEBUG embedfollowsymlinks=1
is set, we allow the leaf files being embedded (not the directories
containing them) to be symlinks. The files pointed to by the symlinks
must still be regular files.

This will be used when a Bazel build action executing the Go command is
running in a symlink-based sandbox. It's not something we want to enable
in general for now, so it's behind a GODEBUG.

Fixes #59924

Change-Id: I895be14c12de55b7d1b663d81bdda1df37d54804
Reviewed-on: https://go-review.googlesource.com/c/go/+/643215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
5 months agogo/types, types2: report better error messages for make calls
Robert Griesemer [Sat, 8 Mar 2025 00:00:53 +0000 (16:00 -0800)]
go/types, types2: report better error messages for make calls

Change-Id: I4593aeb4cad1e2c3f4705ed5249ac0bad910162f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655518
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
5 months agogo/types, types2: report better error messages for slice expressions
Robert Griesemer [Fri, 7 Mar 2025 19:26:38 +0000 (11:26 -0800)]
go/types, types2: report better error messages for slice expressions

Explicitly compute the common underlying type and while doing
so report better slice-expression relevant error messages.
Streamline message format for index and slice errors.

This removes the last uses of the coreString and match functions.
Delete them.

Change-Id: I4b50dda1ef7e2ab5e296021458f7f0b6f6e229cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/655935
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

5 months agogo/types, types2: remove need for coreString in signature.go
Robert Griesemer [Fri, 7 Mar 2025 00:06:55 +0000 (16:06 -0800)]
go/types, types2: remove need for coreString in signature.go

Also, add additional test cases for NewSignatureType
to check expected panic behavior.

Change-Id: If26cd81a2af384bf2084dd09119483c0584715c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/655695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
5 months agogo/types, types2: better error messages for copy built-in
Robert Griesemer [Thu, 6 Mar 2025 23:44:01 +0000 (15:44 -0800)]
go/types, types2: better error messages for copy built-in

Rather than relying on coreString, use the new commonUnder function
to determine the argument slice element types.

Factor out this functionality, which is shared for append and copy,
into a new helper function sliceElem (similar to chanElem).
Use sliceElem for both the append and copy implementation.
As a result, the error messages for invalid copy calls are
now more detailed.

While at it, handle the special cases for append and copy first
because they don't need the slice element computation.

Finally, share the same type recording code for the special and
general cases.

As an aside, in commonUnder, be clearer in the code that the
result is either a nil type and an error, or a non-nil type
and a nil error. This matches in style what we do in sliceElem.

Change-Id: I318bafc0d2d31df04f33b1b464ad50d581918671
Reviewed-on: https://go-review.googlesource.com/c/go/+/655675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
5 months agocmd/internal/obj/loong64: add {V,XV}SEQI, {V,XV}.{AND,OR,XOR,NOR} instructions support
Guoqi Chen [Thu, 6 Mar 2025 03:06:35 +0000 (11:06 +0800)]
cmd/internal/obj/loong64: add {V,XV}SEQI, {V,XV}.{AND,OR,XOR,NOR} instructions support

Go asm syntax:
         VSEQB  $1, V2, V3
        XVSEQB  $2, X2, X3
         V{AND,OR,XOR,NOR}B  $1, V2, V3
        XV{AND,OR,XOR,NOR}B  $1, V2, V3
         V{AND,OR,XOR,NOR,ANDN,ORN}V V1, V2, V3
        XV{AND,OR,XOR,NOR,ANDN,ORN}V V1, V2, V3

Equivalent platform assembler syntax:
         vseqi.b v3, v2, $1
        xvseqi.b x3, x2 ,$2
         v{and,or,xor,nor}.b  v3, v2, $1
        xv{and,or,xor,nor}.b  x3, x2, $1
         v{and,or,xor,nor,andn,orn}v v3, v2, v1
        xv{and,or,xor,nor,andn,orn}v x3, x2, x1

Change-Id: I56ae0db72c7f473755cbdc7f7171c1058a9def97
Reviewed-on: https://go-review.googlesource.com/c/go/+/635515
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agocmd/compile: optimize shifts of int32 and uint32 on loong64
Xiaolin Zhao [Thu, 14 Nov 2024 03:35:39 +0000 (11:35 +0800)]
cmd/compile: optimize shifts of int32 and uint32 on loong64

goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A6000-HV @ 2500.00MHz
                |  bench.old   |              bench.new               |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros       1.100n ± 1%    1.101n ± 0%        ~ (p=0.566 n=10)
LeadingZeros8      1.501n ± 0%    1.502n ± 0%   +0.07% (p=0.000 n=10)
LeadingZeros16     1.501n ± 0%    1.502n ± 0%   +0.07% (p=0.000 n=10)
LeadingZeros32    1.2010n ± 0%   0.9511n ± 0%  -20.81% (p=0.000 n=10)
LeadingZeros64     1.104n ± 1%    1.119n ± 0%   +1.40% (p=0.000 n=10)
TrailingZeros     0.8137n ± 0%   0.8086n ± 0%   -0.63% (p=0.001 n=10)
TrailingZeros8     1.031n ± 1%    1.031n ± 1%        ~ (p=0.956 n=10)
TrailingZeros16   0.8204n ± 1%   0.8114n ± 0%   -1.11% (p=0.000 n=10)
TrailingZeros32   0.8145n ± 0%   0.8090n ± 0%   -0.68% (p=0.000 n=10)
TrailingZeros64   0.8159n ± 0%   0.8089n ± 1%   -0.86% (p=0.000 n=10)
OnesCount         0.8672n ± 0%   0.8677n ± 0%   +0.06% (p=0.000 n=10)
OnesCount8        0.8005n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
OnesCount16       0.9339n ± 0%   0.9344n ± 0%   +0.05% (p=0.000 n=10)
OnesCount32       0.8672n ± 0%   0.8677n ± 0%   +0.06% (p=0.000 n=10)
OnesCount64        1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
RotateLeft        0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
RotateLeft8        1.202n ± 0%    1.202n ± 0%        ~ (p=0.210 n=10)
RotateLeft16      0.8050n ± 0%   0.8036n ± 0%   -0.17% (p=0.002 n=10)
RotateLeft32      0.6674n ± 0%   0.6674n ± 0%        ~ (p=1.000 n=10)
RotateLeft64      0.6673n ± 0%   0.6674n ± 0%        ~ (p=0.072 n=10)
Reverse           0.4123n ± 0%   0.4067n ± 1%   -1.37% (p=0.000 n=10)
Reverse8          0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Reverse16         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
Reverse32         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
Reverse64         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.001 n=10)
ReverseBytes      0.4100n ± 1%   0.4057n ± 1%   -1.06% (p=0.002 n=10)
ReverseBytes16    0.8004n ± 0%   0.8009n ± 0%   +0.07% (p=0.000 n=10)
ReverseBytes32    0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
ReverseBytes64    0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Add                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Add32              1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
Add64              1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Add64multiple      1.831n ± 0%    1.832n ± 0%        ~ (p=1.000 n=10)
Sub                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub32              1.601n ± 0%    1.602n ± 0%   +0.06% (p=0.000 n=10)
Sub64              1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
Sub64multiple      2.400n ± 0%    2.402n ± 0%   +0.10% (p=0.000 n=10)
Mul               0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Mul32             0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Mul64             0.8004n ± 0%   0.8008n ± 0%   +0.05% (p=0.000 n=10)
Div                9.107n ± 0%    9.083n ± 0%        ~ (p=0.255 n=10)
Div32              4.009n ± 0%    4.011n ± 0%   +0.05% (p=0.000 n=10)
Div64              9.705n ± 0%    9.711n ± 0%   +0.06% (p=0.000 n=10)
geomean            1.089n         1.083n        -0.62%

goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A5000 @ 2500.00MHz
                |  bench.old   |              bench.new               |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros       1.352n ± 0%    1.341n ± 4%   -0.81% (p=0.024 n=10)
LeadingZeros8      1.766n ± 0%    1.781n ± 0%   +0.88% (p=0.000 n=10)
LeadingZeros16     1.766n ± 0%    1.782n ± 0%   +0.88% (p=0.000 n=10)
LeadingZeros32     1.536n ± 0%    1.341n ± 1%  -12.73% (p=0.000 n=10)
LeadingZeros64     1.351n ± 1%    1.338n ± 0%   -0.96% (p=0.000 n=10)
TrailingZeros     0.9037n ± 0%   0.9025n ± 0%   -0.12% (p=0.020 n=10)
TrailingZeros8     1.087n ± 3%    1.056n ± 0%        ~ (p=0.060 n=10)
TrailingZeros16    1.101n ± 0%    1.101n ± 0%        ~ (p=0.211 n=10)
TrailingZeros32   0.9040n ± 0%   0.9024n ± 1%   -0.18% (p=0.017 n=10)
TrailingZeros64   0.9043n ± 0%   0.9028n ± 1%        ~ (p=0.118 n=10)
OnesCount          1.503n ± 2%    1.482n ± 1%   -1.43% (p=0.001 n=10)
OnesCount8         1.207n ± 0%    1.206n ± 0%   -0.12% (p=0.000 n=10)
OnesCount16        1.501n ± 0%    1.534n ± 0%   +2.13% (p=0.000 n=10)
OnesCount32        1.483n ± 1%    1.531n ± 1%   +3.27% (p=0.000 n=10)
OnesCount64        1.301n ± 0%    1.302n ± 0%   +0.08% (p=0.000 n=10)
RotateLeft        0.8136n ± 4%   0.8083n ± 0%   -0.66% (p=0.002 n=10)
RotateLeft8        1.311n ± 0%    1.310n ± 0%        ~ (p=0.786 n=10)
RotateLeft16       1.165n ± 0%    1.149n ± 0%   -1.33% (p=0.001 n=10)
RotateLeft32      0.8138n ± 1%   0.8093n ± 0%   -0.57% (p=0.017 n=10)
RotateLeft64      0.8149n ± 1%   0.8088n ± 0%   -0.74% (p=0.000 n=10)
Reverse           0.5195n ± 1%   0.5109n ± 0%   -1.67% (p=0.000 n=10)
Reverse8          0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Reverse16         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Reverse32         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.012 n=10)
Reverse64         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.010 n=10)
ReverseBytes      0.5120n ± 1%   0.5122n ± 2%        ~ (p=0.306 n=10)
ReverseBytes16    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
ReverseBytes32    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
ReverseBytes64    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Add                1.201n ± 0%    1.201n ± 4%        ~ (p=0.334 n=10)
Add32              1.201n ± 0%    1.201n ± 0%        ~ (p=0.563 n=10)
Add64              1.201n ± 0%    1.201n ± 1%        ~ (p=0.652 n=10)
Add64multiple      1.909n ± 0%    1.902n ± 0%        ~ (p=0.126 n=10)
Sub                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub32              1.655n ± 0%    1.654n ± 0%        ~ (p=0.589 n=10)
Sub64              1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub64multiple      2.150n ± 0%    2.180n ± 4%   +1.37% (p=0.000 n=10)
Mul               0.9341n ± 0%   0.9345n ± 0%   +0.04% (p=0.011 n=10)
Mul32              1.053n ± 0%    1.030n ± 0%   -2.23% (p=0.000 n=10)
Mul64             0.9341n ± 0%   0.9345n ± 0%   +0.04% (p=0.018 n=10)
Div                11.59n ± 0%    11.57n ± 1%        ~ (p=0.091 n=10)
Div32              4.337n ± 0%    4.337n ± 1%        ~ (p=0.783 n=10)
Div64              12.81n ± 0%    12.76n ± 0%   -0.39% (p=0.001 n=10)
geomean            1.257n         1.252n        -0.46%

Change-Id: I9e93ea49736760c19dc6b6463d2aa95878121b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/627855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agotesting: warn against calling Log after a test completes
Sean Liao [Mon, 10 Mar 2025 19:41:09 +0000 (19:41 +0000)]
testing: warn against calling Log after a test completes

Fixes #40343

Change-Id: Id266f4b57131e9e148e5aa2be86b67fe6d73b20a
Reviewed-on: https://go-review.googlesource.com/c/go/+/656415
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agocrypto/tls: reject TLS 1.3 compat session ID in TLS 1.2
Daniel McCarney [Wed, 26 Feb 2025 20:59:25 +0000 (15:59 -0500)]
crypto/tls: reject TLS 1.3 compat session ID in TLS 1.2

If we weren't resuming an existing session, and we constructed a TLS 1.3
compatible client hello, ensure the server doesn't echo back the
made up compatibility session ID if we end up handshaking for TLS 1.2.

As part of an effort to make the initial stages of a TLS 1.3 handshake
compatible with TLS 1.2 middleboxes, TLS 1.3 requires that the client
hello contain a non-empty legacy_session_id value. For anti-ossification
purposes it's recommended this ID be randomly generated. This is the
strategy the crypto/tls package takes.

When we follow this approach, but then end up negotiating TLS 1.2, the
server should not have echoed back that random ID to us. It's impossible
for the server to have had a session with a matching ID and so it is
misbehaving and it's prudent for our side to abort the handshake.

See RFC 8446 Section 4.1.2 for more detail:
  https://www.rfc-editor.org/rfc/rfc8446#section-4.1.2

Adopting this behaviour allows un-ignoring the BoGo
EchoTLS13CompatibilitySessionID testcase.

Updates #72006

Change-Id: I1e52075177a13a7aa103b45498eae38d8a4c34b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/652997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 months agocrypto/tls: align cert decode alert w/ BSSL
Daniel McCarney [Wed, 26 Feb 2025 19:13:15 +0000 (14:13 -0500)]
crypto/tls: align cert decode alert w/ BSSL

For malformed client/server certificates in a TLS handshake send
a decode_error alert, matching BoringSSL behaviour.

Previously crypto/tls used a bad_certificate alert for this purpose.
The TLS specification is imprecise enough to allow this to be considered
a spec. justified choice, but since all other places in the protocol
encourage using decode_error for structurally malformed messages we may
as well do the same here and get some extra cross-impl consistency for
free.

This also allows un-ignoring the BoGo
GarbageCertificate-[Client|Server]-[TLS12|TLS13] tests.

Updates #72006

Change-Id: Ide45ba1602816e71c3289a60e77587266c3b9036
Reviewed-on: https://go-review.googlesource.com/c/go/+/652995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agocrypto/tls: update GREASE-Server-TLS13 BoGo skip
Daniel McCarney [Wed, 19 Feb 2025 18:10:36 +0000 (13:10 -0500)]
crypto/tls: update GREASE-Server-TLS13 BoGo skip

Previously this test was skipped without a comment clarifying why. In
practice it's because crypto/tls doesn't generate GREASE extensions at
this time, and the test expects to find one in the NewSessionTicket
message extensions produced by a server.

We're already skipping some other GREASE related test as
not-yet-implemented without explicit bogo_config.json exclusion by way
of the -enable-grease flag not being implemented, however for TLS
1.3 servers the BoGo expectation is that they _always_ send GREASE, and
so the -enable-grease flag isn't provided and an explicit skip must be
used.

We should revisit this alongside implementing GREASE ext production in
general for both clients and servers.

Updates #72006

Change-Id: I8af4b555ac8c32cad42215fbf26aa0feae90fa21
Reviewed-on: https://go-review.googlesource.com/c/go/+/650717
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agocrypto/tls: support bogo -wait-for-debugger
Daniel McCarney [Wed, 19 Feb 2025 17:39:32 +0000 (12:39 -0500)]
crypto/tls: support bogo -wait-for-debugger

When this command line flag is provided to the BoGo runner it will:

* Disable some timeouts
* Limit concurrency to 1 worker at a time
* Pass the -wait-for-debugger flag to the shim process
* Print the PID of the shim process to status output

On the shim-side, we need to react to -wait-for-debugger by sending
ourselves a SIGSTOP signal. When a debugger attaches to the shim the
process will be resumed.

This makes it possible to debug both the runner side and the shim side
of a BoGo interaction without resorting to print style debugging.

Since SIGSTOP is not a signal we can use on Windows this functionality
is limited to unix builds.

Updates #72006

Change-Id: Iafa08cf71830cdfde3e6ee4826914236e3cd7e57
Reviewed-on: https://go-review.googlesource.com/c/go/+/650737
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/tls: ignore TLS 1.3 user canceled alerts
Daniel McCarney [Wed, 19 Feb 2025 15:30:50 +0000 (10:30 -0500)]
crypto/tls: ignore TLS 1.3 user canceled alerts

When encountering alertUserCanceled in a TLS 1.3 handshake, ignore the
alert and retry reading a record. This matches existing logic for how
TLS 1.2 alertLevelWarning alerts are handled.

For broader context, TLS 1.3 removed warning-level alerts except for
alertUserCanceled (RFC 8446, § 6.1). Since at least one major
implementation (https://bugs.openjdk.org/browse/JDK-8323517)
misuses this alert, many TLS stacks now ignore it outright when seen in
a TLS 1.3 handshake (e.g. BoringSSL, NSS, Rustls).

With the crypto/tls behaviour changed to match peer implementations we
can now enable the "SendUserCanceledAlerts-TLS13" BoGo test.

"SendUserCanceledAlerts-TooMany-TLS13" remains ignored, because like
"SendWarningAlerts*" fixing the test requires some general spam
protocol message enhancements be done first.

Updates #72006

Change-Id: I570c1fa674b5a4760836c514d35ee17f746fe28d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650716
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agocrypto/tls: run SkipNewSessionTicket bogo test
Daniel McCarney [Tue, 18 Feb 2025 17:41:34 +0000 (12:41 -0500)]
crypto/tls: run SkipNewSessionTicket bogo test

This commit removes SkipNewSessionTicket from the bogo_config.json
excluded tests list.

Previously this test was being skipped with a TODO that there might be
a bug here. In practice it seems like there's no bug and the test is
handled correctly by crypto/tls.

When activated, a TLS 1.2 client connecting to the bogo dispatcher goes
through the normal handshake process with the exception that the server
skips sending the NewSessionTicket msg expected by the client in
response to the client's final flight of handshake msgs.

The crypto/tls TLS 1.2 client_handshake.go logic correctly rejects the
unexpected message that follows (ChangeCipherSpec) when trying to read
the bytes necessary to unmarshal the expected NewSessionTicket message
that was omitted.

Updates #72006

Change-Id: I9faea4d18589d10b163211aa17b2d0da8af1187e
Reviewed-on: https://go-review.googlesource.com/c/go/+/650736
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agointernal/runtime/atomic: updated go assembler comments
Prabhav Dogra [Fri, 7 Mar 2025 09:32:20 +0000 (09:32 +0000)]
internal/runtime/atomic: updated go assembler comments

Updated comments in go assembler package

Change-Id: I174e344ca45fae6ef70af2e0b29cd783b003b4c2
GitHub-Last-Rev: 8ab37208891e795561a943269ca82b1ce6e7eef5
GitHub-Pull-Request: golang/go#72048
Reviewed-on: https://go-review.googlesource.com/c/go/+/654478
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: PRABHAV DOGRA <prabhavdogra1@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/tls: reject empty TLS 1.3 session ticket
Daniel McCarney [Mon, 17 Feb 2025 16:45:23 +0000 (11:45 -0500)]
crypto/tls: reject empty TLS 1.3 session ticket

While not clearly motivated by normative language in RFC 8446 it seems
clear that an empty opaque ticket value is non-operable, and so we
should reject it with an appropriate alert/error.

This allows removing the SendEmptySessionTicket-TLS13 BoGo test from the
bogo excluded tests configuration.

Fixes #70513
Updates #72006

Change-Id: I589b34e86fb1eb27a349a230e920c22284597cde
Reviewed-on: https://go-review.googlesource.com/c/go/+/650735
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>

5 months agocmd/go/internal/mmap: close file after mmap
Michael Matloob [Wed, 26 Feb 2025 21:31:41 +0000 (16:31 -0500)]
cmd/go/internal/mmap: close file after mmap

Closing the file after mmap will reduce the number of files associated
with the process. This will not likely help with #71698 but it doesn't
hurt to close the files and should simplify lsof output.

For #71698

Change-Id: I06a1bf91914afc7703783fe1a38d8bc5a6fb3d9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/653055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
5 months agocmd/cgo/internal/testsanitizers: bump GCC version for asan location checking
Than McIntosh [Sun, 9 Mar 2025 12:59:45 +0000 (08:59 -0400)]
cmd/cgo/internal/testsanitizers: bump GCC version for asan location checking

Require GCC 11 or greater to turn on the location checking portion of
the asan tests in this directory; the copy of libasan.so.6 shipped
with GCC 10 doesn't seem to properly digest the new DWARF 5 being
generated by the Go compiler+linker.

Updates #72752.

Change-Id: I92718c112df844d9333c4c798cddaae95665feb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/656175
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agodebug/dwarf: fix problem with DWARF 5 and Seek method
Than McIntosh [Fri, 7 Mar 2025 19:16:28 +0000 (14:16 -0500)]
debug/dwarf: fix problem with DWARF 5 and Seek method

When clients use debug/dwarf to examine DWARF 5 binaries, we can run
into problems when the Seek() method is used to skip ahead from a DIE
in one compilation unit to a DIE in another unit. The problem here is
that it is common for DWARF 5 comp units to have attributes (ex:
DW_AT_addr_base) whose value must be applied as an offset when reading
certain forms (ex: DW_FORM_addrx) within that unit. The existing
implementation didn't have a good way to recover these attrs following
the Seek call, and had to essentially punt in this case, resulting in
incorrect attr values.

This patch adds new support for reading and caching the key comp unit
DIE attributes (DW_AT_addr_base, DW_AT_loclists_base, etc) prior to
visiting any of the DIE entries in a unit, storing the cache values of
these attrs the main table of units. This base attribute
reading/caching behavior also happens (where needed) after Seek calls.

Should resolve delve issue 3861.
Supercedes Go pull request 70400.

Updates #26379.
Fixes #57046.

Change-Id: I536a57e2ba4fc55132d91c7f36f67a91ac408dc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/655976
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agodebug/dwarf: refactor entry DIE reading helper
Than McIntosh [Fri, 7 Mar 2025 18:34:55 +0000 (13:34 -0500)]
debug/dwarf: refactor entry DIE reading helper

Simplify the signature of the "entry()" buf method to accept a unit as
opposed to a collection of unit components (version, atable, etc). No
change in functionality, this is a pure refactoring that will be
needed in subsequent patch.

Change-Id: I688def34e39d36b6a62733bc73dc42b49f78ca41
Reviewed-on: https://go-review.googlesource.com/c/go/+/655975
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agointernal/godebugs: add decoratemappings as an opaque godebug setting
Michael Pratt [Fri, 7 Mar 2025 18:53:34 +0000 (13:53 -0500)]
internal/godebugs: add decoratemappings as an opaque godebug setting

This adds a new godebug to control whether the runtime applies the
anonymous memory mapping annotations added in https://go.dev/cl/646095.
It is enabled by default.

This has several effects:

* The feature is only enabled by default when the main go.mod has go >=
  1.25.
* This feature can be disabled with GODEBUG=decoratemappings=0, or the
  equivalents in go.mod or package main. See https://go.dev/doc/godebug.
* As an opaque setting, this option will not appear in runtime/metrics.
* This setting is non-atomic, so it cannot be changed after startup.

I am not 100% sure about my decision for the last two points.

I've made this an opaque setting because it affects every memory mapping
the runtime performs. Thus every mapping would report "non-default
behavior", which doesn't seem useful.

This setting could trivially be atomic and allow changes at run time,
but those changes would only affect future mappings. That seems
confusing and not helpful. On the other hand, going back to annotate or
unannotate every previous mapping when the setting changes is
unwarranted complexity.

For #71546.

Change-Id: I6a6a636c5ad551d76691cba2a6f668d5cff0e352
Reviewed-on: https://go-review.googlesource.com/c/go/+/655895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

5 months agocrypto/pbkdf2: fix code example for Key
Gusted [Sat, 8 Mar 2025 17:30:06 +0000 (17:30 +0000)]
crypto/pbkdf2: fix code example for Key

The type for password is not `[]byte` (as it was in golang.org/x/crypto/pbkdf2), it is `string`.

Change-Id: I914a81a500a6d93f994b587814f26285aef7b96d
GitHub-Last-Rev: 5ec752e0def59c1058c649b4543f296467691813
GitHub-Pull-Request: golang/go#72746
Reviewed-on: https://go-review.googlesource.com/c/go/+/656115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>

5 months agonet/http/httputil: close hijacked connections when CloseWrite not available
Damien Neil [Thu, 6 Mar 2025 21:24:58 +0000 (13:24 -0800)]
net/http/httputil: close hijacked connections when CloseWrite not available

CL 637939 changed ReverseProxy's handling of hijacked connections:
After copying all data in one direction, it half-closes the outbound
connection rather than fully closing both.

Revert to the old behavior when the outbound connection does not support
CloseWrite, avoiding a case where one side of the proxied connection closes
but the other remains open.

Fixes #72140

Change-Id: Ic0cacaa6323290f89ba48fd6cae737e86045a435
Reviewed-on: https://go-review.googlesource.com/c/go/+/655595
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>

5 months agocrypto/tls: small bogo shim test tidying
Daniel McCarney [Sat, 15 Feb 2025 15:07:19 +0000 (10:07 -0500)]
crypto/tls: small bogo shim test tidying

1. onResumeShimWritesFirst is unused, replace the binding with an
   underscore.
2. in the bogoShim() function when looping through resumeCount+1 the
   tlsConn read for loop only breaks for non-nil err, so there's no need
   to check that again after the loop body.

Updates #72006

Change-Id: Ieff45d26df33d71003a2509ea5b2b06c5fa0e1d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/650715
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agoos: remove unused testingForceReadDirLstat
Tobias Klauser [Fri, 7 Mar 2025 13:41:29 +0000 (14:41 +0100)]
os: remove unused testingForceReadDirLstat

It was introduced in CL 261540 but never set by any test.

Change-Id: Id2a59c58ed510b6041cc51ce47ab79199a60b215
Reviewed-on: https://go-review.googlesource.com/c/go/+/655797
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

5 months agocrypto/internal/fips140: make Version return latest when not frozen
Filippo Valsorda [Thu, 6 Mar 2025 16:08:02 +0000 (17:08 +0100)]
crypto/internal/fips140: make Version return latest when not frozen

Fixes #71820

Change-Id: I6a6a46563da281a7b20efc61eefdcbb2e146db33
Reviewed-on: https://go-review.googlesource.com/c/go/+/655795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agocompress/flate,compress/lzw: fix incorrect godoc links
Olivier Mengué [Thu, 6 Mar 2025 08:23:15 +0000 (09:23 +0100)]
compress/flate,compress/lzw: fix incorrect godoc links

Fix incorrect godoc links related to the use of the name "Reader" for
different things in the various compress/* packages:
- in compress/flate Reader is the interface describing the underlying reader,
  not the decompressor as in other packages, so "returned reader" must
  not be linked to Reader.
- in compress/lzw and compress/gzip Reader is the decompressor, not the
  interface of the underlying reader, so "underlying reader" must not
  be linked to Reader.

With this patch the formatting of "underlying reader" and "returned
reader" is consistent accross compress/* packages.

Change-Id: Iea315fd5ee5b6c177855693d68841f3709a382cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/655335
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/internal/fips140/bigmod: explicitly clear expanded limbs on reset
Filippo Valsorda [Wed, 5 Mar 2025 11:08:35 +0000 (12:08 +0100)]
crypto/internal/fips140/bigmod: explicitly clear expanded limbs on reset

Russ Cox noticed that reset was clearing limbs up to the *previous* Nat
size, not up to the new size, because clear(x.limbs) was happening
before the x.limbs[:n] reslice.

That's potentially a severe issue, because it may leave garbage in
x.limbs[len(x.limbs):n] if n < cap(x.limbs).

We were saved by an accidental invariant caused by the bug itself,
though: x.limbs[len(x.limbs):cap(x.limbs)] are always zero.

reset was always clearing all exposed (and hence potentially non-zero)
limbs before shrinking the Nat, and the only other function that could
shrink the Nat was trim, which only trims zero limbs.

Near miss.

Preserve the accidental invariant in the fix, because memclr is cheap
and it just proved it can save us from potential mistakes.

Change-Id: I6a6a4656a77735d8e8d520c699c4d85dd33ce497
Reviewed-on: https://go-review.googlesource.com/c/go/+/655056
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agotext/template: add an if func example
linmaolin [Thu, 6 Mar 2025 00:41:02 +0000 (00:41 +0000)]
text/template: add an if func example

Updates #13880

Change-Id: I0fd3b1a32e485bc8f15238c86a8bbdc161f20fa5
GitHub-Last-Rev: d1e92b31243c86435add422ee46aaff768453cad
GitHub-Pull-Request: golang/go#71922
Reviewed-on: https://go-review.googlesource.com/c/go/+/651916
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoarchive/zip: preallocate fileList size for Reader.Open
Olivier Mengué [Thu, 6 Mar 2025 18:44:22 +0000 (19:44 +0100)]
archive/zip: preallocate fileList size for Reader.Open

When building the index of file entries for Reader.Open (when the Reader
is used as an io/fs.FS), reduce reallocations by pre-allocating the
count of entries based on the count of file entries.

Change-Id: I05048337cb5e752054b3e984a8a5ec5199c4589b
Reviewed-on: https://go-review.googlesource.com/c/go/+/655476
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

5 months agogo/types,types2: allocate the used* maps in initFiles
Rob Findley [Fri, 7 Mar 2025 18:13:51 +0000 (18:13 +0000)]
go/types,types2: allocate the used* maps in initFiles

As described in the associated comment, we need to reallocate usedVars
and usedPkgNames in initFiles, as they are nilled out at the end of
Checker.Files, which may be called multiple times.

Fixes #72122

Change-Id: I9f6eb86e072d9d43a8720f6a5e86d827de6006a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/655437
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
5 months agonet: add comment about blocking to Conn.Close
Ian Lance Taylor [Thu, 6 Mar 2025 22:52:02 +0000 (14:52 -0800)]
net: add comment about blocking to Conn.Close

Fixes #18187

Change-Id: I3d0119838ddbfb99a067ba563e5d247f574ef841
Reviewed-on: https://go-review.googlesource.com/c/go/+/655517
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agogo/types, types2: factor out shared for-range checking code into range.go
Robert Griesemer [Thu, 6 Mar 2025 17:58:51 +0000 (09:58 -0800)]
go/types, types2: factor out shared for-range checking code into range.go

For go/types, generate its range.go file from the corresponding types2 file.

Change-Id: Iaff3ecbf1c536143c92f7b50e2461140469f9280
Reviewed-on: https://go-review.googlesource.com/c/go/+/655536
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: Robert Findley <rfindley@google.com>
5 months agogo/types, types2: rename errorCause to typeError
Robert Griesemer [Tue, 4 Mar 2025 17:51:41 +0000 (09:51 -0800)]
go/types, types2: rename errorCause to typeError

Change-Id: Ib8a63cdaa12dacb5223318a7166fe3dfdac71a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/654655
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: Robert Findley <rfindley@google.com>
5 months agogo/types, types2: use errorCause instead of reportf in comparableType
Robert Griesemer [Tue, 4 Mar 2025 16:47:25 +0000 (08:47 -0800)]
go/types, types2: use errorCause instead of reportf in comparableType

If the error cause is not further specified (empty string),
avoid allocating a new errorCause. This makes using errorCauses
as boolean signals efficient.

While at it, fix an error message for incomparable arrays:
report the array type rather than its underlying type.

Change-Id: I844b18a76695330ca726932ee760aa89635f6a38
Reviewed-on: https://go-review.googlesource.com/c/go/+/654575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

5 months agogo/types, types2: better error messages for invalid calls
Robert Griesemer [Tue, 4 Mar 2025 02:06:48 +0000 (18:06 -0800)]
go/types, types2: better error messages for invalid calls

Rather than reporting "non-function" for an invalid type parameter,
report which type in the type parameter's type set is not a function.

Change-Id: I8beec25cc337bae8e03d23e62d97aa82db46bab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/654475
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agogo/types, types2: factor out single commonUnder function
Robert Griesemer [Mon, 3 Mar 2025 23:11:47 +0000 (15:11 -0800)]
go/types, types2: factor out single commonUnder function

Combine commonUnder and commonUnderOrChan:
- Provide an optional cond(ition) function argument to commonUnder
  to establish additional type set conditions.
- Instead of a *Checker and *string argument for error reporting,
  return an error cause that is only allocated in the presence of
  an error.
- Streamline some error messages.

Replace all calls to coreType with calls to commonUnder.

Change-Id: I81ac86d0d532cddc09164309acced61d90718b44
Reviewed-on: https://go-review.googlesource.com/c/go/+/654455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
5 months agocmd/cgo/internal/testsanitizers: for "leak", use -fsanitize=address
Ian Lance Taylor [Thu, 6 Mar 2025 20:54:27 +0000 (12:54 -0800)]
cmd/cgo/internal/testsanitizers: for "leak", use -fsanitize=address

We currently test the leak detector by running "go build -asan",
which will pass -fsanitize=address to the C compiler.
So use that when testing whether the option works.

Fixes #72128

Change-Id: I4efc0b689bfda04c80dbac30a5c757215f297d2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/go: add 'work' package pattern
Michael Matloob [Thu, 16 Jan 2025 22:05:02 +0000 (17:05 -0500)]
cmd/go: add 'work' package pattern

The 'work' package pattern will resolve to the set of packages in the
work (formerly called main) modules. It's essentially 'all', but without
the dependencies. And the implementation is similar to that of 'all',
except that we don't expand to the dependencies.

Fixes #71294

Change-Id: I3d02beb74fa4e5c6de2290e24eedc51745d13080
Reviewed-on: https://go-review.googlesource.com/c/go/+/643235
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoos: add missing calls to Root.Close() in tests
Olivier Mengué [Thu, 6 Mar 2025 15:25:51 +0000 (16:25 +0100)]
os: add missing calls to Root.Close() in tests

In tests of os.Root, fix a few missing calls to Close().

Change-Id: I8fddd5468394f41d7e92741579fd47f90203ff9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

5 months agocmd/compile: remove no-longer-necessary recursive inlining checks
David Chase [Wed, 5 Mar 2025 19:27:15 +0000 (14:27 -0500)]
cmd/compile: remove no-longer-necessary recursive inlining checks

this does result in a little bit more inlining,
cmd/compile text is 0.5% larger,
bent-benchmark text geomeans grow by only 0.02%.
some of our tests make assumptions about inlining.

Change-Id: I999d1798aca5dc64a1928bd434258a61e702951a
Reviewed-on: https://go-review.googlesource.com/c/go/+/655157
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
5 months agocmd/go: cache coverage profile with tests
Ryan Currah [Tue, 25 Feb 2025 15:51:56 +0000 (15:51 +0000)]
cmd/go: cache coverage profile with tests

This CL stores coverage profile data in the GOCACHE under the
'coverprofile' subkey alongside tests. This makes tests which use
coverage profiles cacheable. The values of the -coverprofile and
-outputdir flags are not included in the cache key to allow cached
profile data to be written to any output file.

Note: This is a rebase and squash from the original PRs below that
was created/closed/abandoned by @jproberts and @macnibblet that I
plan to maintain.

- https://github.com/golang/go/pull/50483
- https://github.com/golang/go/pull/65657

I made improvements to the change based on feedback from @bcmills in Gerrit
https://go-review.googlesource.com/c/go/+/563138.

From @macnibblet:

I don't know if anyone has considered the environmental impact
(Yes, of course, dev experience too), but on a team with 3 backend
developers, when I replaced our CI Golang version with this build,
it reduced the build time by 50%, which would have
equated to about 5000 hours of CI reduced in the past year.

Fixes #23565

Change-Id: I59a20af5ea156f990a17544cf06dc667ae7f8aa3
GitHub-Last-Rev: a5a1d1b9c87ff433d16f656fc8988e1cb1ce7100
GitHub-Pull-Request: golang/go#69339
Reviewed-on: https://go-review.googlesource.com/c/go/+/610564
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agoos: more godoc links
Olivier Mengué [Thu, 6 Mar 2025 12:23:52 +0000 (13:23 +0100)]
os: more godoc links

Add missing links to *PathError.

Also a few links to O_ flags and Mode and syscall constants.

Change-Id: Ic6ec5780a44942050a83ed07dbf16d6fa9f83eb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/655375
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agocompress/lzw,compress/gzip,compress/flate,compress/zlib,compress/bzip2: go doc links
Olivier Mengué [Wed, 5 Mar 2025 16:44:53 +0000 (17:44 +0100)]
compress/lzw,compress/gzip,compress/flate,compress/zlib,compress/bzip2: go doc links

Add godoc links to compress/* package doc.

Change-Id: I768ca250a39b0bb70eca35ac5b3b77ead73ca5f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/655057
Reviewed-by: Ian Lance Taylor <iant@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: Junyang Shao <shaojunyang@google.com>
5 months agocmd/internal/obj/loong64: add {V,XV}ILV{L/H}.{B/H/W/D} instructions support
Xiaolin Zhao [Fri, 13 Dec 2024 10:00:09 +0000 (18:00 +0800)]
cmd/internal/obj/loong64: add {V,XV}ILV{L/H}.{B/H/W/D} instructions support

Go asm syntax:
 VILV{L/H}{B/H/W/V} VK, VJ, VD
XVILV{L/H}{B/H/W/V} XK, XJ, XD

Equivalent platform assembler syntax:
 vilv{l/h}.{b/h/w/d} vd, vj, vk
xvilv{l/h}.{b/h/w/d} xd, xj, xk

Change-Id: I40e21737649d9fdbbc9a423e859f4c0a56d069fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/635936
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>

5 months agodoc: update godebug doc to clarify godebug directive in workspace
Michael Matloob [Wed, 5 Mar 2025 20:20:46 +0000 (15:20 -0500)]
doc: update godebug doc to clarify godebug directive in workspace

Make it clear that we only use godebug directives in the go.work, and
that we don't use those in go.mod, when we're in a workspace.

Fixes #72109

Change-Id: I648bfa4dd9b3ca0ac299c0a890843d41fe1ac7f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/655158
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agomath/big: avoid negative slice size in nat.rem
Russ Cox [Wed, 5 Mar 2025 19:43:44 +0000 (14:43 -0500)]
math/big: avoid negative slice size in nat.rem

In a division, normally the answer to N digits / D digits has N-D digits,
but not when N-D is negative. Fix the calculation of the number of
digits for the temporary in nat.rem not to be negative.

Fixes #72043.

Change-Id: Ib9faa430aeb6c5f4c4a730f1ec631d2bf3f7472c
Reviewed-on: https://go-review.googlesource.com/c/go/+/655156
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/rsa: add a test with very different prime sizes
Filippo Valsorda [Wed, 5 Mar 2025 10:00:57 +0000 (11:00 +0100)]
crypto/rsa: add a test with very different prime sizes

Change-Id: I6a6a46565bdd804790434e2a14216b9f788e5af4
Reviewed-on: https://go-review.googlesource.com/c/go/+/655055
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>

5 months agocrypto: test for unexpected concrete methods in interface value returns
Filippo Valsorda [Fri, 20 Dec 2024 17:06:00 +0000 (18:06 +0100)]
crypto: test for unexpected concrete methods in interface value returns

Change-Id: I24188ad5f51953b2fbdef7487acc4ab6b1d77575
Reviewed-on: https://go-review.googlesource.com/c/go/+/638175
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoruntime: explicitly disable async preempt for internal/runtime
Andy Pan [Wed, 5 Mar 2025 08:14:42 +0000 (16:14 +0800)]
runtime: explicitly disable async preempt for internal/runtime

For #71591
Relevant CL 560155

Change-Id: Iebc497d56b36d50c13a6dd88e7bca4578a03cf63
Reviewed-on: https://go-review.googlesource.com/c/go/+/654916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agocmd/link/internal: remove trampoline for plt on loong64
limeidan [Wed, 5 Mar 2025 09:47:41 +0000 (17:47 +0800)]
cmd/link/internal: remove trampoline for plt on loong64

When trampoline is called, the plt symbol has not been
added. If we add tramp here, plt will not work.

Change-Id: I64e5d2be9e08f78ca5e8a9dcb267620a481d4416
Reviewed-on: https://go-review.googlesource.com/c/go/+/654918
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
5 months agomath: implement func archExp and archExp2 in assembly on loong64
Xiaolin Zhao [Tue, 31 Dec 2024 13:02:47 +0000 (21:02 +0800)]
math: implement func archExp and archExp2 in assembly on loong64

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A6000 @ 2500.00MHz
        |  bench.old  |              bench.new              |
        |   sec/op    |   sec/op     vs base                |
Exp       26.30n ± 0%   12.93n ± 0%  -50.85% (p=0.000 n=10)
ExpGo     26.86n ± 0%   26.92n ± 0%   +0.22% (p=0.000 n=10)
Expm1     16.76n ± 0%   16.75n ± 0%        ~ (p=0.060 n=10)
Exp2      23.05n ± 0%   12.12n ± 0%  -47.42% (p=0.000 n=10)
Exp2Go    23.41n ± 0%   23.47n ± 0%   +0.28% (p=0.000 n=10)
geomean   22.97n        17.54n       -23.64%

goos: linux
goarch: loong64
pkg: math/cmplx
cpu: Loongson-3A6000 @ 2500.00MHz
    |  bench.old  |              bench.new              |
    |   sec/op    |   sec/op     vs base                |
Exp   51.32n ± 0%   35.41n ± 0%  -30.99% (p=0.000 n=10)

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A5000 @ 2500.00MHz
        |  bench.old  |              bench.new              |
        |   sec/op    |   sec/op     vs base                |
Exp       50.27n ± 0%   48.75n ± 1%   -3.01% (p=0.000 n=10)
ExpGo     50.72n ± 0%   50.44n ± 0%   -0.55% (p=0.000 n=10)
Expm1     28.40n ± 0%   28.32n ± 0%        ~ (p=0.360 n=10)
Exp2      50.09n ± 0%   21.49n ± 1%  -57.10% (p=0.000 n=10)
Exp2Go    50.05n ± 0%   49.69n ± 0%   -0.72% (p=0.000 n=10)
geomean   44.85n        37.52n       -16.35%

goos: linux
goarch: loong64
pkg: math/cmplx
cpu: Loongson-3A5000 @ 2500.00MHz
    |  bench.old  |              bench.new              |
    |   sec/op    |   sec/op     vs base                |
Exp   88.56n ± 0%   67.29n ± 0%  -24.03% (p=0.000 n=10)

Change-Id: I89e456d26fc075d83335ee4a31227d2aface5714
Reviewed-on: https://go-review.googlesource.com/c/go/+/653935
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agocmd/internal/obj/loong64: add {V,XV}{ADD/SUB}.{B,H,W,D,Q} and {V,XV}{ADD/SUB}.{B...
Xiaolin Zhao [Thu, 19 Dec 2024 13:07:42 +0000 (21:07 +0800)]
cmd/internal/obj/loong64: add {V,XV}{ADD/SUB}.{B,H,W,D,Q} and {V,XV}{ADD/SUB}.{B,H,W,D}Uinstructions support

Go asm syntax:
 V{ADD/SUB}{B,H,W,V,Q} VK, VJ, VD
XV{ADD/SUB}{B,H,W,V,Q} XK, XJ, XD
 V{ADD/SUB}{B,H,W,V}U $1, VJ, VD
XV{ADD/SUB}{B,H,W,V}U $1, XJ, XD

Equivalent platform assembler syntax:
 v{add/sub}.{b,h,w,d,q} vd, vj, vk
xv{add/sub}.{b,h,w,d,q} xd, xj, xk
 v{add/sub}i.{b,h,w,d}u vd, vj, $1
xv{add/sub}i.{b,h,w,d}u xd, xj, $1

Change-Id: Ia1ef0bc062f4403bb0b1514c2cf1c0264f5d22ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/637795
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoruntime: in asan mode call __lsan_do_leak_check when exiting
Ian Lance Taylor [Sat, 22 Feb 2025 01:13:20 +0000 (17:13 -0800)]
runtime: in asan mode call __lsan_do_leak_check when exiting

This enables the ASAN default behavior of reporting C memory leaks.
It can be disabled with ASAN_OPTIONS=detect_leaks=0.

Fixes #67833

Change-Id: I420da1b5d79cf70d8cf134eaf97bf0a22f61ffd0
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-arm64-asan-clang15
Reviewed-on: https://go-review.googlesource.com/c/go/+/651755
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/compile: use inline-Pos-based recursion test
David Chase [Wed, 5 Mar 2025 18:44:12 +0000 (13:44 -0500)]
cmd/compile: use inline-Pos-based recursion test

Look at the inlining stack of positions for a call site,
if the line/col/file of the call site appears in that
stack, do not inline.  This subsumes all the other
recently-added recursive inlining checks, but they are
left in to make this easier+safer to backport.

Fixes #72090

Change-Id: I0f487bb0d4c514015907c649312672b7be464abd
Reviewed-on: https://go-review.googlesource.com/c/go/+/655155
Reviewed-by: 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>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
5 months agogo/types,types2: externalize used objects
Rob Findley [Wed, 19 Feb 2025 22:07:09 +0000 (22:07 +0000)]
go/types,types2: externalize used objects

The 'used' field on Var and PkgName is fundamentally an aspect of the
type checking pass: it records when objects are used, for the purposes
of reporting errors for unused variables or package names. While
expedient and performant, recording this information in the types.Object
instances themselves increases the memory footprint of type-checked
packages, and (as we saw in golang/go#71817) can lead to data races when
Objects are reused in follow-up type checking, such as is done with the
CheckExpr and Eval APIs.

Fix this by externalizing the 'used' information into two maps (one for
variables and one for packages) on the types.Checker, so that they are
garbage-collected after type checking, and cannot be a source of data
races.

Benchmarks showed essentially no change in performance.

Fixes golang/go#71817

Change-Id: I40daeabe4ecaca3bcb494e2f1c62a04232098e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/650796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
5 months agohtml/template: example for disallowed script type change
Sean Liao [Fri, 19 May 2023 19:11:19 +0000 (20:11 +0100)]
html/template: example for disallowed script type change

Fixes #59112

Change-Id: I617f8a4581a55a0f134f488462f415ec22eb4ee3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496145
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agonet/http: make http.FileServer return 404 when a path is invalid/unsafe
Grégoire Lodi [Wed, 5 Mar 2025 09:44:46 +0000 (09:44 +0000)]
net/http: make http.FileServer return 404 when a path is invalid/unsafe

This PR adds error handling in net/http toHTTPError to return a 404
instead of a 500 when net/http fs.Dir.Open throws the error http:
invalid or unsafe file path.

Fixes #72091

Change-Id: I7941c8fca5160a4a82732dc1d05b9b95eac84fbf
GitHub-Last-Rev: 04b5019dfb629820621f3776d6f22fd754171565
GitHub-Pull-Request: golang/go#72108
Reviewed-on: https://go-review.googlesource.com/c/go/+/654975
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
5 months agocmd/go: skip some tests that run builds in short mode
Michael Matloob [Fri, 28 Feb 2025 21:57:44 +0000 (16:57 -0500)]
cmd/go: skip some tests that run builds in short mode

cmd/go tests that run builds are generally skipped in short mode. This
change will adds skips for some tests that were running builds.

I found these by sorting tests by elapsed time and removing the top
tests that invoked go build. It's our practice to skip tests that run go
build without the -n flag (which prints but doesn't execute commands).

On my work laptop this reduces test run time from about 20 seconds to
about 16 seconds. On my linux workstation it reduces test run time from
about 10 seconds to about 5 seconds.

Change-Id: I18ffcc231df013cb6ac5f5eb3544bed28dadeda8
Reviewed-on: https://go-review.googlesource.com/c/go/+/653775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agogo/types: add Var.Kind() VarKind method
Alan Donovan [Tue, 28 Jan 2025 18:44:41 +0000 (13:44 -0500)]
go/types: add Var.Kind() VarKind method

This CL adds an enum type, VarKind, that discriminates among
the various kinds of Var, and adds setter/getter methods
for Var's kind field.

Beware: NewVar has a weaker postcondition: the Var objects it
returns are not completely initialized and require a call to
Var.SetKind. This should only affect importers.

No changes are needed to the export data, since the kind can
always be deduced from the context when decoding.

See CL 645656 for the corresponding x/tools changes.

+ test, relnote, API

Updates golang/go#70250

Change-Id: Icde86ad22a880cde6f50bc12bf38004a5c6a1025
Reviewed-on: https://go-review.googlesource.com/c/go/+/645115
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
5 months agotext/template: provide example of overwriting template func after parse
rorycl [Tue, 4 Mar 2025 22:47:17 +0000 (22:47 +0000)]
text/template: provide example of overwriting template func after parse

This example illustrates how to overwrite a template function after parsing a template.

This example is intended to clarify the point made in the template.Funcs docstring
that "[i]t is legal to overwrite elements of the map."

Change-Id: Ibded05974d580c54a24fcc16687fd52ce21133ff
GitHub-Last-Rev: ef19a221ab44f47695c27b3114281112231a1b42
GitHub-Pull-Request: golang/go#72094
Reviewed-on: https://go-review.googlesource.com/c/go/+/654416
Reviewed-by: Junyang Shao <shaojunyang@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>
5 months agoencoding/pem: clarify Decode only works on lines
Sean Liao [Sat, 6 Aug 2022 13:28:16 +0000 (14:28 +0100)]
encoding/pem: clarify Decode only works on lines

Fixes #53524

Change-Id: I929ee3c055c3ca564cd6cc374124f493aea2fbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/421636
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agocmd/compile: improve issue62407_test
go101 [Sat, 21 Dec 2024 13:31:27 +0000 (13:31 +0000)]
cmd/compile: improve issue62407_test

The original issue62407_test also passes with versions prior to 1.23.
The improvement makes it fail with versions prior to 1.23.

Change-Id: I94bfb9d1ac695c8e07997d7029fc2101535e14f8
GitHub-Last-Rev: 44be2a610a1a79d04dc3d228af2b313200f4d900
GitHub-Pull-Request: golang/go#70938
Reviewed-on: https://go-review.googlesource.com/c/go/+/638036
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 months agocmd/compile: add tests for too-large shift amounts
Keith Randall [Mon, 3 Mar 2025 22:46:18 +0000 (14:46 -0800)]
cmd/compile: add tests for too-large shift amounts

Update #72018

Change-Id: I3188019658c37da3c31f06472023b39e13170ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/654316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
5 months agotesting: modify got,want equal comparison for unordered example output
Jes Cok [Mon, 3 Mar 2025 13:34:15 +0000 (13:34 +0000)]
testing: modify got,want equal comparison for unordered example output

This change eliminates sortLines function to avoid strings.Join calls.

It's not a performance problem, this change tries to make the comparison
more straightforward.

Change-Id: I3a7ae877c9fc927833ab9f143205f7e007197f60
GitHub-Last-Rev: a71aa58c58533fed24ba9c101664b977a094caf9
GitHub-Pull-Request: golang/go#72025
Reviewed-on: https://go-review.googlesource.com/c/go/+/653556
Reviewed-by: Junyang Shao <shaojunyang@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>
5 months agosync: document behavior of Map.Delete when key is not present
Filippo Valsorda [Wed, 8 Jan 2025 10:16:48 +0000 (11:16 +0100)]
sync: document behavior of Map.Delete when key is not present

Change-Id: I6a6a465631e91141a5fcc9c04a7df0dc47780731
Reviewed-on: https://go-review.googlesource.com/c/go/+/643955
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agonet/http: don't modify caller's tls.Config.NextProtos
Damien Neil [Tue, 4 Mar 2025 23:20:28 +0000 (15:20 -0800)]
net/http: don't modify caller's tls.Config.NextProtos

Clone the input slice before adjusting NextProtos
to add or remove "http/1.1" and "h2" entries,
so as not to modify a slice that the caller might be using.
(We clone the tls.Config that contains the slice, but
that's a shallow clone.)

Fixes #72100

Change-Id: I9f228b8fb6f6f2ca5023179ec114929c002dbda9
Reviewed-on: https://go-review.googlesource.com/c/go/+/654875
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocontext: skip allocs test with -asan
Damien Neil [Tue, 4 Mar 2025 23:39:42 +0000 (15:39 -0800)]
context: skip allocs test with -asan

Allocates more with -asan after CL 653795.

Change-Id: Ib8cc1de1d649623713b6fc123c1c59a47528857b
Reviewed-on: https://go-review.googlesource.com/c/go/+/654876
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agoall: update golang.org/x/net
Junyang Shao [Tue, 4 Mar 2025 19:45:29 +0000 (19:45 +0000)]
all: update golang.org/x/net

For #71984

Change-Id: Ic15826f09ea818f8833bd3d979bffaede24d49df
Reviewed-on: https://go-review.googlesource.com/c/go/+/654717
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>

5 months agocrypto/elliptic: drop hidden Inverse and CombinedMult methods
Filippo Valsorda [Fri, 3 Jan 2025 19:46:29 +0000 (20:46 +0100)]
crypto/elliptic: drop hidden Inverse and CombinedMult methods

These methods were previously used by crypto/ecdsa, but now not even
ecdsa_legacy.go uses them. Neither were ever documented.

Inverse was available only on P256() and only on amd64 and arm64, so
hopefully no one used it. CombinedMult was always available on all
curves, so it's possible some application might have used it, but all
the samples on GitHub I can find copied the old crypto/ecdsa package,
which does a conditional interface upgrade with a fallback, so they
won't break.

Change-Id: I6a6a4656ee1ab98438ca0fb20bea53b229cd7e71
Reviewed-on: https://go-review.googlesource.com/c/go/+/640116
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agoruntime: decorate anonymous memory mappings
Lénaïc Huard [Sat, 1 Feb 2025 13:19:04 +0000 (14:19 +0100)]
runtime: decorate anonymous memory mappings

Leverage the prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...) API to name
the anonymous memory areas.

This API has been introduced in Linux 5.17 to decorate the anonymous
memory areas shown in /proc/<pid>/maps.

This is already used by glibc. See:
* https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=27dfd1eb907f4615b70c70237c42c552bb4f26a8;hb=HEAD#l2434
* https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/setvmaname.c;h=ea93a5ffbebc9e5a7e32a297138f465724b4725f;hb=HEAD#l63

This can be useful when investigating the memory consumption of a
multi-language program.
On a 100% Go program, pprof profiler can be used to profile the memory
consumption of the program. But pprof is only aware of what happens
within the Go world.

On a multi-language program, there could be a doubt about whether the
suspicious extra-memory consumption comes from the Go part or the native
part.

With this change, the following Go program:

        package main

        import (
                "fmt"
                "log"
                "os"
        )

        /*
        #include <stdlib.h>

        void f(void)
        {
          (void)malloc(1024*1024*1024);
        }
        */
        import "C"

        func main() {
                C.f()

                data, err := os.ReadFile("/proc/self/maps")
                if err != nil {
                        log.Fatal(err)
                }
                fmt.Println(string(data))
        }

produces this output:

        $ GLIBC_TUNABLES=glibc.mem.decorate_maps=1 ~/doc/devel/open-source/go/bin/go run .
        00400000-00402000 r--p 00000000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00402000-004a4000 r-xp 00002000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        004a4000-00574000 r--p 000a4000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00574000-00575000 r--p 00173000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00575000-00580000 rw-p 00174000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00580000-005a4000 rw-p 00000000 00:00 0
        2e075000-2e096000 rw-p 00000000 00:00 0                                  [heap]
        c000000000-c000400000 rw-p 00000000 00:00 0                              [anon: Go: heap]
        c000400000-c004000000 ---p 00000000 00:00 0                              [anon: Go: heap reservation]
        777f40000000-777f40021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f40021000-777f44000000 ---p 00000000 00:00 0
        777f44000000-777f44021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f44021000-777f48000000 ---p 00000000 00:00 0
        777f48000000-777f48021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f48021000-777f4c000000 ---p 00000000 00:00 0
        777f4c000000-777f4c021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f4c021000-777f50000000 ---p 00000000 00:00 0
        777f50000000-777f50021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f50021000-777f54000000 ---p 00000000 00:00 0
        777f55afb000-777f55afc000 ---p 00000000 00:00 0
        777f55afc000-777f562fc000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216378]
        777f562fc000-777f562fd000 ---p 00000000 00:00 0
        777f562fd000-777f56afd000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216377]
        777f56afd000-777f56afe000 ---p 00000000 00:00 0
        777f56afe000-777f572fe000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216376]
        777f572fe000-777f572ff000 ---p 00000000 00:00 0
        777f572ff000-777f57aff000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216375]
        777f57aff000-777f57b00000 ---p 00000000 00:00 0
        777f57b00000-777f58300000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216374]
        777f58300000-777f58400000 rw-p 00000000 00:00 0                          [anon: Go: page alloc index]
        777f58400000-777f5a400000 rw-p 00000000 00:00 0                          [anon: Go: heap index]
        777f5a400000-777f6a580000 ---p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f6a580000-777f6a581000 rw-p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f6a581000-777f7a400000 ---p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f7a400000-777f8a580000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f8a580000-777f8a581000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f8a581000-777f9c430000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9c430000-777f9c431000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9c431000-777f9e806000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9e806000-777f9e807000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9e807000-777f9ec00000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ec36000-777f9ecb6000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9ecb6000-777f9ecc6000 rw-p 00000000 00:00 0                          [anon: Go: gc bits]
        777f9ecc6000-777f9ecd6000 rw-p 00000000 00:00 0                          [anon: Go: allspans array]
        777f9ecd6000-777f9ece7000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9ece7000-777f9ed67000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ed67000-777f9ed68000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9ed68000-777f9ede7000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ede7000-777f9ee07000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9ee07000-777f9ee0a000 rw-p 00000000 00:00 0                          [anon: glibc: loader malloc]
        777f9ee0a000-777f9ee2e000 r--p 00000000 00:21 48158213                   /usr/lib/libc.so.6
        777f9ee2e000-777f9ef9f000 r-xp 00024000 00:21 48158213                   /usr/lib/libc.so.6
        777f9ef9f000-777f9efee000 r--p 00195000 00:21 48158213                   /usr/lib/libc.so.6
        777f9efee000-777f9eff2000 r--p 001e3000 00:21 48158213                   /usr/lib/libc.so.6
        777f9eff2000-777f9eff4000 rw-p 001e7000 00:21 48158213                   /usr/lib/libc.so.6
        777f9eff4000-777f9effc000 rw-p 00000000 00:00 0
        777f9effc000-777f9effe000 rw-p 00000000 00:00 0                          [anon: glibc: loader malloc]
        777f9f00a000-777f9f04a000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9f04a000-777f9f04c000 r--p 00000000 00:00 0                          [vvar]
        777f9f04c000-777f9f04e000 r--p 00000000 00:00 0                          [vvar_vclock]
        777f9f04e000-777f9f050000 r-xp 00000000 00:00 0                          [vdso]
        777f9f050000-777f9f051000 r--p 00000000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f051000-777f9f07a000 r-xp 00001000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f07a000-777f9f085000 r--p 0002a000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f085000-777f9f087000 r--p 00034000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f087000-777f9f088000 rw-p 00036000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f088000-777f9f089000 rw-p 00000000 00:00 0
        7ffc7bfa7000-7ffc7bfc8000 rw-p 00000000 00:00 0                          [stack]
        ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

The anonymous memory areas are now labelled so that we can see which
ones have been allocated by the Go runtime versus which ones have been
allocated by the glibc.

Fixes #71546

Change-Id: I304e8b4dd7f2477a6da794fd44e9a7a5354e4bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/646095
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
5 months agonet/http/httputil: skip new test on Plan 9
Ian Lance Taylor [Tue, 4 Mar 2025 18:07:15 +0000 (10:07 -0800)]
net/http/httputil: skip new test on Plan 9

TestReverseProxyWebSocketHalfTCP requires half closed connections,
which aren't supported on Plan 9.

For #35892
Fixes #72095

Change-Id: I64b458bc15ac3b8eda43dc871bf67ada32a59708
Reviewed-on: https://go-review.googlesource.com/c/go/+/654636
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agoos: guarantee min buffer size for ReadFile reads on /proc-like files
Brad Fitzpatrick [Mon, 3 Mar 2025 17:21:26 +0000 (09:21 -0800)]
os: guarantee min buffer size for ReadFile reads on /proc-like files

For instance, this fixes os.ReadFile on plan9's /net/iproute file.

But it's not necessarily plan9-specific; Linux /proc and /sys filesystems
can exhibit the same problems.

Fixes #72080

Change-Id: I60b035913f583a91c6d84df95a6ea7b7ec2b3c92
Reviewed-on: https://go-review.googlesource.com/c/go/+/654315
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>

5 months agonet/http: speed up cookie and method validation
Julien Cretel [Mon, 17 Feb 2025 18:39:58 +0000 (18:39 +0000)]
net/http: speed up cookie and method validation

Fixes #67031

Change-Id: I1d764afdc7e50d61007f5f71a674eb6872ce507a
GitHub-Last-Rev: 869535e843d2133fa5279297b002dd96725384e0
GitHub-Pull-Request: golang/go#71798
Reviewed-on: https://go-review.googlesource.com/c/go/+/650195
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
5 months agomime/quotedprintable: accept LWSP-char after =
Simon Ser [Sun, 22 Dec 2024 10:28:56 +0000 (10:28 +0000)]
mime/quotedprintable: accept LWSP-char after =

SP and HTAB are allowed after a = before the following CRLF.

RFC 2045 section 6.7 describes the ABNF for the quoted-printable encoding:

    qp-line := *(qp-segment transport-padding CRLF)
               qp-part transport-padding
    qp-segment := qp-section *(SPACE / TAB) "="
    transport-padding := *LWSP-char
                          ; Composers MUST NOT generate
                          ; non-zero length transport
                          ; padding, but receivers MUST
                          ; be able to handle padding
                          ; added by message transports.

RFC 822 defines LWSP-char as:

    LWSP-char   =  SPACE / HTAB

Dovecot's imaptest contains such a message in
src/tests/fetch-binary-mime-qp.mbox.

Fixes #70952

Change-Id: Ie05921088d7e4d6c92c4bf79b0f4a13586230753
GitHub-Last-Rev: e6e6eee8ebc2f629644a1d99129fb57cce58058f
GitHub-Pull-Request: golang/go#70951
Reviewed-on: https://go-review.googlesource.com/c/go/+/638276
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>

5 months agonet/http: support TCP half-close when HTTP is upgraded in ReverseProxy
Mark Wakefield [Thu, 2 Jan 2025 19:18:01 +0000 (19:18 +0000)]
net/http: support TCP half-close when HTTP is upgraded in ReverseProxy

This CL propagates closing the write stream from either side of the
reverse proxy and ensures the proxy waits for both copy-to and the
copy-from the backend to complete.

The new unit test checks communication through the reverse proxy when
the backend or frontend closes either the read or write streams.
That closing the write stream is propagated through the proxy from
either the backend or the frontend. That closing the read stream is
not propagated through the proxy.

Fixes #35892

Change-Id: I83ce377df66a0f17b9ba2b53caf9e4991a95f6a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/637939
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matej Kramny <matejkramny@gmail.com>
5 months agonet/http: check server shutting down before processing the request
wineandchord [Tue, 20 Feb 2024 07:18:11 +0000 (07:18 +0000)]
net/http: check server shutting down before processing the request

The root cause of issue #65802 is a small race condition that occurs between
two events:

1. During the HTTP server shutdown, a connection in an idle state is identified
and closed.
2. The connection, although idle, has just finished reading a complete request
before being closed and hasn't yet updated its state to active.

In this scenario, despite the connection being closed, the request continues to
be processed. This not only wastes server resources but also prevents the
client request from being retried.

Fixes #65802

Change-Id: Ic22abb4497be04f6c84dff059df00f2c319d8652
GitHub-Last-Rev: 426099a3e75f51b80f8ca866938f31417d75ff89
GitHub-Pull-Request: golang/go#65805
Reviewed-on: https://go-review.googlesource.com/c/go/+/565277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>

5 months agocmd/compile,cmd/link: move to DWARF5-style location lists
Than McIntosh [Fri, 13 Dec 2024 01:47:30 +0000 (20:47 -0500)]
cmd/compile,cmd/link: move to DWARF5-style location lists

This patch updates the compiler to generate DWARF5-style location
lists (e.g. entries that feed into .debug_loclists) as opposed to
DWARF4-style location lists (which wind up in .debug_loc). The DWARF5
format is much more compact, and can make indirect references to text
addresses via the .debug_addr section for further space savings.

Updates #26379.

Change-Id: If2e6fce1136d9cba5125ea51a71419596d1d1691
Reviewed-on: https://go-review.googlesource.com/c/go/+/635836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
5 months agocmd/compile,cmd/link: move to DWARF5-style range lists
Than McIntosh [Thu, 12 Dec 2024 00:20:58 +0000 (19:20 -0500)]
cmd/compile,cmd/link: move to DWARF5-style range lists

This patch updates the compiler to generate DWARF5-style range lists
(e.g. entries that feed into .debug_rnglists) as opposed to
DWARF4-style range lists (which wind up in .debug_ranges). The DWARF5
format is much more compact, and can make indirect references to text
address via the .debug_addr section for further space savings.

Updates #26379.

Change-Id: I273a6283484b7fe33d79d5412e31c5155b22a7c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/635345
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agocmd/compile: fix out of memory when inlining closure
Cuong Manh Le [Mon, 3 Mar 2025 13:45:13 +0000 (20:45 +0700)]
cmd/compile: fix out of memory when inlining closure

CL 629195 strongly favor closure inlining, allowing closures to be
inlined more aggressively.

However, if the closure body contains a call to a function, which itself
is one of the call arguments, it causes the infinite inlining.

Fixing this by prevent this kind of functions from being inlinable.

Fixes #72063

Change-Id: I5fb5723a819b1e2c5aadb57c1023ec84ca9fa53c
Reviewed-on: https://go-review.googlesource.com/c/go/+/654195
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/internal/fips140/bigmod/_asm: update avo to v0.6.0
Egon Elbre [Thu, 27 Feb 2025 01:43:43 +0000 (03:43 +0200)]
crypto/internal/fips140/bigmod/_asm: update avo to v0.6.0

avo v0.4.0 x/tools dependency crashes while parsing with Go 1.25.

Change-Id: Ic951066b0b39b477887ad0e32be44f4d88d4c2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/653175
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agonet/textproto: document enforcement of RFC 9112 for headers
Sean Liao [Sat, 27 Jul 2024 08:15:31 +0000 (09:15 +0100)]
net/textproto: document enforcement of RFC 9112 for headers

Fixes #68590

Change-Id: Ie7cf1fe8379182f86317d5ebb7f45a404ecd70e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/601555
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agocmd/internal/obj/loong64: add F{MAXA/MINA}.{S/D} instructions
Xiaolin Zhao [Mon, 30 Dec 2024 02:08:58 +0000 (10:08 +0800)]
cmd/internal/obj/loong64: add F{MAXA/MINA}.{S/D} instructions

Go asm syntax:
F{MAXA/MINA}{F/D} FK, FJ, FD

Equivalent platform assembler syntax:
f{maxa/mina}.{s/d} fd, fj, fk

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I6790657d2f36bdf5e6818b6c0aaa48117e782b8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/653915
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agocmd/internal/obj/loong64: add {V,XV}{SLL/SRL/SRA/ROTR}[I].{B/H/W/D} instructions...
Xiaolin Zhao [Thu, 19 Dec 2024 11:03:43 +0000 (19:03 +0800)]
cmd/internal/obj/loong64: add {V,XV}{SLL/SRL/SRA/ROTR}[I].{B/H/W/D} instructions support

Go asm syntax:
 V{SLL/SRL/SRA/ROTR}{B/H/W/V} $1, V2, V3
XV{SLL/SRL/SRA/ROTR}{B/H/W/V} $1, X2, X3
 V{SLL/SRL/SRA/ROTR}{B/H/W/V} VK, VJ, VD
XV{SLL/SRL/SRA/ROTR}{B/H/W/V} XK, XJ, XD

Equivalent platform assembler syntax:
 v{sll/srl/sra/rotr}i.{b/h/w/d} v3, v2, $1
xv{sll/srl/sra/rotr}i.{b/h/w/d} x3, x2, $1
 v{sll/srl/sra/rotr}.{b/h/w/d} vd, vj, vk
xv{sll/srl/sra/rotr}.{b/h/w/d} xd, xj, xk

Change-Id: Ie4f04de1c77491a71688d226f7d91cd1a699ab47
Reviewed-on: https://go-review.googlesource.com/c/go/+/637775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agogo/types, types2: remove remaining mentions of core type in error messages
Robert Griesemer [Mon, 3 Mar 2025 20:26:51 +0000 (12:26 -0800)]
go/types, types2: remove remaining mentions of core type in error messages

The implementatiom still calls coreType in places and refers to
"core types" in comments, but user-visible error messages don't
know about core types anymore.

This brings the user-visible part of the implementation in sync with
the spec which doesn't have the notion of core types anymore.

For #70128.

Change-Id: I14bc6767a83e8f54b10ebe99a7df0b98cd9fca87
Reviewed-on: https://go-review.googlesource.com/c/go/+/654395
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
5 months agocontext: use atomic operation in ctx.Err
Damien Neil [Fri, 28 Feb 2025 23:22:58 +0000 (15:22 -0800)]
context: use atomic operation in ctx.Err

oos: darwin
goarch: arm64
pkg: context
cpu: Apple M1 Pro
               │ /tmp/bench.0.mac │          /tmp/bench.1.mac           │
               │      sec/op      │   sec/op     vs base                │
ErrOK-10             13.750n ± 1%   2.080n ± 0%  -84.87% (p=0.000 n=10)
ErrCanceled-10       13.530n ± 1%   3.248n ± 1%  -76.00% (p=0.000 n=10)
geomean               13.64n        2.599n       -80.94%

goos: linux
goarch: amd64
pkg: context
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz
               │ /tmp/bench.0.linux │         /tmp/bench.1.linux          │
               │       sec/op       │   sec/op     vs base                │
ErrOK-16               21.435n ± 0%   4.243n ± 0%  -80.21% (p=0.000 n=10)
ErrCanceled-16         21.445n ± 0%   5.070n ± 0%  -76.36% (p=0.000 n=10)
geomean                 21.44n        4.638n       -78.37%

Fixes #72040

Change-Id: I3b337ab1934689d2da4134492ee7c5aac8f92845
Reviewed-on: https://go-review.googlesource.com/c/go/+/653795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
5 months agoos: only call GetConsoleMode for char devices
qmuntal [Mon, 3 Mar 2025 11:28:01 +0000 (12:28 +0100)]
os: only call GetConsoleMode for char devices

There is no need to call GetConsoleMode if we know that the file
type is not FILE_TYPE_CHAR. This is a tiny performance optimization,
as I sometimes see this call in profiles.

Change-Id: I9e9237908585d0ec8360930a0406b26f52699b92
Reviewed-on: https://go-review.googlesource.com/c/go/+/654155
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agogo/types, types2: remove remaining references to coreType in literals.go
Robert Griesemer [Wed, 26 Feb 2025 23:23:59 +0000 (15:23 -0800)]
go/types, types2: remove remaining references to coreType in literals.go

For now, use commonUnder (formerly called sharedUnder) and update
error messages and comments. We can provide better error messages
in individual cases eventually.

For #70128.

Change-Id: I906ba9a0c768f6499c1683dc9be3ad27da8007a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/653156
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: Robert Findley <rfindley@google.com>
5 months agogo/types, types2: remove most remaining references to coreType in builtin.go
Robert Griesemer [Wed, 26 Feb 2025 23:14:30 +0000 (15:14 -0800)]
go/types, types2: remove most remaining references to coreType in builtin.go

For now, use commonUnder (formerly called sharedUnder) and update
error messages and comments. We can provide better error messages
in individual cases eventually.

Kepp using coreType for make built-in for now because it must accept
different channel types with non-conflicting directions and identical
element types. Added extra test cases.

While at it, rename sharedUnder, sharedUnderOrChan to commonUnder
and commonUnderOrChan, respectively (per suggestion from rfindley).

For #70128.

Change-Id: I11f3d5ce858746574f4302271d8cb763c2cdcf98
Reviewed-on: https://go-review.googlesource.com/c/go/+/653139
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
5 months agocrypto/rsa: use Div instead of GCD for trial division
Filippo Valsorda [Fri, 3 Jan 2025 13:03:08 +0000 (14:03 +0100)]
crypto/rsa: use Div instead of GCD for trial division

Div is way faster. We could actually test a lot more primes and still
gain performance despite the diminishing returns, but necessarily it
would have marginal impact overall.

fips140: off
goos: linux
goarch: amd64
pkg: crypto/rsa
cpu: AMD Ryzen 7 PRO 8700GE w/ Radeon 780M Graphics
                    │  e325b41ad1  │             0f611af2e1              │
                    │    sec/op    │   sec/op     vs base                │
GenerateKey/2048-16   124.19m ± 0%   39.93m ± 0%  -67.85% (p=0.000 n=20)

Surprisingly, the performance gain is similar on ARM64, which doesn't
have intrinsified math.Div.

fips140: off
goos: darwin
goarch: arm64
pkg: crypto/rsa
cpu: Apple M2
                   │  e325b41ad1  │             6276161a7f              │
                   │    sec/op    │   sec/op     vs base                │
GenerateKey/2048-8   136.49m ± 0%   47.97m ± 1%  -64.86% (p=0.000 n=20)

Change-Id: I6a6a46560331198312bd09c1cbe4d2b3c370c552
Reviewed-on: https://go-review.googlesource.com/c/go/+/639955
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
5 months agogo/types, types2: remove references to core type in append
Robert Griesemer [Wed, 26 Feb 2025 17:57:31 +0000 (09:57 -0800)]
go/types, types2: remove references to core type in append

Writing explicit code for this case turned out to be simpler
and easier to reason about then relying on a helper functions
(except for typeset).

While at it, make append error messages more consistent.

For #70128.

Change-Id: I3dc79774249929de5061b4301ab2506d4b3da0d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/653095
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
5 months agotesting: fix testing.B.Loop doc on loop condition
Junyang Shao [Fri, 21 Feb 2025 16:23:36 +0000 (16:23 +0000)]
testing: fix testing.B.Loop doc on loop condition

As mentioned by
https://github.com/golang/go/issues/61515#issuecomment-2656656554,
the documentation should be relaxed.

Change-Id: I9f18301e1a4e4d9a72c9fa0b1132b1ba3cc57b03
Reviewed-on: https://go-review.googlesource.com/c/go/+/651435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>

5 months agonet: fix parsing of interfaces on plan9 without associated devices
Brad Fitzpatrick [Sun, 2 Mar 2025 04:34:45 +0000 (20:34 -0800)]
net: fix parsing of interfaces on plan9 without associated devices

Fixes #72060
Updates #39908

Change-Id: I7d5bda1654753acebc8aa9937d010b41c5722b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/654055
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>

5 months agonet/http: allocate CloseNotifier channel lazily
Jakob Ackermann [Tue, 7 Jan 2025 22:33:05 +0000 (22:33 +0000)]
net/http: allocate CloseNotifier channel lazily

The CloseNotifier interface is deprecated. We can defer allocating the
backing channel until the first use of CloseNotifier.

goos: linux
goarch: amd64
pkg: net/http
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                   │   before    │               after                │
                   │   sec/op    │   sec/op     vs base               │
Server-8             160.8µ ± 2%   160.1µ ± 1%       ~ (p=0.353 n=10)
CloseNotifier/h1-8   222.1µ ± 4%   226.4µ ± 7%       ~ (p=0.143 n=10)
geomean              189.0µ        190.4µ       +0.75%

                   │    before    │                after                │
                   │     B/op     │     B/op      vs base               │
Server-8             2.292Ki ± 0%   2.199Ki ± 0%  -4.07% (p=0.000 n=10)
CloseNotifier/h1-8   3.224Ki ± 0%   3.241Ki ± 0%  +0.51% (p=0.000 n=10)
geomean              2.718Ki        2.669Ki       -1.80%

                   │   before   │                after                │
                   │ allocs/op  │ allocs/op   vs base                 │
Server-8             21.00 ± 0%   20.00 ± 0%  -4.76% (p=0.000 n=10)
CloseNotifier/h1-8   50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean              32.40        31.62       -2.41%
¹ all samples are equal

Change-Id: I3f35d56b8356fb660589b7708a023e4480f32067
GitHub-Last-Rev: c75696b9b8498ae03a4ad9527b9b7c8337415456
GitHub-Pull-Request: golang/go#71163
Reviewed-on: https://go-review.googlesource.com/c/go/+/640598
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>