]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
15 months agocmd/go, go/build: parse directives in file headers
Russ Cox [Tue, 29 Nov 2022 18:30:50 +0000 (13:30 -0500)]
cmd/go, go/build: parse directives in file headers

For #56986, go/build needs to report up to cmd/go
about //go:debug lines found in the source code.
Rather than make a special case for //go:debug,
this change gathers all top-level directives above the
package line and includes them in the result.

The go command's module index must match go/build,
so this CL contains the code to update the index as well.

A future CL will use the //go:debug lines to prepare the default
GODEBUG settings, as well as rejecting such lines in non-main
packages.

Change-Id: I66ab8dc72f9cd65c503b10b744367caca233f8a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/453603
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/internal/obj/arm64: use more appropriate types for olsr12u
Joel Sing [Sun, 8 Jan 2023 18:22:20 +0000 (05:22 +1100)]
cmd/internal/obj/arm64: use more appropriate types for olsr12u

This allows for a large number of casts to be removed at call sites.

Change-Id: Id929f6c7155b0b59a2bcdf43144de95a007b8a48
Reviewed-on: https://go-review.googlesource.com/c/go/+/461139
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Eric Fang <eric.fang@arm.com>
15 months agocmd/internal/obj/arm64: invert SP check
Joel Sing [Sat, 7 Jan 2023 15:03:30 +0000 (02:03 +1100)]
cmd/internal/obj/arm64: invert SP check

Check for REGSP use before checking for invalid instructions. This simplifies
the code and avoids duplicated op generation.

Change-Id: I302e3b54a29742f2c48024b25162200f5966cfaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/461138
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/internal/obj/arm64: use obj.REG_NONE where appropriate
Joel Sing [Sat, 7 Jan 2023 07:40:56 +0000 (18:40 +1100)]
cmd/internal/obj/arm64: use obj.REG_NONE where appropriate

When referring to an unspecified register, use obj.REG_NONE rather than 0.
This has the same result but is more readable.

Change-Id: I56b541a3abc3c2c0e3ce1de21a624da0b21c485a
Reviewed-on: https://go-review.googlesource.com/c/go/+/461137
Reviewed-by: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/internal/obj/arm64: remove bogus omovlit return value check
Joel Sing [Sat, 7 Jan 2023 07:36:38 +0000 (18:36 +1100)]
cmd/internal/obj/arm64: remove bogus omovlit return value check

omovlit never returns zero, so it does not make any sense to check for that.
Additionally, no other call site does this.

Change-Id: I5769dcdb557bed4ec4d727abe0869a1549fcf04c
Reviewed-on: https://go-review.googlesource.com/c/go/+/461136
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/internal/obj/arm64: remove spurious assignments with OR
Joel Sing [Sun, 8 Jan 2023 17:31:47 +0000 (04:31 +1100)]
cmd/internal/obj/arm64: remove spurious assignments with OR

Use = rather than |= when assigning to an op variable.

Change-Id: I142c9fb3aa6f4b48875710100c05ab640e21933a
Reviewed-on: https://go-review.googlesource.com/c/go/+/461135
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agodebug/macho: don't crash if dynamic symtab with no symtab
Ian Lance Taylor [Wed, 22 Feb 2023 21:00:14 +0000 (13:00 -0800)]
debug/macho: don't crash if dynamic symtab with no symtab

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58642

Change-Id: I19fee0dc9bd6239b520c15182b8f1e57bb0049bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/470397
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/link: default to external linking with cgo std packages
Cherry Mui [Tue, 21 Feb 2023 22:34:41 +0000 (17:34 -0500)]
cmd/link: default to external linking with cgo std packages

Previously, when a program depends on cgo packages in the standard
library (e.g. net, os/user) but not otherwise use cgo, we default
to internal linking mode. As we shipped pre-built cgo-using packages
in Go distributions, we don't require a C compiler to build those
packages. Then, by using internal linking we can link programs
using those packages without requiring a C toolchain.

As of Go 1.20, we stopped shipping those pre-built packages. If a
user doesn't have a C toolchain, they will use the non-cgo version
of the package. If they have a C toolchain, they can get cgo-using
packages but they can link with the external linker as well. So
there is no strong need to be able to link the cgo version of the
packages without a C toolchain. This CL makes it default to
external linking mode.

Fixes #58619.
Fixes #58620.

Change-Id: I62d3744c2b82ce734813c0e303e417d85dd29868
Reviewed-on: https://go-review.googlesource.com/c/go/+/470298
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agoruntime: use explicit NOFRAME on linux/amd64
qmuntal [Wed, 8 Feb 2023 08:40:44 +0000 (09:40 +0100)]
runtime: use explicit NOFRAME on linux/amd64

This CL marks some linux assembly functions as NOFRAME to avoid relying
on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Updates #58378

Change-Id: I7792cff4f6e539bfa56c02868f2965088ca1975a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466316
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet/http: remove warning when parsing a query containing a semicolon
Damien Neil [Wed, 22 Feb 2023 16:42:37 +0000 (08:42 -0800)]
net/http: remove warning when parsing a query containing a semicolon

It's been years since the behavior here was changed, and there's
little point in continuing to warn users of it.

Fixes #49399

Change-Id: I95f64ca14cacb64ebe78296593b1cc3d837e6b77
Reviewed-on: https://go-review.googlesource.com/c/go/+/470315
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agocmd/link: make Exitf panic under -h
Cherry Mui [Wed, 22 Feb 2023 17:09:56 +0000 (12:09 -0500)]
cmd/link: make Exitf panic under -h

If the -h flag is specified, currently it makes Errorf panic, but
not Exitf. Do so for Exitf as well.

Change-Id: I3e8d8899fd439f7299be3f9e9a63993b04852a93
Reviewed-on: https://go-review.googlesource.com/c/go/+/470297
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agosyscall: add jail support to ForkExec on FreeBSD
Harald Böhm [Sun, 27 Nov 2022 14:34:28 +0000 (15:34 +0100)]
syscall: add jail support to ForkExec on FreeBSD

Introduce a new SysProcAttr member called Jail on FreeBSD. This allows
supplying an existing jail's ID to which the child process is attached
before calling the exec system call.

Fixes #46259

Change-Id: Ie282e5b83429131f9a9e1e27cfcb3bcc995d1d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458335
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Samuel Karp <samuelkarp@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

15 months agoruntime: improve memclr on ppc64x/power10
Archana R [Mon, 13 Feb 2023 12:18:59 +0000 (06:18 -0600)]
runtime: improve memclr on ppc64x/power10

Rewrite memclr asm function to use the new power10 instruction stxvl
or the store vector with length which can specify the number of bytes
to be stored in a register, thereby avoiding loops to store the tail
end bytes.
On power9 and power8 the code remains unchanged.
The performance for all sizes<16 improve on power10 with this change.

name          old time/op    new time/op     delta
Memclr/1        2.59ns ± 1%     2.80ns ± 9%      ~
Memclr/2        2.77ns ± 0%     2.90ns ± 8%      ~
Memclr/3        3.70ns ± 1%     3.00ns ± 1%   -19.02%
Memclr/4        4.56ns ± 5%     2.98ns ± 1%   -34.56%
Memclr/5        10.1ns ± 8%      2.9ns ± 4%   -70.82%
Memclr/6        6.99ns ± 4%     2.84ns ± 9%   -59.40%
Memclr/7        8.66ns ± 5%     2.92ns ± 4%   -66.27%
Memclr/8        2.75ns ± 1%     2.75ns ± 0%      ~
Memclr/9        3.43ns ± 1%     2.75ns ± 0%   -19.78%
Memclr/10       3.30ns ± 0%     2.77ns ± 0%   -15.81%
Memclr/12       5.09ns ± 0%     2.78ns ± 0%   -45.49%
Memclr/15       9.79ns ± 0%     2.78ns ± 0%   -71.64%
Memclr/16       2.65ns ± 1%     2.77ns ± 0%    +4.77%
GoMemclr/1      2.46ns ± 3%     2.46ns ± 3%      ~
GoMemclr/2      2.91ns ± 0%     2.46ns ± 1%   -15.38%
GoMemclr/3      4.85ns ± 6%     2.45ns ± 1%   -49.50%
GoMemclr/4      5.44ns ± 5%     2.47ns ± 1%   -54.63%
GoMemclr/5      6.48ns ± 0%     2.45ns ± 1%   -62.20%
GoMemclr/6      9.33ns ±20%     2.45ns ± 1%   -73.76%
GoMemclr/7      8.79ns ± 2%     2.46ns ± 1%   -72.03%
GoMemclr/8      2.91ns ± 0%     2.84ns ± 0%    -2.35%
GoMemclr/9      5.04ns ± 0%     2.84ns ± 0%   -43.67%
GoMemclr/10     5.17ns ± 1%     2.84ns ± 0%   -44.99%
GoMemclr/12     6.22ns ± 0%     2.84ns ± 0%   -54.41%
GoMemclr/15     10.1ns ± 0%      2.8ns ± 0%   -72.04%
GoMemclr/16     2.90ns ± 0%     2.92ns ± 0%    +0.83%

Change-Id: I2b7e1a9ceafba11c57c04a2e8cbd12b5ac87ec9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/467635
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>

15 months agodoc: start draft Go 1.21 release notes
Than McIntosh [Wed, 22 Feb 2023 18:17:30 +0000 (13:17 -0500)]
doc: start draft Go 1.21 release notes

This initial release notes template is based on previous releases.

For #58645.

Change-Id: I8bae25d6dd9778a69963b8b4903a6dc1c180e15f
Reviewed-on: https://go-review.googlesource.com/c/go/+/470296
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoRevert "internal/poll: drop redundant ENOSYS in CopyFileRange"
Ian Lance Taylor [Tue, 21 Feb 2023 23:00:01 +0000 (23:00 +0000)]
Revert "internal/poll: drop redundant ENOSYS in CopyFileRange"

This reverts CL 428555.

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

Fixes #58592

Change-Id: Ib8dd1be61544f54bf652a99dc0b449109f8f50ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/470016
Reviewed-by: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
15 months agotesting: add -fullpath to go test
Hossein Zolfi [Fri, 27 Jan 2023 14:50:09 +0000 (18:20 +0330)]
testing: add -fullpath to go test

When -test.fullpath flag is provided to go test,
go test displays the full file names in error messages.

Fixes #37708

Change-Id: I6096e75ed816fd42205810f20624e495047a73a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/463837
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

15 months agocmd/go: return an early error from queryImport when in vendor mode
rohnnyjoy [Sat, 18 Feb 2023 04:37:17 +0000 (04:37 +0000)]
cmd/go: return an early error from queryImport when in vendor mode

The current behavior for -mod=vendor is to let QueryPackages run and
fail from queryImport: "cannot query module due to -mod=vendor".
This has the side effect of allowing "go: finding module for package"
to be printed to stderr. Instead of this, return an error before
running QueryPackages.

Fixes #58417

Change-Id: Idc0ed33d1dd1bd185348da3a18ba8eb2dd225909
GitHub-Last-Rev: dd09deec0afecabd1bffc34cfe66db0a8c124fd9
GitHub-Pull-Request: golang/go#58471
Reviewed-on: https://go-review.googlesource.com/c/go/+/467517
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/link: add internal linking support for calling SDYNIMPORT on mips64
Joel Sing [Mon, 6 Jun 2022 20:08:51 +0000 (06:08 +1000)]
cmd/link: add internal linking support for calling SDYNIMPORT on mips64

Add internal linking support for calling SDYNIMPORT symbols on mips64. This adds
code to generate appropriate PLT and GOT entries, along with the various dynamic
entries needed for the dynamic loader.

Updates #36435, #46178

Change-Id: I783e0d028510ca2bca82bcbc745f2375770813fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/415815
Reviewed-by: Rong Zhang <rongrong@oss.cipunited.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agogo/types, types2: point out type parameters with predeclared names in errors
Robert Griesemer [Tue, 21 Feb 2023 22:42:18 +0000 (14:42 -0800)]
go/types, types2: point out type parameters with predeclared names in errors

If a type parameter has the same name as a predeclared type, error
messages can be very confusing. In these rare cases, explicitly
point out where the type parameter is declared (types2) or that it
is a type parameter (go/types).

(We can't point out where the type parameter is declared in go/types
because we don't have access to the file set in the type writer at
the moment.)

Fixes #58611.

Change-Id: I5c150c2b0afae5fad320821e7e5935090dc2ef4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/470075
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: avoid unused variable error in invalid x.(type) expression
Robert Griesemer [Tue, 21 Feb 2023 20:51:34 +0000 (12:51 -0800)]
go/types, types2: avoid unused variable error in invalid x.(type) expression

This change removes one of the two follow-on errors in the issue below.

For #58612.

Change-Id: If1eec5031e524bad33caa4a914f52e6a1e273b60
Reviewed-on: https://go-review.googlesource.com/c/go/+/470015
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agosyscall: introduce IoctlPtr for exec_unix tests
Dmitri Goutnik [Mon, 20 Feb 2023 11:55:42 +0000 (06:55 -0500)]
syscall: introduce IoctlPtr for exec_unix tests

Avoid passing Go pointers as uintptr in exec_unix_test.go by introducing
syscall.IoctlPtr() which accepts arg as unsafe.Pointer.

For #44834
Fixes #58609

Change-Id: I6d0ded023e5f3c9989783aee7075bb88100d9ec2
Reviewed-on: https://go-review.googlesource.com/c/go/+/469675
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agodebug/macho: use saferio to read symbol table strings
Ian Lance Taylor [Tue, 21 Feb 2023 18:14:20 +0000 (10:14 -0800)]
debug/macho: use saferio to read symbol table strings

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58603

Change-Id: I67fc45365c1a5b0b4b381f541bf2fee8ce8ddc3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/469895
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

15 months agoos: use testenv.Command instead of exec.Command in tests
cui fliter [Fri, 18 Nov 2022 06:06:56 +0000 (14:06 +0800)]
os: use testenv.Command instead of exec.Command in tests

testenv.Command sets a default timeout based on the test's deadline
and sends SIGQUIT (where supported) in case of a hang.

Change-Id: I84d469d12ca1f39175b713ca41e7cd2202d11d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/451895
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agopath/filepath: document that Clean does not change Windows volume names
Damien Neil [Tue, 21 Feb 2023 19:46:39 +0000 (11:46 -0800)]
path/filepath: document that Clean does not change Windows volume names

Fixes #58348

Change-Id: I4aac0285f11618a45aca6b13c2da2a10a803a9b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/469955
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

15 months agocmd/internal/obj/riscv: optimize loading large immediate with trailing zeros
Wayne Zuo [Tue, 8 Nov 2022 07:39:27 +0000 (15:39 +0800)]
cmd/internal/obj/riscv: optimize loading large immediate with trailing zeros

This CL can avoid a memory load for some immediate.
Reduce binary size slightly.

compilecmp HEAD~1 -> HEAD
HEAD~1 (9860faa512): math/big: remove underscores from Binomial docs
HEAD (ac85312f10): cmd/internal/obj/riscv: optimize loading large immediate with many trailing zeros
platform: linux/riscv64

file      before    after     Δ       %
addr2line 3892904   3889844   -3060   -0.079%
api       5558527   5555073   -3454   -0.062%
asm       5191725   5187853   -3872   -0.075%
buildid   2631958   2629356   -2602   -0.099%
cgo       4722642   4718516   -4126   -0.087%
compile   25579930  25564496  -15434  -0.060%
cover     4989560   4985580   -3980   -0.080%
dist      3538991   3536299   -2692   -0.076%
doc       3990845   3987605   -3240   -0.081%
fix       3410945   3407097   -3848   -0.113%
link      6701702   6697926   -3776   -0.056%
nm        3802030   3798664   -3366   -0.089%
objdump   4211373   4207651   -3722   -0.088%
pack      2423248   2421048   -2200   -0.091%
pprof     14302052  14296714  -5338   -0.037%
test2json 2724359   2721881   -2478   -0.091%
trace     13598607  13590879  -7728   -0.057%
vet       7612108   7607722   -4386   -0.058%
go        15092773  15087323  -5450   -0.036%
total     133976279 133891527 -84752  -0.063%

Change-Id: I8615c7830ebfee0386f95d0c0fc4d29dc0b4c7fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/448635
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
15 months agoruntime: record parent goroutine ID, and print it in stack traces
Nick Ripley [Wed, 28 Sep 2022 18:44:56 +0000 (14:44 -0400)]
runtime: record parent goroutine ID, and print it in stack traces

Fixes #38651

Change-Id: Id46d684ee80e208c018791a06c26f304670ed159
Reviewed-on: https://go-review.googlesource.com/c/go/+/435337
Run-TryBot: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Ethan Reesor <ethan.reesor@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoRevert "hex: fix panic in Decode when len(src) > 2*len(dst)"
Joe Tsai [Wed, 8 Feb 2023 09:57:25 +0000 (01:57 -0800)]
Revert "hex: fix panic in Decode when len(src) > 2*len(dst)"

This reverts CL 461958 and CL 465855.

Reason for revert: This introduced an irreconcilable inconsistency with Encode

Fixes #58391.

Change-Id: Ifd01a04d433b24c092b73e627b8149a5851c2bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/469615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agostrconv: add Atoi test cases with characters less than '0'
Anuraag Agrawal [Mon, 20 Feb 2023 00:38:44 +0000 (00:38 +0000)]
strconv: add Atoi test cases with characters less than '0'

Change-Id: I35c0fe4e7e11b694ef07687d5e0532a2ab9ba213
GitHub-Last-Rev: e0a28f42367c2685d80bcc5c45294c0d2eae77fe
GitHub-Pull-Request: golang/go#58575
Reviewed-on: https://go-review.googlesource.com/c/go/+/469035
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
15 months agodoc: add clear builtin to spec
Cuong Manh Le [Mon, 13 Feb 2023 17:10:10 +0000 (00:10 +0700)]
doc: add clear builtin to spec

Fixes #56351

Change-Id: Ia87bf594553b7d0464b591106840f849571c5f39
Reviewed-on: https://go-review.googlesource.com/c/go/+/467755
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agodoc: do not use "==" in slice examples
Cuong Manh Le [Fri, 17 Feb 2023 02:20:30 +0000 (09:20 +0700)]
doc: do not use "==" in slice examples

There's no slice comparison in Go.

Change-Id: I5de1766c2adeb56ed12a577a4c46c12b2582b1c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/469015
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agoruntime/cgo: restore correct build tags for linux/mips*
Joel Sing [Fri, 17 Feb 2023 18:45:34 +0000 (05:45 +1100)]
runtime/cgo: restore correct build tags for linux/mips*

The linux build tags were incorrectly removed from these files by CL 460538.
Restore the correct build tags so that they are only included in builds
for linux/mips* platforms.

Change-Id: I21d8802b0252688d8e2228cf904b47d90b253485
Reviewed-on: https://go-review.googlesource.com/c/go/+/469175
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agonet/http: remove five second timeout from TestTransportClosesBodyOnError
Damien Neil [Thu, 26 Jan 2023 21:16:26 +0000 (13:16 -0800)]
net/http: remove five second timeout from TestTransportClosesBodyOnError

Wait forever and let the test time out with a stack trace if the
expected response doesn't happen.

Fixes #57990

Change-Id: I835def63db113752cdd06e03e258cb10d63a6a25
Reviewed-on: https://go-review.googlesource.com/c/go/+/463222
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/compile: move raw writes out of write barrier code
Keith Randall [Tue, 1 Nov 2022 21:18:09 +0000 (14:18 -0700)]
cmd/compile: move raw writes out of write barrier code

Previously, the write barrier calls themselves did the actual
writes to memory. Instead, move those writes out to a common location
that both the wb-enabled and wb-disabled code paths share.

This enables us to optimize the write barrier path without having
to worry about performing the actual writes.

Change-Id: Ia71ab651908ec124cc33141afb52e4ca19733ac6
Reviewed-on: https://go-review.googlesource.com/c/go/+/447780
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agoruntime: remove the restriction that write barrier ptrs come in pairs
Keith Randall [Wed, 26 Oct 2022 00:58:07 +0000 (17:58 -0700)]
runtime: remove the restriction that write barrier ptrs come in pairs

Future CLs will remove the invariant that pointers are always put in
the write barrier in pairs.

The behavior of the assembly code changes a bit, where instead of writing
the pointers unconditionally and then checking for overflow, check for
overflow first and then write the pointers.

Also changed the write barrier flush function to not take the src/dst
as arguments.

Change-Id: I2ef708038367b7b82ea67cbaf505a1d5904c775c
Reviewed-on: https://go-review.googlesource.com/c/go/+/447779
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>

15 months agocmd/api: add API checks for freebsd/riscv64
Dmitri Goutnik [Fri, 17 Feb 2023 16:44:16 +0000 (11:44 -0500)]
cmd/api: add API checks for freebsd/riscv64

The freebsd/riscv64 port was added in go1.20, make cmd/api aware of it and
backfill API files.

For #58582

Change-Id: I242b161cdb6221c8f60a1868c6435be26fca0078
Reviewed-on: https://go-review.googlesource.com/c/go/+/469135
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/cgo: include seed string with -frandom-seed for lto
Morten Linderud [Thu, 16 Feb 2023 14:37:50 +0000 (14:37 +0000)]
cmd/cgo: include seed string with -frandom-seed for lto

cgo is built with -flto the symbols in runtime/cgo is going to include random numbers which would make builds unreproducible.

Settings -frandom-seeds ensures this is consistent across builds, and to ensure we always use a reproducible seed across builds we use the actionID as the seed string.

runtime/cgo built with "-frandom-seed=OFEc9OKoUMJwh3-5yFCH" would output the following:

    $ strings --all --bytes=8 $WORK/b055/_pkg_.a | grep "gnu.lto_.profile"
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797
    .gnu.lto_.profile.8403a797

Change-Id: I3c2d261a94f23c8227a922da9a7f81660905fd71
GitHub-Last-Rev: cec5162316d33d8f652948706ce0a5f8c6794a6e
GitHub-Pull-Request: golang/go#58561
Reviewed-on: https://go-review.googlesource.com/c/go/+/468835
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agocmd/api: add API checks for freebsd/arm64
Dmitri Goutnik [Fri, 17 Feb 2023 16:19:49 +0000 (11:19 -0500)]
cmd/api: add API checks for freebsd/arm64

The freebsd/arm64 port was added in go1.14, make cmd/api aware of it and
backfill API files.

For #58582

Change-Id: I8b25c6cf5a66611d90d225762b257679a4abface
Reviewed-on: https://go-review.googlesource.com/c/go/+/469115
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agotest: add regress test for #58572
Matthew Dempsky [Thu, 16 Feb 2023 23:53:42 +0000 (15:53 -0800)]
test: add regress test for #58572

Fixes #58572.

Change-Id: I75fa432afefc3e036ed9a6a9002a29d7b23105ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/468880
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

15 months agoRevert "cmd/compile: use ONAME node directly from generated hash func"
Matthew Dempsky [Thu, 16 Feb 2023 23:54:25 +0000 (15:54 -0800)]
Revert "cmd/compile: use ONAME node directly from generated hash func"

This reverts commit 25f5d9d4a253cb880bff909ebbdc05c8941c4a48.

Causes ICE on valid code.

Updates #58572.

Change-Id: Ib276c87d9b0362bbd2a760ac2a242f82d4e20400
Reviewed-on: https://go-review.googlesource.com/c/go/+/468879
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: ensure constant folding of pointer arithmetic remains a pointer
Keith Randall [Wed, 15 Feb 2023 18:21:52 +0000 (10:21 -0800)]
cmd/compile: ensure constant folding of pointer arithmetic remains a pointer

For c + nil, we want the result to still be of pointer type.

Fixes ppc64le build failure with CL 468455, in issue33724.go.

The problem in that test is that it requires a nil check to be
scheduled before the corresponding load. This normally happens fine
because we prioritize nil checks. If we have nilcheck(p) and load(p),
once p is scheduled the nil check will always go before the load.

The issue we saw in 33724 is that when p is a nil pointer, we ended up
with two different p's, an int64(0) as the argument to the nil check
and an (*Outer)(0) as the argument to the load. Those two zeroes don't
get CSEd, so if the (*Outer)(0) happens to get scheduled first, the
load can end up before the nilcheck.

Fix this by always having constant arithmetic preserve the pointerness
of the value, so that both zeroes are of type *Outer and get CSEd.

Update #58482
Update #33724

Change-Id: Ib9b8c0446f1690b574e0f3c0afb9934efbaf3513
Reviewed-on: https://go-review.googlesource.com/c/go/+/468615
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>

15 months agosyscall: Faccessat: check for CAP_DAC_OVERRIDE on Linux
Kir Kolyshkin [Thu, 16 Feb 2023 00:47:40 +0000 (16:47 -0800)]
syscall: Faccessat: check for CAP_DAC_OVERRIDE on Linux

CL 416115 added using faccessat2(2) from syscall.Faccessat on Linux
(which is the only true way to implement AT_EACCESS flag handing),
if available. If not available, it uses some heuristics to mimic the
kernel behavior, mostly taken from glibc (see CL 126415).

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

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

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

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

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

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

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

Fixes #58552.

Change-Id: I82a7e757ab3fd3d0193690a65c3b48fee46ff067
Reviewed-on: https://go-review.googlesource.com/c/go/+/468735
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/link: don't switch to gold on ARM Linux
Ian Lance Taylor [Wed, 15 Feb 2023 22:05:22 +0000 (14:05 -0800)]
cmd/link: don't switch to gold on ARM Linux

The bug in GNU ld appears to have been fixed in GNU binutils 2.28 by
GNU binutils revision 5522f910cb539905d6adfdceab208ddfa5e84557.
(This may have been accidental as the ChangeLog for the fix makes
no reference to it; the fix is from
https://sourceware.org/bugzilla/show_bug.cgi?id=19962).

Continue using gold on arm64, at least for now, because as reported in
issue #22040 GNU ld still fails there.

For #15696
For #22040

Change-Id: I5534bb8b5680daf536a7941aba5c701e8a4138ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/468655
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

15 months agosrc: rename unexported errors by adding prefix err
Oleksandr Redko [Sun, 12 Feb 2023 13:37:00 +0000 (15:37 +0200)]
src: rename unexported errors by adding prefix err

By convention, use `err` as prefix for variables of type `error`.

Change-Id: I9401d5d47e994a27be245b2c8b1edd55cdd52db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/467536
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agodoc: add missing builtin functions not permitted in statement context
Cuong Manh Le [Mon, 13 Feb 2023 17:15:43 +0000 (00:15 +0700)]
doc: add missing builtin functions not permitted in statement context

The typechecker already enforces this semantic, but the spec is not
updated when unsafe.{SliceData,String,StringData} were added.

Change-Id: I4ee8c564d5681b2a5fd31ff424a31bdf065d9f3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/467756
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agoruntime: expose auxv for use by x/sys/cpu
Brad Fitzpatrick [Sat, 17 Dec 2022 04:19:33 +0000 (20:19 -0800)]
runtime: expose auxv for use by x/sys/cpu

Updates #57336

Change-Id: I181885f59bac59360b855d3990326ea2b268bd28
Reviewed-on: https://go-review.googlesource.com/c/go/+/458256
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
15 months agocmd/compile: ensure InitMem comes after Args
Keith Randall [Thu, 16 Feb 2023 00:11:37 +0000 (16:11 -0800)]
cmd/compile: ensure InitMem comes after Args

The debug info generation currently depends on this invariant.

A small update to CL 468455.

Update #58482

Change-Id: Ica305d360d9af04036c604b6a65b683f7cb6e212
Reviewed-on: https://go-review.googlesource.com/c/go/+/468695
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
15 months agoruntime: reimplement GODEBUG=cgocheck=2 as a GOEXPERIMENT
Keith Randall [Thu, 20 Oct 2022 21:20:41 +0000 (14:20 -0700)]
runtime: reimplement GODEBUG=cgocheck=2 as a GOEXPERIMENT

Move this knob from a binary-startup thing to a build-time thing.
This will enable followon optmizations to the write barrier.

Change-Id: Ic3323348621c76a7dc390c09ff55016b19c43018
Reviewed-on: https://go-review.googlesource.com/c/go/+/447778
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile: detect write barrier completion differently
Keith Randall [Mon, 10 Oct 2022 02:06:23 +0000 (19:06 -0700)]
cmd/compile: detect write barrier completion differently

Instead of keeping track of in which blocks write barriers complete,
introduce a new op that marks the exact memory state where the
write barrier completes.

For future use. This allows us to move some of the write barrier code
to between the start of the merging block and the WBend marker.

Change-Id: If3809b260292667d91bf0ee18d7b4d0eb1e929f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/447777
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

15 months agocmd/compile: reorganize write barrier code a bit
Keith Randall [Mon, 10 Oct 2022 01:43:34 +0000 (18:43 -0700)]
cmd/compile: reorganize write barrier code a bit

This exposes mightBeHeapPointer and mightContainHeapPointer which
I plan to use in future CLs.

Change-Id: Ice4ae3b33127936868fff6cc045d8703d0b1a79a
Reviewed-on: https://go-review.googlesource.com/c/go/+/447776
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: share compiler allocations of similar shapes
Keith Randall [Mon, 9 Jan 2023 22:29:49 +0000 (14:29 -0800)]
cmd/compile: share compiler allocations of similar shapes

Use the same allocator for, e.g., []int32 and []int8. Anything with
similar base shapes and be coerced into a single allocator, which helps
reuse memory more often.

There is not much unsafe in the compiler currently. This adds quite a bit,
joining cmd/compiler/internal/base/mapfile_mmap.go and some unsafe.Sizeof calls.

Change-Id: I95d6d6e47c42b9f0a45f3556f4d7605735e65d99
Reviewed-on: https://go-review.googlesource.com/c/go/+/461084
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

15 months agonet: retry if GetAddrInfoW returns WSTRY_AGAIN when resolving an IP
zen [Tue, 17 Jan 2023 03:52:03 +0000 (19:52 -0800)]
net: retry if GetAddrInfoW returns WSTRY_AGAIN when resolving an IP

GetAddrInfoW is retried now multiple times as per the timeout and number of retries defined in func dnsReadConfig (before it was called only once)

Fixes #55050

Change-Id: If5369ebb164d98557a802de938756dbf9c125773
Reviewed-on: https://go-review.googlesource.com/c/go/+/462051
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agonet/http: support streaming POST content in wasm
Will Hawkins [Mon, 19 Dec 2022 16:49:33 +0000 (11:49 -0500)]
net/http: support streaming POST content in wasm

With new releases of Chrome, Opera and Deno it is possible to stream the
body of a POST request. Add support for using that interface when it is
available.

Change-Id: Ib23d63cd3dea634bd9e267abf4e9a9bfa9c525ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/458395
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
15 months agocrypto/internal/bigmod: flag amd64 assembly as noescape
Filippo Valsorda [Sun, 8 Jan 2023 16:39:02 +0000 (17:39 +0100)]
crypto/internal/bigmod: flag amd64 assembly as noescape

I had forgotten, which caused amd64 allocations to go back up
significantly. Added an allocations test.

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

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

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

Fixes #58501

Change-Id: I418c5152833787b80220b556336ec284674c2493
Reviewed-on: https://go-review.googlesource.com/c/go/+/460542
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

15 months agomath: add Compare and Compare32
Akhil Indurti [Sat, 11 Feb 2023 03:08:14 +0000 (19:08 -0800)]
math: add Compare and Compare32

This change introduces the Compare and Compare32 functions
based on the total-ordering predicate in IEEE-754, section 5.10.

In particular,
* -NaN is ordered before any other value
* +NaN is ordered after any other value
* -0 is ordered before +0
* All other values are ordered the usual way

Compare-8    0.4537n ± 1%
Compare32-8  0.3752n ± 1%
geomean      0.4126n

Fixes #56491.

Change-Id: I5c9c77430a2872f380688c1b0a66f2105b77d5ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/467515
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: schedule SP earlier
Keith Randall [Wed, 15 Feb 2023 01:25:48 +0000 (17:25 -0800)]
cmd/compile: schedule SP earlier

The actual scheduling of SP early doesn't really matter, but lots of
early spills (of arguments) depend on SP so they can't schedule until
SP does.

Fixes #58482

Change-Id: Ie581fba7cb173d665c11f797f39d824b1c040a2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/468455
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agocmd/go: fuzz test splitPkgConfigOutput and fix minor bugs
Bryan C. Mills [Thu, 9 Feb 2023 21:35:04 +0000 (16:35 -0500)]
cmd/go: fuzz test splitPkgConfigOutput and fix minor bugs

In reviewing CL 466875, I noticed that the implementation of
splitPkgConfigOutput from CL 86541 referred to another specific
implementation, and that implementation has had recent changes to fix
deviations from the POSIX specification for shell argument parsing.

Curious about those changes, I decided to fuzz the function to check
whether it agreed in practice with the way a real shell parses
arguments in POSIX mode. It turned out to deviate in several edge
cases, such as backslash-escapes within single quotes, quoted empty
strings, and carriage returns. (We do not expect to see carriage
returns in pkg-config output anyway, but the quote handling might
matter.)

This change updates the implementation to refer to the POSIX
documentation instead of another implementation, and confirms the
behavior with a fuzz test. It may introduce minor deviations from the
pkgconf implementation that was previously used as a reference, but if
so it is plausible that those could be fixed upstream in pkgconf
(like the other recent changes there).

For #35262.
Updates ##23373.

Change-Id: Ifab76e94af0ca9a6d826379f4a6e2028561e615c
Reviewed-on: https://go-review.googlesource.com/c/go/+/466864
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agoruntime: check for overflow in sweep assist
Michael Anthony Knyszek [Wed, 4 Jan 2023 05:20:58 +0000 (05:20 +0000)]
runtime: check for overflow in sweep assist

The sweep assist computation is intentionally racy for performance,
since the specifics of sweep assist aren't super sensitive to error.
However, if overflow occurs when computing the live heap delta, we can
end up with a massive sweep target that causes the sweep assist to sweep
until sweep termination, causing severe latency issues. In fact, because
heapLive doesn't always increase monotonically then anything that
flushes mcaches will cause _all_ allocating goroutines to inevitably get
stuck in sweeping.

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

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

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

Fixes #57523.

Change-Id: Ib18f71f53468e913548aac6e5358830c72ef0215
Reviewed-on: https://go-review.googlesource.com/c/go/+/460376
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

15 months agoall: update vendored golang.org/x/net
Michael Pratt [Tue, 14 Feb 2023 18:04:12 +0000 (13:04 -0500)]
all: update vendored golang.org/x/net

Pull in HTTP/2 security fix:

    CL 468135: http2/hpack: avoid quadratic complexity in hpack decoding

For #57855

Change-Id: Id6b05dc52a1a585c41c6aff0c51665614fd5e215
Reviewed-on: https://go-review.googlesource.com/c/go/+/468295
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>

15 months agoslices: skip TestGrow allocation test if noopt
Ian Lance Taylor [Tue, 14 Feb 2023 17:38:18 +0000 (09:38 -0800)]
slices: skip TestGrow allocation test if noopt

Change-Id: Ie444367c6bb16ed78482d1786b546e6daa63444a
Reviewed-on: https://go-review.googlesource.com/c/go/+/468196
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocrypto/tls: replace all usages of BytesOrPanic
Roland Shoemaker [Wed, 14 Dec 2022 17:43:16 +0000 (09:43 -0800)]
crypto/tls: replace all usages of BytesOrPanic

Message marshalling makes use of BytesOrPanic a lot, under the
assumption that it will never panic. This assumption was incorrect, and
specifically crafted handshakes could trigger panics. Rather than just
surgically replacing the usages of BytesOrPanic in paths that could
panic, replace all usages of it with proper error returns in case there
are other ways of triggering panics which we didn't find.

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

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

Thanks to Marten Seemann for reporting this issue.

Fixes #58001
Fixes CVE-2022-41724

Change-Id: Ieb55867ef0a3e1e867b33f09421932510cb58851
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1679436
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468125
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>

15 months agomime/multipart: limit memory/inode consumption of ReadForm
Damien Neil [Wed, 25 Jan 2023 17:27:01 +0000 (09:27 -0800)]
mime/multipart: limit memory/inode consumption of ReadForm

Reader.ReadForm is documented as storing "up to maxMemory bytes + 10MB"
in memory. Parsed forms can consume substantially more memory than
this limit, since ReadForm does not account for map entry overhead
and MIME headers.

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

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

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

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

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

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

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

Fixes #58006
Fixes CVE-2022-41725

Change-Id: Ibd780a6c4c83ac8bcfd3cbe344f042e9940f2eab
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1714276
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468124
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agopath/filepath: do not Clean("a/../c:/b") into c:\b on Windows
Damien Neil [Tue, 13 Dec 2022 00:43:37 +0000 (16:43 -0800)]
path/filepath: do not Clean("a/../c:/b") into c:\b on Windows

Do not permit Clean to convert a relative path into one starting
with a drive reference. This change causes Clean to insert a .
path element at the start of a path when the original path does not
start with a volume name, and the first path element would contain
a colon.

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

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

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

Fixes #57274
Fixes CVE-2022-41722

Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/468123
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoall: fix some comments
cui fliter [Tue, 14 Feb 2023 14:42:38 +0000 (22:42 +0800)]
all: fix some comments

Change-Id: I16ec916b47de2f417b681c8abff5a1375ddf491b
Reviewed-on: https://go-review.googlesource.com/c/go/+/468055
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoRevert "io: detect Writers that access io.Copy's buffer after returning"
Damien Neil [Mon, 13 Feb 2023 22:35:34 +0000 (14:35 -0800)]
Revert "io: detect Writers that access io.Copy's buffer after returning"

This reverts CL 466865.

Reason for revert: Causing trybot flakiness due to net/http race,
roll back until net/http is fixed.

For #58168

Change-Id: I3129deb996abe6466eccf933fe93cbbaf72ae217
Reviewed-on: https://go-review.googlesource.com/c/go/+/467895
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>

15 months agogo/internal/gcimporter: restore Go 1.19 Package.SetImports behavior
Matthew Dempsky [Mon, 13 Feb 2023 22:40:01 +0000 (14:40 -0800)]
go/internal/gcimporter: restore Go 1.19 Package.SetImports behavior

This CL is a port of go.dev/cl/465936 from the x/tools importer, which
changes the unified importer to (1) only call Package.SetImports on
the main package being imported (not any transitively imported
packages), and (2) to only populate it with any packages that were
referenced by the exported API.

With these changes, it should behave identically to how the indexed
importer worked in Go 1.19. It will also allow eventually dropping the
serialized import DAG from the export data format, which should help
with export data file sizes somewhat.

Updates #54096.
Updates #58296.

Change-Id: I70d252a19cada3333ed59b16d1df2abc5a4cff73
Reviewed-on: https://go-review.googlesource.com/c/go/+/467896
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: fix wrong escape analysis for go/defer generic calls
Cuong Manh Le [Tue, 7 Feb 2023 12:28:15 +0000 (19:28 +0700)]
cmd/compile: fix wrong escape analysis for go/defer generic calls

For go/defer calls like "defer f(x, y)", the compiler rewrites it to:

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

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

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

Fixes #58341

Change-Id: I238b6e75441442b5540d39bc818205398e80c94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466035
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoslices: new package
Ian Lance Taylor [Fri, 10 Feb 2023 21:52:37 +0000 (13:52 -0800)]
slices: new package

This copies parts of x/exp/slices into the standard library.
We omit all functions that depend on constraints.Ordered,
and the Func variants of all such functions. In particular this
omits the various Sort and Search functions.

Fixes #57433

Change-Id: I3c28f4c2e6bd1e3c9ad70e120a0dd68065388f77
Reviewed-on: https://go-review.googlesource.com/c/go/+/467417
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocmd/link/internal/ld: fix text section splitting for ARM
Than McIntosh [Mon, 13 Feb 2023 15:13:57 +0000 (10:13 -0500)]
cmd/link/internal/ld: fix text section splitting for ARM

Fix a problem with trampoline generation for ARM that was causing link
failures when building selected k8s targets. Representative error
(this is coming from the external linker):

  go.go:(.text+...): relocation truncated to fit: R_ARM_CALL against `runtime.duffcopy'

The Go linker is supposed to be limiting text section size for ARM to
0x1c00000 bytes, however due to a problem in the tramp generation
phase this limit wasn't being enforced.

Updates #58428.
Fixes #58425.

Change-Id: I4e778bdcbebeab607a6e626b354ca5109e52a1aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/467715
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoall: update vendored golang.org/x/net
Damien Neil [Mon, 13 Feb 2023 18:58:32 +0000 (10:58 -0800)]
all: update vendored golang.org/x/net

Pull in HTTP/2 fix to deflake builders:

    547e7edf38 http2: avoid referencing ResponseWrite.Write parameter after returning

For #58446

Change-Id: I7f3666bc1f20ee03a7ccf25f0e091033cbc635d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/467657
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/internal/cov: fix typo in readcovdata.go
Ikko Eltociear Ashimine [Sat, 11 Feb 2023 12:45:01 +0000 (12:45 +0000)]
cmd/internal/cov: fix typo in readcovdata.go

hte -> the

Change-Id: Ie81062997289d622756881acdd11af66611cd778
GitHub-Last-Rev: 5ef07542b47f243d5a66ef166c74db0348fd2c80
GitHub-Pull-Request: golang/go#58473
Reviewed-on: https://go-review.googlesource.com/c/go/+/467518
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocrypto/internal/edwards25519: reduce Point size by reordering fields
Jorropo [Mon, 13 Feb 2023 00:48:57 +0000 (01:48 +0100)]
crypto/internal/edwards25519: reduce Point size by reordering fields

Updates #58483

Tested on Linux amd64:
  type Element struct {
    l0, l1, l2, l3, l4 uint64
  }

  type PointAfter struct {
    x, y, z, t Element
    _          incomparable
  }

  type PointBefore struct {
    _          incomparable
    x, y, z, t Element
  }

  type incomparable [0]func()

  func main() {
    fmt.Println(unsafe.Sizeof(PointAfter{})) // 168
    fmt.Println(unsafe.Sizeof(PointBefore{})) // 160
  }

Change-Id: I6c4fcb586bbf3febf62b6e54608496ff81685e43
Reviewed-on: https://go-review.googlesource.com/c/go/+/467616
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

15 months agocmd/dist: use a copy of platform.BuildModeSupported
Ian Lance Taylor [Fri, 10 Feb 2023 22:47:07 +0000 (14:47 -0800)]
cmd/dist: use a copy of platform.BuildModeSupported

The dist tool already includes a similar duplicate of BuildModeSupported.
Replace it with an exact copy, to make it easier to maintain going forward.

Change-Id: Id14a6c5a48f92d843e02218d87cc62c6b001923b
Reviewed-on: https://go-review.googlesource.com/c/go/+/467495
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agointernal/bytealg: simplify and improve compare on riscv64
Joel Sing [Sat, 17 Sep 2022 15:43:20 +0000 (01:43 +1000)]
internal/bytealg: simplify and improve compare on riscv64

Remove some unnecessary loops and pull the comparison code out from the
compare/loop code. Add an unaligned 8 byte comparison, which reads 8 bytes
from each input before comparing them. This gives a reasonable gain in
performance for the large unaligned case.

Updates #50615

name                                 old time/op    new time/op    delta
CompareBytesEqual-4                     116ns _ 0%     111ns _ 0%   -4.10%  (p=0.000 n=5+5)
CompareBytesToNil-4                    34.9ns _ 0%    35.0ns _ 0%   +0.45%  (p=0.002 n=5+5)
CompareBytesEmpty-4                    29.6ns _ 1%    29.8ns _ 0%   +0.71%  (p=0.016 n=5+5)
CompareBytesIdentical-4                29.8ns _ 0%    29.9ns _ 1%   +0.50%  (p=0.036 n=5+5)
CompareBytesSameLength-4               66.1ns _ 0%    60.4ns _ 0%   -8.59%  (p=0.000 n=5+5)
CompareBytesDifferentLength-4          63.1ns _ 0%    60.5ns _ 0%   -4.20%  (p=0.000 n=5+5)
CompareBytesBigUnaligned/offset=1-4    6.84ms _ 3%    6.04ms _ 5%  -11.70%  (p=0.001 n=5+5)
CompareBytesBigUnaligned/offset=2-4    6.99ms _ 4%    5.93ms _ 6%  -15.22%  (p=0.000 n=5+5)
CompareBytesBigUnaligned/offset=3-4    6.74ms _ 1%    6.00ms _ 5%  -10.94%  (p=0.001 n=5+5)
CompareBytesBigUnaligned/offset=4-4    7.20ms _ 6%    5.97ms _ 6%  -17.05%  (p=0.000 n=5+5)
CompareBytesBigUnaligned/offset=5-4    6.75ms _ 1%    5.81ms _ 8%  -13.93%  (p=0.001 n=5+5)
CompareBytesBigUnaligned/offset=6-4    6.89ms _ 5%    5.75ms _ 2%  -16.58%  (p=0.000 n=5+4)
CompareBytesBigUnaligned/offset=7-4    6.91ms _ 6%    6.13ms _ 6%  -11.27%  (p=0.001 n=5+5)
CompareBytesBig-4                      2.75ms _ 5%    2.71ms _ 8%     ~     (p=0.651 n=5+5)
CompareBytesBigIdentical-4             29.9ns _ 1%    29.8ns _ 0%     ~     (p=0.751 n=5+5)

name                                 old speed      new speed      delta
CompareBytesBigUnaligned/offset=1-4   153MB/s _ 3%   174MB/s _ 6%  +13.40%  (p=0.003 n=5+5)
CompareBytesBigUnaligned/offset=2-4   150MB/s _ 4%   177MB/s _ 6%  +18.06%  (p=0.001 n=5+5)
CompareBytesBigUnaligned/offset=3-4   156MB/s _ 1%   175MB/s _ 5%  +12.39%  (p=0.002 n=5+5)
CompareBytesBigUnaligned/offset=4-4   146MB/s _ 6%   176MB/s _ 6%  +20.67%  (p=0.001 n=5+5)
CompareBytesBigUnaligned/offset=5-4   155MB/s _ 1%   181MB/s _ 7%  +16.35%  (p=0.002 n=5+5)
CompareBytesBigUnaligned/offset=6-4   152MB/s _ 5%   182MB/s _ 2%  +19.74%  (p=0.000 n=5+4)
CompareBytesBigUnaligned/offset=7-4   152MB/s _ 6%   171MB/s _ 6%  +12.70%  (p=0.001 n=5+5)
CompareBytesBig-4                     382MB/s _ 5%   388MB/s _ 9%     ~     (p=0.616 n=5+5)
CompareBytesBigIdentical-4           35.1TB/s _ 1%  35.1TB/s _ 0%     ~     (p=0.800 n=5+5)

Change-Id: I127edc376e62a2c529719a4ab172f481e0a81357
Reviewed-on: https://go-review.googlesource.com/c/go/+/431100
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

15 months agoruntime: Allow handling of EXCEPTION_IN_PAGE_ERROR
Max Altgelt [Fri, 10 Feb 2023 10:38:42 +0000 (11:38 +0100)]
runtime: Allow handling of EXCEPTION_IN_PAGE_ERROR

Currently, access faults on memory mapped files on Windows (e.g.
from the drive the memory mapped file is on being ejected) cause
a runtime fault that can not be caught by debug.SetPanicOnFault.

On Unix systems, on the other hand, this causes a SIGBUS signal,
which can be caught by debug.SetPanicOnFault. Given that the
documentation of debug.SetPanicOnFault mentions handling memory
mapped files, this is arguably the correct behaviour.

Add handling, analogous to SIGBUS, to EXCEPTION_IN_PAGE_ERROR
on Windows, to allow for users to handle this error.

Fixes #58457

Change-Id: Ic7695fc01271f3552782089ac75c403d5279811f
Reviewed-on: https://go-review.googlesource.com/c/go/+/467195
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
15 months agocmd/go: mod vendor: fixed checking for vendor directory
David Barshow [Tue, 7 Feb 2023 17:30:05 +0000 (17:30 +0000)]
cmd/go: mod vendor: fixed checking for vendor directory

In our case I was using a "vendor-replace" directory which was incorrectly flagged as being in the vendor directory.

Change-Id: I8208243ea8416ee7cb4de30e907bcfc25c2d3f27
GitHub-Last-Rev: d183a94d03225ee529c4906a64a289f02eaf7684
GitHub-Pull-Request: golang/go#58287
Reviewed-on: https://go-review.googlesource.com/c/go/+/465036
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agoio: detect Writers that access io.Copy's buffer after returning
Damien Neil [Thu, 9 Feb 2023 22:41:42 +0000 (14:41 -0800)]
io: detect Writers that access io.Copy's buffer after returning

When the race detector is enabled, scribble over copy buffers with
garbage after Write returns.

For #58452

Change-Id: I25547684bcbef7d302d76736cb02e59c89a640ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/466865
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>

15 months agocmd/go: handle escapes in pkg-config ldflags output
zlasd [Thu, 9 Feb 2023 14:03:45 +0000 (14:03 +0000)]
cmd/go: handle escapes in pkg-config ldflags output

#16455 handled escapes in pkg-config output but only for cflags. The fix
for #41400 left a note that we don't need to parse quotes and unescapes,
but it is still necessary to handle spaces in pkg-config output. As cflags
has already been processed correctly, we apply the same logic to ldflags
here.

Fixes #35262

Change-Id: Id01d422b103780f67f89e99ff1df0d8f51a7a137
GitHub-Last-Rev: c67e5112130fa008397cfd0bc03e1de58201da86
GitHub-Pull-Request: golang/go#58429
Reviewed-on: https://go-review.googlesource.com/c/go/+/466875
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
15 months agocmd/trace: fix error message for bad goroutine state transition
Nick Ripley [Fri, 10 Feb 2023 19:08:27 +0000 (14:08 -0500)]
cmd/trace: fix error message for bad goroutine state transition

The error message when an invalid goroutine state transition is found in
a trace should show the current state, not the next state, when
comparing against the expected current state.

This CL also picks up a gofmt change to the file.

Change-Id: Ic0ce6c9ce79d8a784b73b115b5db76c311b8593d
Reviewed-on: https://go-review.googlesource.com/c/go/+/467416
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agovendor: add new vendored files from update
David Chase [Fri, 10 Feb 2023 20:01:40 +0000 (15:01 -0500)]
vendor: add new vendored files from update

fixes failing cmd/internal/moddeps TestAllDependencies

Change-Id: I70e081469f1aa3b795a5bd28adeb61b31d7f34fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/467415
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agonet: move context cancellation logic of blocking calls to a common function
Mateusz Poliwczak [Fri, 10 Feb 2023 09:01:29 +0000 (09:01 +0000)]
net: move context cancellation logic of blocking calls to a common function

Follow up of CL 464375 which reverted the CL 463231, because of a data race.

Change-Id: I1a52f23a68a6981b902fc59bda1437bd169ca22b
GitHub-Last-Rev: 0157bd01807a731239f3f2940d440e798be33d83
GitHub-Pull-Request: golang/go#58383
Reviewed-on: https://go-review.googlesource.com/c/go/+/465836
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocmd/compile/internal/pgo: fix hard-coded PGO sample data position
Frederic Branczyk [Wed, 8 Feb 2023 17:59:27 +0000 (17:59 +0000)]
cmd/compile/internal/pgo: fix hard-coded PGO sample data position

This patch detects at which index position profiling samples that have
the value-type samples count are, instead of the previously hard-coded
position of index 1. Runtime generated profiles always generate CPU
profiling data with the 0 index being CPU nanoseconds, and samples count
at index 1, which is why this previously hasn't come up.

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

Fixes #58292

Change-Id: Ia6c94f0793f6ca9b0882b5e2c4d34f38e600c1e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/466675
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agovendor, cmd/vendor: update standard library dependencies
David Chase [Thu, 9 Feb 2023 18:04:21 +0000 (13:04 -0500)]
vendor, cmd/vendor: update standard library dependencies

Change-Id: I6facfae14e850f6c9bf3bcb53489c8b475bbb860
Reviewed-on: https://go-review.googlesource.com/c/go/+/467297
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: David Chase <drchase@google.com>

15 months agobufio: permit r.Reset(r) without infinite recursion
Ian Lance Taylor [Thu, 9 Feb 2023 03:50:06 +0000 (19:50 -0800)]
bufio: permit r.Reset(r) without infinite recursion

This can happen in reasonable code because NewReader(r) can return r,
if r is already a Reader.

Similarly for Writer.

Fixes #58423

Change-Id: Iff9d9265410bee68fbaeb7175369847bd737eb2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/466815
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

15 months agocmd/internal/cov: fix misuse of bufio.Reader.Read in read helper
Than McIntosh [Wed, 8 Feb 2023 20:06:08 +0000 (15:06 -0500)]
cmd/internal/cov: fix misuse of bufio.Reader.Read in read helper

Fix a misuse of bufio.Reader.Read in the helper class
cmd/internal/cov.MReader; the MReader method in question should have
been using io.ReadFull (passing the bufio.Reader) instead of directly
calling Read.

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

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

Fixes #58411.

Change-Id: Iea48dc25c0081be1ade29f3a633df02a681fd941
Reviewed-on: https://go-review.googlesource.com/c/go/+/466677
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agoRevert "math: add Compare and Compare32"
Than McIntosh [Fri, 10 Feb 2023 14:39:20 +0000 (14:39 +0000)]
Revert "math: add Compare and Compare32"

This reverts CL 459435.

Reason for revert: Tests failing on MIPS.

Change-Id: I9017bf718ba938df6d6766041555034d55d90b8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/467255
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Akhil Indurti <aindurti@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agocmd/go: remove tests that assume lack of new versions of external modules
Bryan C. Mills [Thu, 9 Feb 2023 21:37:51 +0000 (16:37 -0500)]
cmd/go: remove tests that assume lack of new versions of external modules

In general it seems ok to assume that an open-source module that did
exist will continue to do so — after all, users of open-source modules
already do that all the time. However, we should not assume that those
modules do not publish new versions — that's really up to their
maintainers to decide.

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

Fixes #58445.

Change-Id: Ica8fe587d86fc41f3d8445a4cd2b8820455ae45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/466860
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
15 months agomath/rand: fix typo in Seed deprecation comment
Valentin Deleplace [Fri, 10 Feb 2023 14:51:11 +0000 (15:51 +0100)]
math/rand: fix typo in Seed deprecation comment

Change-Id: I37a9e4362953a711840087e1b7b8d7a25f1a83b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/467275
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

15 months agoRevert "io: allocate copy buffers from a pool"
Damien Neil [Thu, 9 Feb 2023 22:24:46 +0000 (14:24 -0800)]
Revert "io: allocate copy buffers from a pool"

This reverts CL 456555.

Reason for revert: This seems too likely to exercise race conditions
in code where a Write call continues to access its buffer after
returning. The HTTP/2 ResponseWriter is one such example.

Reverting this change while we think about this some more.

For #57202

Change-Id: Ic86823f81d7da410ea6b3f17fb5b3f9a979e3340
Reviewed-on: https://go-review.googlesource.com/c/go/+/467095
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocontext: reduce init-time allocations
Carlo Alberto Ferraris [Tue, 6 Dec 2022 05:45:04 +0000 (14:45 +0900)]
context: reduce init-time allocations

Small cleanup to remove a couple of needless global variables.
Instead of relying on two instances of emptyCtx having different
addresses, we use different types.

For #26775

Change-Id: I0bc4813e94226f7b3f52bf4b1b3c3a3bbbebcc9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/455455
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
15 months agoruntime: skip darwin osinit_hack on ios
Russ Cox [Wed, 8 Feb 2023 19:02:55 +0000 (14:02 -0500)]
runtime: skip darwin osinit_hack on ios

Darwin needs the osinit_hack call to fix some bugs in the Apple libc
that surface when Go programs call exec. On iOS, the functions that
osinit_hack uses are not available, so signing fails. But on iOS exec
is also unavailable, so the hack is not needed. Disable it there,
which makes signing work again.

Fixes #58323.

Change-Id: I3f1472f852bb36c06854fe1f14aa27ad450c5945
Reviewed-on: https://go-review.googlesource.com/c/go/+/466516
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dave Anderson <danderson@tailscale.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agocmd/dist: remove windows-amd64-2008 code path
qmuntal [Fri, 10 Feb 2023 09:36:16 +0000 (10:36 +0100)]
cmd/dist: remove windows-amd64-2008 code path

`windows-amd64-2008` builder does no longer exist on go1.20,
so it is safe to remove conditions checking for that name.

Updates #57003
Closes #56904

Change-Id: I941ccc64cda0af3b9356996c4b581700afa81987
Reviewed-on: https://go-review.googlesource.com/c/go/+/467175
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agocmd/link: try libssp_nonshared.a when looking for "__stack_chk_fail_local"
Than McIntosh [Thu, 9 Feb 2023 16:37:13 +0000 (11:37 -0500)]
cmd/link: try libssp_nonshared.a when looking for "__stack_chk_fail_local"

Update the code that tries to satisfy unresolved references to
"__stack_chk_fail_local" to look for "libssp_nonshared.a" in addition
to "libc_nonshared.a" (the former archive is the correct place on
Alpine).

Updates #52919.
Updates #54313.
Updates #57261.
Fixes #58385.

Change-Id: Id6cd3ebb4d5388df50a838e6efa5e5b683545b01
Reviewed-on: https://go-review.googlesource.com/c/go/+/466936
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/cgo: add -fno-stack-protector to CFLAGS (again)
Than McIntosh [Thu, 9 Feb 2023 16:31:57 +0000 (11:31 -0500)]
cmd/cgo: add -fno-stack-protector to CFLAGS (again)

Add -fno-stack-protector back to the default set of CFLAGS for cgo, so
as to avoid problems with internal linking locating the library
containing the "__stack_chk_fail_local" support function that some
compilers emit (the specific archive can vary based on GOOS).

Updates #52919.
Updates #54313.
Updates #57261.
Updates #58385.

Change-Id: I4591bfb15501f04b7afe1fcd50c4fb93c86db63d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466935
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/link: improve error for missing SDYNIMPORT support on mips/mips64
Than McIntosh [Thu, 9 Feb 2023 14:08:44 +0000 (09:08 -0500)]
cmd/link: improve error for missing SDYNIMPORT support on mips/mips64

Issue an error (instead of crashing) when encountering a symbol that
requires dynamic relocations on mips/mips64. The dynimport support is
in progress, but is not done yet, so rather than crashing, print a
message indicating that the feature is not yet implemented and exit.

Fixes #58240.

Change-Id: I9ad64c89e4f7b4b180964b35ad1d72d375f2df7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/466895
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

15 months agomath/rand: rewrite the math/rand package comment to say what it's good for
Rob Pike [Wed, 8 Feb 2023 03:19:59 +0000 (14:19 +1100)]
math/rand: rewrite the math/rand package comment to say what it's good for

It currently says only what it wasn't good for, which is not helpful.

Change-Id: I468c7f385c14eaca99788a94d53c30b729ed0944
Reviewed-on: https://go-review.googlesource.com/c/go/+/466276
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agogo/types, types2: remove need to store type parameter list in unifier
Robert Griesemer [Thu, 9 Feb 2023 17:23:41 +0000 (09:23 -0800)]
go/types, types2: remove need to store type parameter list in unifier

For unification we only need the handles map.
The type parameter list was stored for reproducible printing only,
but we can achieve the same effect with sorting.

This opens the door to adding type parameters from different
types/functions that we may want to infer together. They may
be added through separate "addTypeParams" calls in the future.
Printing (which is used for debugging only) will remain reproducible.

Change-Id: I23b56c63fa45a7d687761f2efcf558e61b004584
Reviewed-on: https://go-review.googlesource.com/c/go/+/466955
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: simplify unify.inferred signature
Robert Griesemer [Thu, 9 Feb 2023 00:51:58 +0000 (16:51 -0800)]
go/types, types2: simplify unify.inferred signature

Rather than referring back to the type parameter list stored with
the unifier, return inferred types for a given list of type parameters.
This decouples the unifier more and opens the door for inference to
consider type parameters from multiple types for inference.

While at it, introduce an internal flag to control whether
inference results of the two inference implementations should
be compared or not.

Change-Id: I23b254c6c1c750f5bd1360aa2bb088cc466434f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/466795
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet: remove unused cname return from cgoLookupIPCNAME
Mateusz Poliwczak [Wed, 8 Feb 2023 08:44:32 +0000 (08:44 +0000)]
net: remove unused cname return from cgoLookupIPCNAME

Change-Id: I4f9b84696f55c6b381de60682f8b242098b95b75
GitHub-Last-Rev: 74a6013a9e668119a0895c1250c3d4592bfd4072
GitHub-Pull-Request: golang/go#58402
Reviewed-on: https://go-review.googlesource.com/c/go/+/466335
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agomath: add Compare and Compare32
Akhil Indurti [Sat, 24 Dec 2022 14:22:30 +0000 (09:22 -0500)]
math: add Compare and Compare32

This change introduces the Compare and Compare32 functions
based on the total-ordering predicate in IEEE-754, section 5.10.

In particular,
* -NaN is ordered before any other value
* +NaN is ordered after any other value
* -0 is ordered before +0
* All other values are ordered the usual way

name         time/op
Compare-8    0.24ns ± 1%
Compare32-8  0.24ns ± 0%

Fixes #56491.

Change-Id: I9444fbfefe26741794c4436a26d403b8da97bdaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/459435
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agonet/http: improve js fetch errors
Johan Brandhorst-Satzkorn [Sat, 28 Jan 2023 06:53:25 +0000 (22:53 -0800)]
net/http: improve js fetch errors

The Error type used in failed fetch invocations contain more
information than we're currently extracting. Optimistically
look for the cause field for extra context for errors.

Change-Id: I6c8e4b230a21ec684af2107707aa605fc2148fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/463978
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Evan Phoenix <evan@phx.io>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>