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

61720 Commits

Author SHA1 Message Date
Russ Cox
28f4e14ebe crypto/internal/fips140deps: fix test for running in FIPS snapshot
In a FIPS snapshot, the import paths have a snapshot version number.
Remove that version in the test before proceeding with the usual checks.

Change-Id: I15c9d11dcac6d33330b334b8e5056c215bffa75c
Reviewed-on: https://go-review.googlesource.com/c/go/+/629977
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2024-11-21 10:40:09 +00:00
Robert Griesemer
a2a4f00783 go/types, types2: simplify Checker.resolveBaseTypeName (cleanup)
Method receivers that denote cgo-generated types are not permitted
per issues #60725 and #57926. There's no need to collect such methods
in the first place. Simplify Checker.resolveBaseTypeName so that it
doesn't find a base type name in these cases.

Also, simplify the test case for issue #59944 and update it to use
current cgo-generated output.

For #60725.
For #57926.
For #59944.

Change-Id: I70594daebc3d4d594c5b06be138f66f8927b0e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/630395
Reviewed-by: 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>
Auto-Submit: Robert Griesemer <gri@google.com>
2024-11-21 05:01:49 +00:00
Robert Griesemer
b631b8e674 go/types, types: better error message position for invalid receiver errors
Errors related to invalid receivers are based on the receiver base type.
Position the error message at the receiver base type, not the receiver
variable.

Add an additional example with an (invalid) generic receiver type.

Also, fix a panic when the code is run w/o Alias types enabled.

Change-Id: I610df171e4c447bbe03b904937c12e4170508b3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/630376
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: 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>
2024-11-21 05:01:47 +00:00
Ian Lance Taylor
a9428eab40 cmd/cgo/internal/testsanitizers: use t.TempDir
Change-Id: I6b2c25ab045aaec8bb6c25511b12d178d155fc25
Reviewed-on: https://go-review.googlesource.com/c/go/+/630338
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-21 02:18:27 +00:00
Ian Lance Taylor
f96987888f cmd/cgo/internal/testsanitizers: don't create fuzz corpus
The TestASANFuzz test would sometimes create a fuzz corpus
in testdata/testdata/FuzzReverse. Avoid modifying the source
directory by building the test with "go test -c" and running
it in a temporary directory.

Change-Id: I12e2da4c85165fa35e0dc1aa6b46c6d0fbccaab8
Reviewed-on: https://go-review.googlesource.com/c/go/+/630377
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-21 02:17:08 +00:00
Rhys Hiltner
adc9c45587 runtime: clean up new lock2 structure
Simplify some flow control, as suggested on https://go.dev/cl/620435.

The MutexCapture microbenchmark shows a bit of throughput improvement at
moderate levels of contention, and little change to capture and
starvation. (Note that the capture and starvation figures below are in
terms of power-of-two buckets multiplied by throughput, so they either
follow similar patterns or move by a factor of two.)

For #68578

goos: linux
goarch: amd64
pkg: runtime
cpu: 13th Gen Intel(R) Core(TM) i7-13700H
                │     old      │                 new                  │
                │    sec/op    │    sec/op     vs base                │
MutexCapture      18.21n ±  0%   18.35n ±  0%   +0.77% (p=0.000 n=10)
MutexCapture-2    21.46n ±  8%   21.05n ± 12%        ~ (p=0.796 n=10)
MutexCapture-3    22.56n ±  9%   22.59n ± 18%        ~ (p=0.631 n=10)
MutexCapture-4    22.85n ±  5%   22.74n ±  2%        ~ (p=0.565 n=10)
MutexCapture-5    22.84n ±  5%   22.50n ± 14%        ~ (p=0.912 n=10)
MutexCapture-6    23.33n ± 14%   22.22n ±  3%   -4.78% (p=0.004 n=10)
MutexCapture-7    27.04n ± 14%   23.78n ± 15%        ~ (p=0.089 n=10)
MutexCapture-8    25.44n ± 10%   23.03n ±  6%   -9.48% (p=0.004 n=10)
MutexCapture-9    25.56n ±  7%   24.39n ± 11%        ~ (p=0.218 n=10)
MutexCapture-10   26.77n ± 10%   24.00n ±  7%  -10.33% (p=0.023 n=10)
MutexCapture-11   27.02n ±  7%   24.55n ± 15%   -9.18% (p=0.035 n=10)
MutexCapture-12   26.71n ±  8%   24.96n ±  8%        ~ (p=0.148 n=10)
MutexCapture-13   25.58n ±  4%   25.82n ±  5%        ~ (p=0.271 n=10)
MutexCapture-14   26.86n ±  6%   25.91n ±  7%        ~ (p=0.529 n=10)
MutexCapture-15   25.12n ± 13%   26.16n ±  4%        ~ (p=0.353 n=10)
MutexCapture-16   26.18n ±  4%   26.21n ±  9%        ~ (p=0.838 n=10)
MutexCapture-17   26.04n ±  4%   25.85n ±  5%        ~ (p=0.363 n=10)
MutexCapture-18   26.02n ±  7%   25.93n ±  5%        ~ (p=0.853 n=10)
MutexCapture-19   25.67n ±  5%   26.21n ±  4%        ~ (p=0.631 n=10)
MutexCapture-20   25.50n ±  6%   25.99n ±  8%        ~ (p=0.404 n=10)
geomean           24.73n         24.02n         -2.88%

                │      old       │                  new                   │
                │ sec/streak-p90 │ sec/streak-p90  vs base                │
MutexCapture        76.36m ±  0%    76.96m ±   0%   +0.79% (p=0.000 n=10)
MutexCapture-2     10.609µ ± 50%    5.390µ ± 119%        ~ (p=0.579 n=10)
MutexCapture-3      5.936µ ± 93%    5.782µ ±  18%        ~ (p=0.684 n=10)
MutexCapture-4      5.849µ ±  5%    5.820µ ±   2%        ~ (p=0.579 n=10)
MutexCapture-5      5.849µ ±  5%    5.759µ ±  14%        ~ (p=0.912 n=10)
MutexCapture-6      5.975µ ± 14%    5.687µ ±   3%   -4.81% (p=0.004 n=10)
MutexCapture-7      6.921µ ± 14%    6.086µ ±  18%        ~ (p=0.165 n=10)
MutexCapture-8      6.512µ ± 10%    5.894µ ±   6%   -9.50% (p=0.004 n=10)
MutexCapture-9      6.544µ ±  7%    6.245µ ±  11%        ~ (p=0.218 n=10)
MutexCapture-10     6.962µ ± 11%    6.144µ ±   7%  -11.76% (p=0.023 n=10)
MutexCapture-11     6.938µ ±  7%    6.284µ ± 130%        ~ (p=0.190 n=10)
MutexCapture-12     6.838µ ±  8%    6.408µ ±  13%        ~ (p=0.404 n=10)
MutexCapture-13     6.549µ ±  4%    6.608µ ±   5%        ~ (p=0.271 n=10)
MutexCapture-14     6.877µ ±  8%    6.634µ ±   7%        ~ (p=0.436 n=10)
MutexCapture-15     6.433µ ± 13%    6.697µ ±   4%        ~ (p=0.247 n=10)
MutexCapture-16     6.702µ ± 10%    6.711µ ± 116%        ~ (p=0.796 n=10)
MutexCapture-17     6.730µ ±  3%    6.619µ ±   5%        ~ (p=0.225 n=10)
MutexCapture-18     6.663µ ±  7%    6.716µ ±  13%        ~ (p=0.853 n=10)
MutexCapture-19     6.570µ ±  5%    6.710µ ±   4%        ~ (p=0.529 n=10)
MutexCapture-20     6.528µ ±  6%    6.775µ ±  11%        ~ (p=0.247 n=10)
geomean             10.66µ          10.00µ          -6.13%

                │      old       │                  new                   │
                │ sec/starve-p90 │ sec/starve-p90  vs base                │
MutexCapture-2    10.609µ ±  50%    5.390µ ± 119%        ~ (p=0.579 n=10)
MutexCapture-3     184.8µ ±  91%    183.9µ ±  48%        ~ (p=0.436 n=10)
MutexCapture-4     388.8µ ± 270%    375.6µ ± 280%        ~ (p=0.436 n=10)
MutexCapture-5     807.2µ ±  83%   2880.9µ ±  85%        ~ (p=0.105 n=10)
MutexCapture-6     2.272m ±  61%    2.173m ±  34%        ~ (p=0.280 n=10)
MutexCapture-7     1.351m ± 125%    2.990m ±  70%        ~ (p=0.393 n=10)
MutexCapture-8     3.328m ±  97%    3.064m ±  96%        ~ (p=0.739 n=10)
MutexCapture-9     3.526m ±  91%    3.081m ±  47%  -12.62% (p=0.015 n=10)
MutexCapture-10    3.641m ±  86%    3.228m ±  90%  -11.34% (p=0.005 n=10)
MutexCapture-11    3.324m ± 109%    3.190m ±  71%        ~ (p=0.481 n=10)
MutexCapture-12    3.519m ±  77%    3.200m ± 106%        ~ (p=0.393 n=10)
MutexCapture-13    3.353m ±  91%    3.368m ±  99%        ~ (p=0.853 n=10)
MutexCapture-14    3.314m ± 101%    3.396m ± 286%        ~ (p=0.353 n=10)
MutexCapture-15    3.534m ±  83%    3.397m ±  91%        ~ (p=0.739 n=10)
MutexCapture-16    3.485m ±  90%    3.436m ± 116%        ~ (p=0.853 n=10)
MutexCapture-17    6.516m ±  48%    3.452m ±  88%        ~ (p=0.190 n=10)
MutexCapture-18    6.645m ± 105%    3.439m ± 108%        ~ (p=0.218 n=10)
MutexCapture-19    6.521m ±  46%    4.907m ±  42%        ~ (p=0.529 n=10)
MutexCapture-20    6.532m ±  47%    3.516m ±  89%        ~ (p=0.089 n=10)
geomean            1.919m           1.783m          -7.06%

Change-Id: I36106e1baf8afd132f1568748d1b83b797fa260e
Reviewed-on: https://go-review.googlesource.com/c/go/+/629415
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
2024-11-20 23:27:49 +00:00
Damien Neil
c315862c99 os: add OpenInRoot
For #67002

Change-Id: If919ee8a5e3d90e91c7848330762e3254245fba1
Reviewed-on: https://go-review.googlesource.com/c/go/+/629555
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 23:21:51 +00:00
Damien Neil
a1b5394dba os: add Root.FS
For #67002

Change-Id: Ib687c92d645b9172677e5781a3e51ef1a0427c30
Reviewed-on: https://go-review.googlesource.com/c/go/+/629518
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 23:21:42 +00:00
Damien Neil
3d56891969 os: add Root.Stat and Root.Lstat
For #67002

Change-Id: I0903f45dbb4c44ea0280c340c96c5f3c3c0781be
Reviewed-on: https://go-review.googlesource.com/c/go/+/627475
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-11-20 23:21:29 +00:00
Damien Neil
49d24d469e os: add Root.Remove
For #67002

Change-Id: Ibbf44c0bf62f53695a7399ba0dae5b84d5efd374
Reviewed-on: https://go-review.googlesource.com/c/go/+/627076
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 23:21:14 +00:00
Damien Neil
43d90c6a14 os: add Root
Add os.Root, a type which represents a directory and permits performing
file operations within that directory.

For #67002

Change-Id: I863f4f1bc320a89b1125ae4237761f3e9320a901
Reviewed-on: https://go-review.googlesource.com/c/go/+/612136
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 23:20:45 +00:00
Junyang Shao
558f5372fc cmd/compile,testing: implement one-time rampup logic for testing.B.Loop
testing.B.Loop now does its own loop scheduling without interaction with b.N.
b.N will be updated to the actual iterations b.Loop controls when b.Loop returns false.

This CL also added tests for fixed iteration count (benchtime=100x case).

This CL also ensured that b.Loop() is inlined.

For #61515

Change-Id: Ia15f4462f4830ef4ec51327520ff59910eb4bb58
Reviewed-on: https://go-review.googlesource.com/c/go/+/627755
Reviewed-by: Michael Pratt <mpratt@google.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-11-20 23:19:48 +00:00
Russ Cox
60299c2513 cmd/go: revert "remove base.ShortPathConservative"
This reverts commit 2e07ff3543 (CL 630276).

Reason for revert: broke longtest builders.

Change-Id: I86b313cc6c1be061b408502e96a09916a6ac2c4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/630317
Auto-Submit: Russ Cox <rsc@golang.org>
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>
2024-11-20 23:14:02 +00:00
Tobias Klauser
c94a9fdf65 os: use ignoringEINTR2 in (*Process).pidWait
This was missed in CL 627479.

Change-Id: Ibcd511573c330bf782fe6a8a50d56bb70aedf3c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/629915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 22:54:25 +00:00
Michael Pratt
dce30a1920 cmd/compile: intrinsify swissmap match calls with SIMD on amd64
Use similar SIMD operations to the ones used in Abseil. We still
using 8-slot groups (even though the XMM registers could handle 16-slot
groups) to keep the implementation simpler (no changes to the memory
layout of maps).

Still, the implementations of matchH2 and matchEmpty are shorter than
the portable version using standard arithmetic operations. They also
return a packed bitset, which avoids the need to shift in bitset.first.

That said, the packed bitset is a downside in cognitive complexity, as
we have to think about two different possible representations. This
doesn't leak out of the API, but we do need to intrinsify bitset to
switch to a compatible implementation.

The compiler's intrinsics don't support intrinsifying methods, so the
implementations move to free functions.

This makes operations between 0-3% faster on my machine. e.g.,

MapGetHit/impl=runtimeMap/t=Int64/len=6-12                      12.34n ±  1%   11.42n ± 1%   -7.46% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=12-12                     15.14n ±  2%   14.88n ± 1%   -1.72% (p=0.009 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=18-12                     15.04n ±  6%   14.66n ± 2%   -2.53% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=24-12                     15.80n ±  1%   15.48n ± 3%        ~ (p=0.444 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=30-12                     15.55n ±  4%   14.77n ± 3%   -5.02% (p=0.004 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=64-12                     15.26n ±  1%   15.05n ± 1%        ~ (p=0.055 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=128-12                    15.34n ±  1%   15.02n ± 2%   -2.09% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=256-12                    15.42n ±  1%   15.15n ± 1%   -1.75% (p=0.001 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=512-12                    15.48n ±  1%   15.18n ± 1%   -1.94% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=1024-12                   17.38n ±  1%   17.05n ± 1%   -1.90% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=2048-12                   17.96n ±  0%   17.59n ± 1%   -2.06% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=4096-12                   18.36n ±  1%   18.18n ± 1%   -0.98% (p=0.013 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=8192-12                   18.75n ±  0%   18.31n ± 1%   -2.35% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=65536-12                  26.25n ±  0%   25.95n ± 1%   -1.14% (p=0.000 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=262144-12                 44.24n ±  1%   44.06n ± 1%        ~ (p=0.181 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=1048576-12                85.02n ±  0%   85.35n ± 0%   +0.39% (p=0.032 n=25)
MapGetHit/impl=runtimeMap/t=Int64/len=4194304-12                98.87n ±  1%   98.85n ± 1%        ~ (p=0.799 n=25)

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-amd64-goamd64v3
Change-Id: Ic1b852f02744404122cb3672900fd95f4625905e
Reviewed-on: https://go-review.googlesource.com/c/go/+/626277
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-11-20 22:41:14 +00:00
Ian Lance Taylor
b8ba5b440b cmd/cgo: improve error message for unknown name
Fixes #70472

Change-Id: Ib50d1dd5a648afc199ed62a507d54d0b0ccb1da2
Reviewed-on: https://go-review.googlesource.com/c/go/+/630375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2024-11-20 22:16:58 +00:00
Robert Griesemer
ae9938fae2 doc: document new restriction on cgo-generated method receicer types
Follow-up on CL 629715.

For #60725.

Change-Id: I1b980ad44f73550b633c74fc881c70255e7d8565
Reviewed-on: https://go-review.googlesource.com/c/go/+/630335
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2024-11-20 21:44:47 +00:00
Michael Pratt
cf5ec0720f cmd/compile: remove types.Compare map bucket special cases
runtime.hmap never directly refers to the bucket type (it uses an
unsafe.Pointer), thus it shouldn't be possible to have infinite
recursion here.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race,gotip-linux-amd64-longtest-aliastypeparams
Change-Id: I457885e48bbc352acedae1c0c389078f39ed9d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/619037
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-11-20 21:41:14 +00:00
Russ Cox
a947912d8a internal/byteorder: use canonical Go casing in names
If Be and Le stand for big-endian and little-endian,
then they should be BE and LE.

Change-Id: I723e3962b8918da84791783d3c547638f1c9e8a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/627376
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 20:59:28 +00:00
Michael Matloob
2e07ff3543 cmd/go: remove base.ShortPathConservative
This CL first removes the base.ShortPathConservative function. It had
two classes of uses. The first was in opening files where the paths end
up in error messages. In all those cases, the non-shortened paths are
used to open the files, and ShortPath is only used for the error
messages. The second is in base.RelPaths. RelPaths will now call
ShortPath for each of the paths passed in instead of calling
RelConservative and then doing the same check as ShortPath to see if the
path is shorter.

To avoid the possibility of incorrect relative paths ending up in error
messages (that might have command lines suggested for users to run), and
to avoid the possibility of incorrect relative paths appearing in the
output of base.RelPaths, base.ShortPaths always does an os.SameFile
check to make sure that the relative path its providing is actually
correct. Since this makes ShortPath slower than just manipulating paths
(because we need to stat the files), we need to be continue to enforce
that ShortPath is only called for error messages (with the exception of
base.RelPaths and its callers).

This is a simpler way of solving the problem that base.ShortPaths
intended to solve.

For #68383

Change-Id: I474f464f51a9acb2250069dea3054b55d95a4ab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/630276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-11-20 20:58:09 +00:00
Russ Cox
5242bfa26a cmd/go: remove temporary crypto/internal/fips140 import relaxation
Now that crypto/internal/fips140deps has been checked in,
we can enforce the full restrictions in the go command:
crypto/internal/fips can only import crypto/internal, not internal/...

Change-Id: I035470dbd478a5997c37ffabd268117969ed00a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/630135
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-11-20 20:56:02 +00:00
Russ Cox
4a3cef2036 all: rename crypto/internal/fips to crypto/internal/fips140
Sometimes we've used the 140 suffix (GOFIPS140, crypto/fips140)
and sometimes not (crypto/internal/fips, cmd/go/internal/fips).
Use it always, to avoid having to remember which is which.

Also, there are other FIPS standards, like AES (FIPS 197), SHA-2 (FIPS 180),
and so on, which have nothing to do with FIPS 140. Best to be clear.

For #70123.

Change-Id: I33b29dabd9e8b2703d2af25e428f88bc81c7c307
Reviewed-on: https://go-review.googlesource.com/c/go/+/630115
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-11-20 20:28:34 +00:00
qmuntal
5254e98942 cmd/cgo/internal/testsanitizers: fix TSAN tests using setarch
Some systems don't have permissions to run setarch, for example
when running in a docker container without the --privileged flag.

This change makes the tests skip the setarch command if it fails.

Fixes #70463

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15
Change-Id: I02fbd423ba809f5229b8639c9abe6fd275f32558
Reviewed-on: https://go-review.googlesource.com/c/go/+/630096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-20 20:11:21 +00:00
Robert Griesemer
2ad53d5a19 go/types, types2: disallow new methods on (aliases to) cgo-generated types
This makes methods on aliases of cgo-generated types a new compiler error.
That is ok because cgo-behavior is not covered by the G1 compatibility
guarantee.

Background: In 2023 we fixed a gopls issue related to this by actually
enabling methods on cgo-generated types in the first place (#59944).
See the discussion in #60725 and this CL for why we believe it is ok
to make this an error now.

Based on a variation of CL 503596 (by Xie Cui).

Fixes #60725.
For #59944.

Change-Id: I7e9e6e1a76447167483a282b268f5183214027c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/629715
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: 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>
2024-11-20 20:05:29 +00:00
Robert Griesemer
91af7119cd go/types, types2: disallow new methods on generic alias and instantiated types
If the receiver is an alias declaring type parameters, report
an error and ensure that the receiver type remains invalid.
Collect type parameters etc. as before but do not attempt to
find their constraints or instantiate the receiver type.
The constraints of the type parameters will be invalid by
default. The receiver type will not be (lazily) instantiated
which causes problems with existing invariants.

If a receiver denotes an instantiated (alias or defined) type,
report an error and ensure that the receiver type remains invalid.

While at it, add more comments and bring go/types and types2
closer together where there were differences.

Fixes #70417.

Change-Id: I87ef0b42d2f70464664cacc410f4b7eb1c994241
Reviewed-on: https://go-review.googlesource.com/c/go/+/629080
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 20:03:55 +00:00
Michael Anthony Knyszek
d69e6f63c3 runtime: keep cleanup closure alive across adding the cleanup special
This is similar to the weak handle bug in #70455. In short, there's a
window where a heap-allocated value is only visible through a special
that has not been made visible to the GC yet.

For #70455.

Change-Id: Ic2bb2c60d422a5bc5dab8d971cfc26ff6d7622bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/630277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-11-20 19:50:09 +00:00
Michael Anthony Knyszek
88cfad0c89 runtime: explicitly keep handle alive during getOrAddWeakHandle
getOrAddWeakHandle is very careful about keeping its input alive across
the operation, but not very careful about keeping the heap-allocated
handle it creates alive. In fact, there's a window in this function
where it is *only* visible via the special. Specifically, the window of
time between when the handle is stored in the special and when the
special actually becomes visible to the GC.

(If we fail to add the special because it already exists, that case is
fine. We don't even use the same handle value, but the one we obtain
from the attached GC-visible special, *and* we return that value, so it
remains live.)

Fixes #70455.

Change-Id: Iadaff0cfb93bcaf61ba2b05be7fa0519c481de82
Reviewed-on: https://go-review.googlesource.com/c/go/+/630315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-11-20 19:46:18 +00:00
Robert Griesemer
e0b569842d spec: document restrictions for method receivers that are aliases
For #70417.

Change-Id: I5e6b3011f356c7ecd8f64f5dcf0a6a77dcb21bbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/629577
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-11-20 19:43:54 +00:00
Roland Shoemaker
e36b4d76ad doc/godebug: document we removed x509sha1
Change-Id: I4a4ff0b9e0d3584b96e414d60b889d68fa8660c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/630236
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-11-20 19:29:11 +00:00
Filippo Valsorda
dc28aca568 crypto/ed25519: fix GenerateKey with rand nil
GenerateKey(nil) is documented to use crypto/rand.Reader, but we didn't
have a test.

While at it, since it's documented to be equivalent to NewKeyFromSeed,
actually implement it that way. This has the probably good side effect
of making it deterministic in FIPS mode. The other GenerateKey use
MaybeReadByte, so can change, but this one is probably worth keeping
deterministic. It's just slightly less compliant, but ok as long as
crypto/rand.Reader is the default one.

Intentionally leaving crypto/internal/fips/ed25519.GenerateKey in, in
case we need to switch to it during the life of the module.

Change-Id: Ic203436ff452bb9740291b9ca17f85aa6ae20b6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/630099
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 19:04:33 +00:00
Brian Gabin
e1dc707f33 cmd/go/testdata/script: restrict test to check only exe name
Avoid test failures caused by 'v2' in user environment paths.
Modify the test to check only the output executable name and ensure it is not 'v2', rather than inspecting the entire path.

Fixes #67989

Change-Id: Ida2131f6c9b41724df1b6b5e31413252c5009d25
Reviewed-on: https://go-review.googlesource.com/c/go/+/621315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-11-20 18:45:12 +00:00
Roland Shoemaker
7c7170e939 crypto/x509: remove x509sha1 GODEBUG
Fixes #41682

Change-Id: I37760f2186e75ec7df9674db25ae466cf453d66d
Reviewed-on: https://go-review.googlesource.com/c/go/+/629676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 18:27:31 +00:00
Roland Shoemaker
c901d93fcd cmd/go: enforce -Wl,--push-state logic only when it is a prefix
Make sure we only run the --push-state logic when -Wl,--push-state is a
prefix of the argument, not just present in the argument string.

Thanks to Juho Forsén of Mattermost for reporting this issue.

Change-Id: I799f7854ff680674fd84cf2136fadf70817fc7e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/628415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-20 18:26:43 +00:00
Russ Cox
30b09bccfd crypto/internal/fipstest: fix TestACVP not to write to module cache
Not sure how this ever worked; the module cache is read-only.

Change-Id: I22e4945fa0bac101995ab9101d22dcfdcee40776
Reviewed-on: https://go-review.googlesource.com/c/go/+/629976
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 18:12:28 +00:00
Conrad Irwin
5165f54167 cmd/go: add support for mod tools
Running `go tool` with no arguments will now list built in tools
followed by module defined tools.

Running `go tool X` where X matches either the full package path,
or the last segment of the package path, of a defined tool will
build the tool to a known location and immediately execute it.

For golang/go#48429

Change-Id: I02249df8dad12fb74aa244002f82a81af20e732f
Reviewed-on: https://go-review.googlesource.com/c/go/+/534817
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 17:58:35 +00:00
Filippo Valsorda
297081eb02 crypto/internal/fips/rsa: support all SHA hashes in PKCS#1 v1.5
The byte sequences match those in
https://github.com/randombit/botan/blob/e5ec40828/src/lib/pk_pad/hash_id/hash_id.cpp

For #69536
Fixes #43923

Change-Id: I8b4daea71c2f696ad67ddc13affefd1563c51266
Reviewed-on: https://go-review.googlesource.com/c/go/+/630095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 17:52:09 +00:00
Filippo Valsorda
c483fdbfcf crypto/ed25519: fix TestAllocations in FIPS mode
Change-Id: Ic36e95dba29d43e73ddf105d538c4795bc4ce557
Reviewed-on: https://go-review.googlesource.com/c/go/+/630097
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 16:57:48 +00:00
Filippo Valsorda
93fcd8fb18 crypto/rsa: move implementation to crypto/internal/fips/rsa
Key generation is still missing and will come in a follow-up CL.

For #69536

Change-Id: Ia17754fe31a39a48710673b51e30ca3125b19a20
Reviewed-on: https://go-review.googlesource.com/c/go/+/629937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 16:57:14 +00:00
Filippo Valsorda
8837503237 crypto/rsa: move RSAES-OAEP to the same file as RSASSA-PSS
They are both from PKCS#1 v2.2, so it makes sense to keep them in the
same file, and to only have common RSA stuff in rsa.go.

This should make it easier to follow the changes in the following CLs.

Change-Id: I1982e679f54eefa9babb5eeea34fa23792cf340a
Reviewed-on: https://go-review.googlesource.com/c/go/+/629936
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 16:48:09 +00:00
Damien Neil
2c02b4a252 runtime: remove unused casgcopystack function
Change-Id: I349b24ba5259d7abb0ae37065f704517aa4decda
Reviewed-on: https://go-review.googlesource.com/c/go/+/630155
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 16:47:29 +00:00
Damien Neil
1d28fa8c43 runtime: avoid deadlock in synctest changegstatus when copying stacks
For #67434
Fixes #70452

Change-Id: Ie655a9e55837aa68b6bfb0bb69b6c8caaf3bbea5
Reviewed-on: https://go-review.googlesource.com/c/go/+/629856
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-11-20 16:45:48 +00:00
Joel Sing
b483f382a2 crypto/subtle: unbreak DIT test on openbsd/arm64
OpenBSD already enables DIT on arm64 in both kernel and userland.
As such, if DIT is already enabled, do not expect that it can be
disabled.

Change-Id: If7aae2ace40d97109beefa71c03e0c138a0995ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/629995
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-11-20 16:31:41 +00:00
Keith Randall
98e719f677 cmd/compile: let MADD/MSUB combination happen more often on arm64
We have a single-instruction x+y*z op. Unfortunately x can't be
a constant, so the rule that builds them doesn't apply in that case.

This CL handles x+(c+y*z) by reordering to c+(x+y*z) so x is
in the right place.

Change-Id: Ibed621607d49da70474128e20991e0c4630ebfad
Reviewed-on: https://go-review.googlesource.com/c/go/+/629858
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-11-20 16:30:01 +00:00
Keith Randall
7d2e3da243 cmd/compile: remove redundant nil checks
Optimize them away if we can.

If not, be more careful about splicing them out after scheduling.

Change-Id: I660e54649d753dc456d2e25d389d375a16d76940
Reviewed-on: https://go-review.googlesource.com/c/go/+/627418
Reviewed-by: Shengwei Zhao <wingrez@126.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 16:28:52 +00:00
Damien Neil
76e4efdc77 testing/synctest: add experimental synctest package
The testing/synctest package is experimental,
subject to change or removal,
and only present when GOEXPERIMENT=synctest.

Fixes #69687

Change-Id: I6c79e7d1479a54bebcd2de754854c87bfd0a5fa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/629735
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20 16:26:46 +00:00
Russ Cox
a7043ec95b syscall: do not run TestSyscallAllocations in parallel with other tests
Fixes #70327.

Change-Id: I27ee0d1fbae73fb5c22aa699f4e3110c67bc9ea2
Reviewed-on: https://go-review.googlesource.com/c/go/+/630136
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2024-11-20 16:16:51 +00:00
Russ Cox
0d397d85ea lib/fips140: add directory and test
This directory will hold the fips140 snapshots.
Add a README, helpful Makefile, and a test that
the checksums are correct (once we have zip files).

Change-Id: I735540ad1ce7da9a24c3a0b57b054c8340708da1
Reviewed-on: https://go-review.googlesource.com/c/go/+/629955
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-11-20 16:09:03 +00:00
thepudds
a311754d54 cmd/internal/testdir: print stderr if go list fails while gathering stdlib import config
If cmd/compile is in an unhappy state, the testdir test can
fail with an unhelpful 'exit code 1' log message if
'go list' fails while gathering stdlib import config
When running individual files, such as:

 go test cmd/internal/testdir -run='Test/escape.*.go'

This might also happen in other uses, or it might be
that a more expansive set of tests such as run.bash
might first trigger a more useful error.

This change prints stderr and states that it is 'go list'
that is having problems to help someone track down the
proper issue.

Change-Id: Iba658ea139bb9087ab8adb00c9f65080a1b6ee76
Reviewed-on: https://go-review.googlesource.com/c/go/+/524941
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 13:07:35 +00:00
thepudds
5d2cc56620 cmd/internal/testdir: update errors when filepaths include 'C:\'
Currently on Windows, commands like:

 go test cmd/internal/testdir -run=foo -update_errors

will fail to update the errors because the parsing is
currently confused by the ':' in filepaths that
start with 'C:\', and wrongly thinks that ':' marks
the end of the Go filename.

Instead of finding the first ':', use a regexp
to find what looks to be the end of the Go filename.

Change-Id: I091106da55b8e9e9cf421814abf26a6f8b821af9
Reviewed-on: https://go-review.googlesource.com/c/go/+/524942
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-20 13:07:03 +00:00
Russ Cox
5e1726b71a cmd/go: add GOFIPS140 to 'go help environment'
Also re-sort the various lists. (All lists should be sorted.)
The linked page https://go.dev/security/fips140 has yet
to be written, but soon.

For #70123.

Change-Id: Ica5bbf5bd29e9136c2a49d3099d6e0e018c36145
Reviewed-on: https://go-review.googlesource.com/c/go/+/629816
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-20 12:50:40 +00:00