1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:34:39 -07:00
Commit Graph

58141 Commits

Author SHA1 Message Date
thepudds
fbaf71f36b cmd/compile/internal/dwarfgen: make scope test less sensitive to changes in escape analysis
The test function fi is used in TestEscape, and the intent of fi
seems to be to leak its argument, but fi is currently
sensitive to changes in escape analysis regarding interface receivers.

Make fi less sensitive by directly leaking its argument.

Change-Id: I16cc3d3a6bd7b08a08c8fc292b0b99c9a54d68d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/524943
Run-TryBot: t hepudds <thepudds1460@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-07 00:29:59 +00:00
Andy Pan
729f214e3a runtime: fix the miscalculation of memoryLimitGoal in gcPaceScavenger
The goal is supposed to be (100-reduceExtraPercent) / 100 * memoryLimit,
as stated in the original design.

Fixes #62449

Change-Id: Ia33acadc3320aa3625814595a24b9631ae8896d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/525555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
2023-09-06 19:37:10 +00:00
Michael Pratt
4be921d888 runtime: clear procid in unminit
Extra Ms can move between system threads. needm will reinitialize procid
(via minit) on the new thread, but leaving a stale procid behind after
dropm can be misleading if printing the M early in needm for debugging.

Change-Id: I668891971a0baeab31170d1e40a97126416e7379
Reviewed-on: https://go-review.googlesource.com/c/go/+/526118
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:36:02 +00:00
Ian Lance Taylor
f25ca8b33d cmd/go: permit $AR to include options
Handle the AR environment variable, used by gccgo,
the same way we handle the CC environment variable.

Change-Id: I4f42161469392f68f0b5adeb9c8b52359d5108a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/526275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-06 18:35:28 +00:00
Than McIntosh
3f0f76734e cmd/compile/internal/inline: analyze function result properties
Add code to analyze properties of function result values, specifically
heuristics for cases where we always return allocated memory, always
return the same constant, or always return the same function.

Updates #61502.

Change-Id: I8b0a3295b5be7f7ad4c2d5b9803925aea0639376
Reviewed-on: https://go-review.googlesource.com/c/go/+/511559
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:30:19 +00:00
Than McIntosh
3d62c76736 cmd/compile/internal/ir: add "never returns" func flag
Add a flag to ir.Func's flags field to record whether a given function
is deemed to never return (e.g. always calls exit or panic or
equivalent on all control paths). So as to not increase the amount of
flag storage, this new flag replaces the existing "ExportInline" flag,
which is currently unused.

Change-Id: Idd336e47381048cfc995eda05faf8b62f06ba206
Reviewed-on: https://go-review.googlesource.com/c/go/+/518256
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:29:16 +00:00
Bryan C. Mills
a0c3a1b676 cmd/go: reject toolchain directives containing path separators
If GOTOOLCHAIN="path" or "auto", the go command uses exec.LookPath to
search for it in order to allow toolchains to refer to local-only
toolchain variants (such as toolchains built from enterprise- or
distro-patched source). However, those toolchains should only be
resolved from $PATH, not relative to the working directory of the
command.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #62198.
Fixes CVE-2023-39320.

Change-Id: I247c7acea95d737362dd0475e9fc8515430d0fcc
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1996318
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526158
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 18:27:30 +00:00
Roland Shoemaker
b2f8f6c8ef html/template: properly handle special tags within the script context
The HTML specification has incredibly complex rules for how to handle
"<!--", "<script", and "</script" when they appear within literals in
the script context. Rather than attempting to apply these restrictions
(which require a significantly more complex state machine) we apply
the workaround suggested in section 4.12.1.3 of the HTML specification [1].

More precisely, when "<!--", "<script", and "</script" appear within
literals (strings and regular expressions, ignoring comments since we
already elide their content) we replace the "<" with "\x3C". This avoids
the unintuitive behavior that using these tags within literals can cause,
by simply preventing the rendered content from triggering it. This may
break some correct usages of these tags, but on balance is more likely
to prevent XSS attacks where users are unknowingly either closing or not
closing the script blocks where they think they are.

Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for
reporting this issue.

Fixes #62197
Fixes CVE-2023-39319

[1] https://html.spec.whatwg.org/#restrictions-for-contents-of-script-elements

Change-Id: Iab57b0532694827e3eddf57a7497ba1fab1746dc
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1976594
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526157
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-09-06 18:26:41 +00:00
Roland Shoemaker
67fb00396d html/template: support HTML-like comments in script contexts
Per Appendix B.1.1 of the ECMAScript specification, support HTML-like
comments in script contexts. Also per section 12.5, support hashbang
comments. This brings our parsing in-line with how browsers treat these
comment types.

Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for
reporting this issue.

Fixes #62196
Fixes CVE-2023-39318

Change-Id: Id512702c5de3ae46cf648e268cb10e1eb392a181
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1976593
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526156
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@golang.org>
2023-09-06 18:11:19 +00:00
Than McIntosh
e844d72421 cmd/compile/internal/inline: no-return flag analysis for inline heuristics
Add code to compute whether a given function appears to
unconditionally call panic or exit, as a means of driving inlining
decisions. Note that this determination is based on
heuristics/guesses, as opposed to strict safety analysis; in some
cases we may miss a function that does indeed always panic, or mark a
function as always invoking panic when it doesn't; the intent is get
the right answer in "most" cases.

Updates #61502.

Change-Id: Ibba3e60c06c2e54cf29b3ffa0f816518aaacb9a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/511558
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-06 17:43:02 +00:00
Paul E. Murphy
5cdb132228 cmd/compile/internal/ssa: improve masking codegen on PPC64
Generate RLDIC[LR] instead of MOVD mask, Rx; AND Rx, Ry, Rz.
This helps reduce code size, and reduces the latency caused
by the constant load.

Similarly, for smaller-than-register values, truncate constants
which exceed the range of the value's type to avoid needing to
load a constant.

Change-Id: I6019684795eb8962d4fd6d9585d08b17c15e7d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/515576
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-06 16:34:20 +00:00
Nayef Ghattas
2186909d86 runtime/metrics: fix /gc/scan/* metrics
In the existing implementation, all /gc/scan/* metrics are
always equal to 0 due to the dependency on gcStatDep not being
set. This leads to gcStatAggregate always containing zeros, and
always reporting 0 for those metrics.

Also, add a test to ensure that /gc/scan/* metrics are not empty.

Fixes #62477.

Change-Id: I67497347d50ed5c3ce1719a18714c062ec938cab
Reviewed-on: https://go-review.googlesource.com/c/go/+/525595
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
2023-09-06 15:44:45 +00:00
Austin Clements
4c5130a96e runtime: ignore SPWrite on innermost traceback frame
Prior to CL 458218, gentraceback ignored the SPWrite function flag on
the innermost frame when doing a precise traceback on the assumption
that precise tracebacks could only be started from the morestack
prologue, and that meant that the innermost function could not have
modified SP yet.

CL 458218 rearranged this logic a bit and unintentionally lost this
particular case. As a result, if traceback starts in an assembly
function that modifies SP (either as a result of stack growth or stack
scanning during a GC preemption), traceback stop at the SPWrite
function and then crash with "traceback did not unwind completely".

Fix this by restoring the earlier special case for when the innermost
frame is SPWrite.

This is a fairly minimal change that should be easy to backport. I
think a more robust change would be to encode this per-PC in the
spdelta table, so it would be clear that we're unwinding from the
morestack prologue and wouldn't rely on a complicated and potentially
fragile set of conditions.

Fixes #62326.

Change-Id: I34f38157631890d33a79d0bd32e32c0fcc2574e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/525835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-09-06 14:45:46 +00:00
Dmitri Shuralyov
08e35cc334 all: use ^$ instead of XXXX, NoSuchTestExists to match no tests
It's shorter and can't accidentally match unlikely test names.

Change-Id: I96dd9da018cad1acf604f266819470278f54c128
Reviewed-on: https://go-review.googlesource.com/c/go/+/524949
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-05 23:35:32 +00:00
Dmitri Shuralyov
0dfb22ed70 all: use ^TestName$ regular pattern for invoking a single test
Use ^ and $ in the -run flag regular expression value when the intention
is to invoke a single named test. This removes the reliance on there not
being another similarly named test to achieve the intended result.

In particular, package syscall has tests named TestUnshareMountNameSpace
and TestUnshareMountNameSpaceChroot that both trigger themselves setting
GO_WANT_HELPER_PROCESS=1 to run alternate code in a helper process. As a
consequence of overlap in their test names, the former was inadvertently
triggering one too many helpers.

Spotted while reviewing CL 525196. Apply the same change in other places
to make it easier for code readers to see that said tests aren't running
extraneous tests. The unlikely cases of -run=TestSomething intentionally
being used to run all tests that have the TestSomething substring in the
name can be better written as -run=^.*TestSomething.*$ or with a comment
so it is clear it wasn't an oversight.

Change-Id: Iba208aba3998acdbf8c6708e5d23ab88938bfc1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524948
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-05 23:35:29 +00:00
Ian Lance Taylor
cffdfe8d2c runtime: don't let the tests leave core files behind
Also add a check that we didn't leave any core files behind.

Change-Id: I30444ef43ad1a8cc1cacd3b75280f2128e104939
Reviewed-on: https://go-review.googlesource.com/c/go/+/525175
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-05 22:43:54 +00:00
Ian Lance Taylor
a819178915 os: don't invoke shell in TestStatStdin
Change-Id: I4048caffd4f79e3ffb6a0a3770bdfa830d1a2f35
Reviewed-on: https://go-review.googlesource.com/c/go/+/525515
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-05 22:34:26 +00:00
go101
972cc3e7c2 testing: add doc to not call Init concurrently
Change-Id: I2e218805fbe4858be125df97bdaf921799315799
GitHub-Last-Rev: 32b798d75f
GitHub-Pull-Request: golang/go#62410
Reviewed-on: https://go-review.googlesource.com/c/go/+/525015
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-05 22:26:12 +00:00
Ian Lance Taylor
b6372114b2 cmd/go: correct function name in comment
Change-Id: I9d8056117367998c3723ec4cc09f47b46ec8b4ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/525855
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-05 21:59:53 +00:00
root
a40404da74 cmd/asm: add KMA and KMCTR instructions on s390x.
This CL is to add assembly instruction mnemonics for the following instructions, mainly used in crypto packages.

 * KMA    - cipher message with authentication
 * KMCTR  - cipher message with counter

Fixes #61163

Change-Id: Iff9a69911aeb4fab4bca8755b23a106eaebb2332
Reviewed-on: https://go-review.googlesource.com/c/go/+/515195
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-09-05 16:41:03 +00:00
Egon Elbre
a2647f08f0 compile/internal/walk: add walkGrowslice
Move growslice generation to a separate func so that specialization
logic can be shared.

Updates #49480

Change-Id: I9ea5bb898753622d2d767546a46b4db6410dc725
Reviewed-on: https://go-review.googlesource.com/c/go/+/495877
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-05 15:06:41 +00:00
Kir Kolyshkin
0e1a9e1867 syscall: fixup TestUseCgroupFD error checking
Fixup for CL 520265; of course errors returned from os/exec are wrapped.

While at it, change the order -- it seems more readable this way.

Change-Id: Ifb5d0c113f4fb2b3cc4be922021dbd2a8a886b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/524959
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-05 12:31:06 +00:00
Egon Elbre
1d84b02b22 runtime: introduce nextslicecap
This allows to reuse the slice cap computation across
specialized growslice funcs.

Updates #49480

Change-Id: Ie075d9c3075659ea14c11d51a9cd4ed46aa0e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/495876
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Egon Elbre <egonelbre@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-04 17:50:50 +00:00
Egon Elbre
c56f463412 runtime: optimize growslice
This is tiny optimization for growslice, which is probably too small to
measure easily.

Move the for loop to avoid multiple checks inside the loop.
Also, use >> 2 instead of /4, which generates fewer instructions.

Change-Id: I9ab09bdccb56f98ab22073f23d9e102c252238c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/493795
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Egon Elbre <egonelbre@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-04 17:50:46 +00:00
Jes Cok
778f5fc079 cmd/compile/internal/ssa: fix typos in comments
Change-Id: Idb09d68ce1e4823c8a330430e082d5c7ac2d8fc5
GitHub-Last-Rev: 5a2b71b21e
GitHub-Pull-Request: golang/go#62441
Reviewed-on: https://go-review.googlesource.com/c/go/+/525415
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-04 17:23:05 +00:00
Nikita Vaniasin
33d4a5105c net: respect hosts file when resolving names for Windows
Fixes #57757.

Change-Id: I896dae8e5905ae98539ab83c9379fd1c9886d44a
Reviewed-on: https://go-review.googlesource.com/c/go/+/467335
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-04 07:21:38 +00:00
Joe Tsai
5373959057 encoding: show the alphabet for base32 and base64
There is not a great reason to hide the alphabet used
for StdEncoding, HexEncoding, and URLEncoding.

Although this is specified in RFC 4748,
showing it in GoDoc saves an extra click from going
to the RFC itself to see the alphabet being used.

Also, split exported and unexported constants apart
so that GoDoc renders more cleanly.

Fixes #55126

Change-Id: I03bfa607fb6c3df7f757e33fc0f4ec2b233de1a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/525296
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
2023-09-03 18:57:29 +00:00
zhangjian
05d4b57c9f cmd/compile/internal/liveness: remove excess bits for stackmap
ArgWidth() already includes the stack space required for
input parameters and return values, so their offset will
not exceed the value of ArgWidth(), so there is no need
to double it.

Change-Id: I10fde7afbf2a5714b5142075c2116af14debc7e8
GitHub-Last-Rev: eaf3fd5eb8
GitHub-Pull-Request: golang/go#60591
Reviewed-on: https://go-review.googlesource.com/c/go/+/500675
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: guangyuan zhou <zhouguangyuan@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-03 15:46:21 +00:00
Kir Kolyshkin
e7fbd28a4d syscall: inline TestUseCgroupFDHelper
This way, the test case is self-contained, and the test output no longer
has useless lines related to TestUseCgroupFDHelper.

Change-Id: I575a03b678c8c08a87353f6dc00c35a90ec561ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/525196
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-03 13:53:50 +00:00
cui fliter
0cd473d97a cmd: fix some comments
Change-Id: I8b3eb51e31139314d222d796b56ab7d42338797f
Reviewed-on: https://go-review.googlesource.com/c/go/+/525315
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2023-09-02 22:09:21 +00:00
Jes Cok
83fe0e093d encoding/gob: add comma in field comment of userTypeInfo for consistency
Change-Id: I80c494a357195dad3ade98fcce0a6883303777ce
GitHub-Last-Rev: a30615f373
GitHub-Pull-Request: golang/go#62422
Reviewed-on: https://go-review.googlesource.com/c/go/+/524998
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-02 02:18:51 +00:00
Joe Tsai
8b88d58042 compress: linkify references to io.ByteReader
The special treatment of io.ByteReader is somewhat significant.
Linkify references to that type from documentation.

Change-Id: I77c06e4c6b957d107638e2ff2a4c58148b396ed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/525016
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
2023-09-01 23:31:15 +00:00
Joe Tsai
c700c23cef reflect: make Value.IsZero identical to v == zero
The upcoming built-in zero value provides an idiomatic way
to test for zero by comparing to the zero literal: v == zero.

The reflect package is meant to provide a programmatic way to perform
operations that the Go language itself provides.
Thus, it seems prudent that reflect.ValueOf(&v).Elem().IsZero() is
identical to v == zero.

This change alters the behavior of Value.IsZero in two concrete ways:
* negative zero is identical to zero
* blank fields in a struct are ignored

Prior to this change, we were already in an inconsistent state
due to a regression introduced by CL 411478.
The new behavior was already the case for comparable composite types.
This change makes it consistent for all other types
(in particular incomparable composite types and standalone numbers).

Updates #61372
Fixes #61827

Change-Id: Id23fb97eb3b8921417cc75a1d3ead963e22dc3d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/517777
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-01 23:20:30 +00:00
Mauri de Souza Meneguzzo
7015ed891c sync: prevent (*Map).Range from always escaping
After the change from CL 426074 the Range method on Map always
escape the read variable, leading to an allocation.

Since the compiler doesn't do live-range splitting for local variables we
need to use some hints to only escape in that particular branch.

Fixes #62404

Change-Id: I938a5e593647455fa827e3dd3ed8ea22c7365df1
GitHub-Last-Rev: fcbedb467c
GitHub-Pull-Request: golang/go#62408
Reviewed-on: https://go-review.googlesource.com/c/go/+/524976
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-01 22:41:39 +00:00
Matthew Dempsky
227ec02824 cmd/internal/dwarf: replace Sym.Length with Context.Size
Preparatory refactoring before next CL.

Change-Id: I06fb4670b933fddff1a2a70f3cf1eb124cbd86ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/524899
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-01 20:40:28 +00:00
Matthew Dempsky
9b0140a695 cmd/link: type alias sym.LoaderSym and loader.Sym
Rather than making these two different types, we can type alias them
together. This will ease converting cmd/internal/dwarf to use generics
in a subsequent CL.

The one unfortunate quirk is that while we'd currently like loader.Sym
to be the authoritative type, to break the cycle we have to instead
make loader.Sym an alias of sym.LoaderSym.

Change-Id: I6dde0d492ca89a478c2470c426bb4eed3393d680
Reviewed-on: https://go-review.googlesource.com/c/go/+/525195
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-01 20:39:56 +00:00
Matthew Dempsky
c9bb7ce2d7 cmd/internal/obj: simplify filename handling
The old Go object file format used linker symbols like "gofile..foo"
to record references to the filename "foo". But the current object
file format has a dedicated section for file names, so we don't need
these useless prefixes anymore.

Also, change DWARF generation to pass around the src.Pos directly,
rather than the old file symbols, which it just turned back into a
file index before writing out anyway.

Finally, directly record the FileIndex into src.PosBase, so that we
can skip the map lookups.

Change-Id: Ia4a5ebfa95da271f2522e45befdb9f137c16d373
Reviewed-on: https://go-review.googlesource.com/c/go/+/523378
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-09-01 15:52:41 +00:00
Guoqi Chen
06f420fc19 runtime: remove the meaningless offset of 8 for duffzero on loong64
Currently we subtract 8 from offset when calling duffzero because 8
is added to offset in the duffzero implementation. This operation is
meaningless, so remove it.

Change-Id: I7e451d04d7e98ccafe711645d81d3aadf376766f
Reviewed-on: https://go-review.googlesource.com/c/go/+/487295
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-01 15:48:45 +00:00
Bryan C. Mills
e3ef8d1810 net: deflake TestDialTimeout on windows
The time granularity on windows is large enough that setting even an
implausibly small timeout still gives ConnectEx enough time to succeed
before the timeout expires. That causes TestDialTimeout to sometimes
flake, because it expects to be able to provoke a timeout using some
nonzero duration.

This change takes a two-pronged approach to address the problem:

1. We can set a deadline on the FD more aggressively. (If the Context
has already expired, or the deadline is already known, we can go ahead
and set it on the fd without waiting for a background goroutine to get
around to it.)

2. We can reintroduce a test hook to ensure that Dial takes a
measurable amount of time before it completes, so that setting an
implausibly short deadline sets that deadline in the past instead of
the future.

Together, these reduce the flake rate on a windows-amd64-longtest
gomote from around 1-in-10 to less than 1-in-2000.

For #62377.

Change-Id: I03975c32f61fffa9f6f84efb3c474a01ac5a0d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524936
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-01 15:17:54 +00:00
Dominique Lefevre
b4c889b561 cmd/internal/objabi: rename R_USEGENERICIFACEMETHOD to R_USENAMEDMETHOD.
Now we have two cases when we want to keep methods with a specific name:
calls to generic interface methods and MethodByName("Foo"). Both use
the same relocation type, so let us give it a name that is not limited
to the implementation of generic interfaces.

Also, introduce staticdata.StrSymNoCommon(). It creates a symbol that
does not appear in the final binary and only communicates arguments
to the linker.

Change-Id: Icc9f49febfde1f31a4455b5acb903e8838d1c0af
Reviewed-on: https://go-review.googlesource.com/c/go/+/523016
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-09-01 15:08:50 +00:00
Dominique Lefevre
bb74a53c21 cmd/link: add testcases for MethodByName(string literal).
Change-Id: I96ea268ecceea75a24303526ed2f17c8a5e142c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/522438
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-09-01 15:07:26 +00:00
Dominique Lefevre
6b52bfa393 cmd/link: remove special cases for Method() and MethodByName().
There is no more need to do this in the linker. The compiler now
handles both Type.Method() and Value.Method(), and flags their
users as ReflectMethod.

Change-Id: Ice93d5d975a1b93a324471e8abdebdce141d17d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/522437
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-01 15:07:16 +00:00
Dominique Lefevre
e802f211b0 cmd/compile: special-case MethodByName(string literal) to keep the DCE enabled.
Normally, a call to MethodByName() disables the DCE because the linker
assumes that any method can be accessed this way. This pessimises
the code generation for k8s.io/apimachinery which needs MethodByName()
to verify whether or not a struct implements DeepCopyInto(). It cannot
cast a struct to `interface { DeepCopyInto() Foo }` because the return
type may vary. Instead, it does the following:

  if m := reflect.ValueOf(obj).MethodByName("DeepCopyInto"); ... {

In this case there is no need to disable the DCE altogether. It
suffices to add a relocation to keep methods named DeepCopyInto().

Fixes #62257.

Change-Id: I583c2f04d8309a8807de75cd962c04151baeeb1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522436
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-01 15:06:51 +00:00
Cosmos Nicolaou
660feea72f runtime/pprof: print stderr on test failure
Print Stderr on test failure to track down the intermittent
test failure reported in issue #62352.

Change-Id: I547a3220dc07d05578dac093d6c028a9103b552a
Reviewed-on: https://go-review.googlesource.com/c/go/+/524156
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-01 14:55:55 +00:00
Kir Kolyshkin
38b623f42d syscall: fix skipping TestUseCgroupFD
The check in prepareCgroupFD tried to find out if clone3 with
CLONE_INTO_CGROUP flag is supported, by supplying arguments in
SysProcAttr that will make ForkExec use clone3 with CLONE_INTO_CGROUP
and fail.

CL 456375 inadvertently broke the above check by adding more errno
values to ignore. As a result, TestUseCgroupFD is always skipped, even
when the test could in fact be run.

Fix by removing the check entirely, instead let's use the functionality
and figure out from the errno if this has failed because of unsupported
syscall, lack of permissions, or other reason.

Change-Id: I108b27b6cfeec390ebd3f161ac39e8597569b666
Reviewed-on: https://go-review.googlesource.com/c/go/+/520265
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-01 04:33:32 +00:00
Matthew Dempsky
62fb281cf7 bytes, strings: use "reports whether" in HasPrefix and HasSuffix
Update the doc comments to use the more idiomatic and common phrase
"reports whether" instead of "tests whether".

Change-Id: I2b7f8cce2d192f66e296ebaa9b37f37e8276b4ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/524898
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-01 04:29:02 +00:00
Robert Griesemer
7a4787d12a go/types, types2: fix doc string
Change-Id: I9ab93c90d128d0abd0c84c7520f8c72983fee79b
Reviewed-on: https://go-review.googlesource.com/c/go/+/524975
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-31 23:57:29 +00:00
Jes Cok
ffc4ccea07 cmd/compile/internal/types2: use strings.ReplaceAll for goTypeName
strings.ReplaceAll is currently available.

Change-Id: I111b97f12723c97791b59d81fd035a0d5e97cd4b
GitHub-Last-Rev: 561dbab6d2
GitHub-Pull-Request: golang/go#62369
Reviewed-on: https://go-review.googlesource.com/c/go/+/524157
Reviewed-by: Ian Lance Taylor <iant@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: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-31 21:14:38 +00:00
Tobias Klauser
9dea791a7a net: remove unused errTimedout
It's unused since CL 524055.

Change-Id: I767eac6a66379e67337e24051e5f79aa027e9fad
Reviewed-on: https://go-review.googlesource.com/c/go/+/524715
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-31 16:59:22 +00:00
qmuntal
cab416f339 runtime: remove unnecessary timeout in TestCallbackInAnotherThread
Waiting only for 100ms might be not enough for the callback to be
called. It is more reliable to wait infinitely and rely on the
test timeout to fail the test if the callback is not called.

Fixes #62206

Change-Id: I06b5eadae1dd334a2afc41af31a44b42cb5e596d
Reviewed-on: https://go-review.googlesource.com/c/go/+/524695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2023-08-31 16:31:35 +00:00