1
0
mirror of https://github.com/golang/go synced 2024-11-26 12:58:06 -07:00
Commit Graph

54012 Commits

Author SHA1 Message Date
Matthew Dempsky
10ffb27528 test: add failing test case for inlined type switches
The unified frontend ICEs when inlining a function that contains a
function literal, which captures both a type switch case variable and
another variable.

Updates #54912.

Change-Id: I0e16d371ed5df48a70823beb0bf12110a5a17266
Reviewed-on: https://go-review.googlesource.com/c/go/+/428917
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07 17:26:34 +00:00
Matthew Dempsky
2c45feb4d7 test: fix typo in escape_unsafe.go
The toStringData test was meant to test reflect.StringHeader, not
reflect.SliceHeader. It's not supported to convert *string to
*reflect.SliceHeader anyway.

Change-Id: Iaa4912eafd241886c6337bd7607cdf2412a15ead
Reviewed-on: https://go-review.googlesource.com/c/go/+/428995
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07 17:25:59 +00:00
Joe Tsai
cdb270cf07 reflect: fix stale Value.kind documentation
The lowests fives bits are the kind, and the next five bits are attributes,
not the other way around.

Change-Id: I5e1d13b195b766e99f66bb1227cc7f84e85dc49d
Reviewed-on: https://go-review.googlesource.com/c/go/+/425185
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2022-09-07 16:41:47 +00:00
Michael Pratt
027ff3f47d debug/gosym: rename nameoff to nameOff to match runtime
Change-Id: Id33526e56bb25bc06746355f95045c5ef3c795c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/428660
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-09-07 16:39:44 +00:00
Michael Pratt
3e75859390 cmd/link/internal/ld: update _func names to match runtime
Change-Id: I4a47f676c0e533f7612fc3eb1b5dd8039f72782f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428659
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-09-07 16:37:07 +00:00
Sean Liao
7033275e37 .github: update issue label for pkgsite-removal
Change-Id: Ie90013077068b8e61bd651f2e686b06b6dad9fc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410454
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 16:00:20 +00:00
Michael Pratt
7ebaa6587b runtime: rename _func.entryoff to entryOff
To match _func.nameOff.

Change-Id: I75e71cadaa0f7ca8844d1b49950673797b227074
Reviewed-on: https://go-review.googlesource.com/c/go/+/428658
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-09-07 15:42:49 +00:00
cuiweixie
df9d53d93b cmd/vet: use strings.Builder
Change-Id: I583e167dac033037e82e55a9ae6c6f0c47a34c7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428293
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-07 15:29:51 +00:00
Michael Pratt
196003f9fd runtime: rename _func.nameoff and friends to nameOff
Switch to the more Go-style name to match inlinedCall.nameOff.

Change-Id: I2115b27af8309e1ead7d61ecc65fe4fc966030f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428657
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-07 15:11:05 +00:00
Michael Pratt
d81ed4d621 runtime: rename inlinedCall.func_ to inlinedCall.nameOff
The meaning of this field is unchanged, this CL simply gives it a more
descriptive name, as func_ makes it sound like a reference to the _func.

Change-Id: I70e54f34bede7636ce4d7b9dd0f7557308f02143
Reviewed-on: https://go-review.googlesource.com/c/go/+/427961
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 14:47:36 +00:00
Jinzhu
0752f4a12c database/sql: simplify retry logic when the connection is bad
Simplify retry logic when got bad connection

Change-Id: I92494c6c020576ec01bc4868334ee920ded7aa57
GitHub-Last-Rev: 7499b0c941
GitHub-Pull-Request: golang/go#54043
Reviewed-on: https://go-review.googlesource.com/c/go/+/419182
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 14:33:56 +00:00
Kir Kolyshkin
88149ed43e os: fix wrong error msg from TestReadClosed
If test would fail, the error message will have wrong error and its
type, because e is used after the failed type assertion.

To fix, use the original err.

While at it,
 - combine the checks for error type and value into one statement;
 - use the standard "got ..., want ..." format.

Fixes: 212d2f82e0 ("os: add ErrClosed, return for use of closed File")
Change-Id: I862a96607b461ab89cce6bed2443b28aa2c16468
Reviewed-on: https://go-review.googlesource.com/c/go/+/428915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-07 13:59:41 +00:00
Cuong Manh Le
5a96386922 test: add regression test for issue 54911
It was fixed by CL 422196, and have been already worked in unified IR.

Fixes #54911

Change-Id: Ie69044a64b296f6961e667e7661d8c4d1a24d84e
Reviewed-on: https://go-review.googlesource.com/c/go/+/428758
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-09-07 13:58:00 +00:00
cui fliter
2e1f98e3a1 go/parser: use strings.Builder
Change-Id: Ic8078543eb80470505a3cc2da8ea9fb8fb1369aa
GitHub-Last-Rev: 7b358c685a
GitHub-Pull-Request: golang/go#54919
Reviewed-on: https://go-review.googlesource.com/c/go/+/428922
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 13:57:12 +00:00
cuiweixie
c75d19732d reflect: use strings.Builder
Change-Id: Ie100a2a6f272b84fa2da6ac7b64452985242d788
Reviewed-on: https://go-review.googlesource.com/c/go/+/428275
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: Michael Knyszek <mknyszek@google.com>
2022-09-07 13:56:11 +00:00
cuiweixie
82d1019c60 net/textproto: use strings.Builder
Change-Id: I2ed993a804dd830b9ff445c467eb224b7aaa3401
Reviewed-on: https://go-review.googlesource.com/c/go/+/428273
Reviewed-by: Michael Knyszek <mknyszek@google.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>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 13:55:46 +00:00
Ian Lance Taylor
b53471a655 Revert "sync: convert Once.done to atomic type"
This reverts commit CL 427140.

Reason for revert: Comments say that done should be the first field.

Change-Id: Id131da064146b44e1182289546aeb877867e63cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428638
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 13:22:04 +00:00
cuiweixie
ed530dbd07 testing: use strings.Builder
Change-Id: Ied8a3019f1e21c0e74c798d2b1b279a606a38554
Reviewed-on: https://go-review.googlesource.com/c/go/+/428279
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07 07:03:10 +00:00
cuiweixie
f4bf9bceac runtime: use strings.Builder
Change-Id: I9274d36ca983fdf59088b71a97b139ea262370dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428276
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-09-07 07:02:51 +00:00
cuiweixie
6375f508a8 os: use strings.Builder
Change-Id: I610509aa35c345ff7fbb1fc94bf177ffbe934731
Reviewed-on: https://go-review.googlesource.com/c/go/+/428274
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: Benny Siegert <bsiegert@gmail.com>
2022-09-07 06:18:48 +00:00
cuiweixie
e2d8ed2fd7 net/smtp: use strings.Builder
Change-Id: I0d1195fcb4eceb12c4be3190b05a82079dc496a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428272
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 06:18:03 +00:00
cuiweixie
6a2ff105f1 unicode/utf8: use strings.Builder
Change-Id: I88b55f61eccb5764cac2a9397fd99a62f8735a9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/428281
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-09-07 06:17:15 +00:00
Joel Sing
77da976419 cmd/compile: remove redundant SEQZ/SNEZ on riscv64
In particular, (SEQZ (SNEZ x)) can arise from (Not (IsNonNil x)).

Change-Id: Ie249cd1934d71087e0f774cf8f6c937ceeed7ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/428215
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07 05:39:23 +00:00
Joel Sing
b6a6847b2f cmd/compile: avoid zero extension after properly typed atomic operation on riscv64
LoweredAtomicLoad8 is implemented using MOVBU, hence it is already zero
extended. LoweredAtomicCas32 and LoweredAtomicCas64 return a properly
typed boolean.

Change-Id: Ie0acbaa19403d59c7e5f76d060cc13ee51eb7834
Reviewed-on: https://go-review.googlesource.com/c/go/+/428214
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
2022-09-07 05:38:50 +00:00
Joel Sing
c011270fa5 cmd/compile: improve Slicemask on riscv64
Implement Slicemask the same way every other architecture does - negate
then arithmetic right shift. This sets or clears the sign bit, before
extending it to the entire register.

Removes around 2,500 instructions from the Go binary on linux/riscv64.

Change-Id: I4d675b826e7eb23fe2b1e6e46b95dcd49ab49733
Reviewed-on: https://go-review.googlesource.com/c/go/+/426354
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 05:37:53 +00:00
cuiweixie
ba1ef54c1e syscall: simplify code using unsafe.Slice
Updates #54854

Change-Id: Ibaf4eea14a6259cdbca79e9e95db1602966f18e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/428176
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 01:48:31 +00:00
cuiweixie
4fe4601d37 runtime: simplify code using unsafe.{Slice,String}
Updates #54854

Change-Id: Ie18665e93e477b6f220acf4c6c070b2af4343064
Reviewed-on: https://go-review.googlesource.com/c/go/+/428157
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-07 01:48:30 +00:00
cuiweixie
2ee075dc47 strings: simplify code using unsafe.StringData
Updates #54854

Change-Id: I93396dc92bd2decba895f2d059e1aeffcd22312c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428158
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-07 01:33:55 +00:00
cuiweixie
92b8f4e293 internal/fuzz: simplify code using unsafe.{SliceData,Slice}
Updates #54854

Change-Id: If70b11c0fc920b7214fcff249da9e3c4ac1de991
Reviewed-on: https://go-review.googlesource.com/c/go/+/428156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-09-07 01:33:53 +00:00
cuiweixie
2a627afe13 bytes: simplify code using unsafe.SliceData
Updates #54854

Change-Id: I9c14f9fa595f73eae44eb714abc5d486915893c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/428155
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@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>
2022-09-07 01:33:52 +00:00
cuiweixie
502504f433 cmd/compile/internal/ssagen: use strings.Builder
Change-Id: I840262eefff1073a452a243b9e31f61b53362fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/428360
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 01:30:12 +00:00
cuiweixie
095b6f050f cmd/compile/internal/ssa: use strings.Builder
Change-Id: Ieb15b54d36f18d1fbccbafe5451a4758df797718
Reviewed-on: https://go-review.googlesource.com/c/go/+/428359
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@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>
2022-09-07 01:29:43 +00:00
cuiweixie
431446d0a0 cmd/compile/internal/pkginit: use strings.Builder
Change-Id: If675277e17b97500100e46ec6fe471260131bafc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428358
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-07 01:29:20 +00:00
cuiweixie
1429a97520 cmd/compile/internal/ir: use strings.Builder
Change-Id: I24fb36a0591782c07f26c3289265aa41a643666d
Reviewed-on: https://go-review.googlesource.com/c/go/+/428357
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-07 01:28:55 +00:00
cuiweixie
db9e549fd2 crypto/x509/internal/macos: simplify code using unsafe.{SliceData,StringData}
Updates #54854

Change-Id: I8a64a1176cbe16489e1fd21c66a7abc7d8b8e9b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428154
Run-TryBot: Bryan Mills <bcmills@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: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-07 01:27:54 +00:00
Andy Pan
ccf82d5323 net: fix a typo in BenchmarkSendFile
Change-Id: Ic463bd6d52e7d1d50d2dbd2122b4d514e0b4af60
Reviewed-on: https://go-review.googlesource.com/c/go/+/428755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-07 01:09:59 +00:00
cuiweixie
bfadd78986 net/rpc/jsonrpc: use strings.Builder
Change-Id: I251f734adbaf83aa03e3f4f37add4e116f5af093
Reviewed-on: https://go-review.googlesource.com/c/go/+/428271
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@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>
2022-09-07 01:09:53 +00:00
Kir Kolyshkin
2b8f214094 os/exec: LookPath: use eaccess for exec check on linux
Having an executable bit set for a binary is not enough for it to be
executable -- there might be more checks in the kernel. For example,
binaries on a filesystem mounted with "noexec" flag couldn't be
executed. There might be other scenarios involving ACLs, SELinux,
file capabilities, and so on.

As a result, LookPath might either find a non-executable (while going
over $PATH elements), or return a false positive that the argument
provided is an executable.

One possible fix would be to perform the check by using access(2)
syscall with X_OK flag.

Now, since access(2) uses real (rather than effective) uid and gid,
when used by a setuid or setgid binary, it checks permissions of the
(real) user who started the binary, rather than the actual effective
permissions. Therefore, using access with X_OK won't work as expected
for setuid/setgid binaries.

To fix this, modern platforms added ways to check against effective uid
and gid, with the most common being the faccessat(2) call with the
AT_EACCESS flag, as described by POSIX.1-2008 (in Linux, only
faccessat2(2) supports flags such as AT_EACCESS). Let's use it, and fall
back to checking permission bits if faccessat is not available.

Wrap the logic into unix.Eaccess, which is currently only implemented on
Linux. While many other OSes (Free/Net/OpenBSD, AIX, Solaris/Illumos, and
Darwin) do implement faccessat(2) with AT_EACCESS, it is not wired in
syscall package (except for AIX), so these platforms are left out for now.
In the future, eaccess can be implemented for these OSes, too.

Alas, a call to unix.Eaccess is not enough since we have to filter out
directories, so use both stat and Eaccess.

One minor change introduced by this commit is that LookPath and Command
now returns "is a directory" error when the argument contains a slash
and is a directory.  This is similar to what e.g. bash does on Linux:

	$ bash -c /etc
	bash: line 1: /etc: Is a directory

Add a test case, which, unfortunately, requires root, is specific to
Linux, and needs a relatively new kernel (supporting faccessat2).  Other
platforms either have different semantics for tmpfs with noexec, or have
different ways to set up a binary which has x bit set but nevertheless
could not be executed.

Change-Id: If49b6ef6bf4dd23b2c32bebec8832d83e511a4bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/414824
Reviewed-by: Ian Lance Taylor <iant@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: Bryan Mills <bcmills@google.com>
2022-09-07 01:09:45 +00:00
cuiweixie
403e5f1cb1 net/http: use strings.Builder
Change-Id: I754edcf21e003a3f4037fb2c5d8d06f2cd5f2fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428267
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-09-07 01:07:32 +00:00
cuiweixie
8fd2073694 net: use strings.Builder
Change-Id: I3861a73d6b9d1d454c42bec50099b916bf30f1cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428266
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2022-09-07 00:49:41 +00:00
Damien Neil
29af494fca all: update vendored golang.org/x/net
Pull in security fix:

    f3363e06e7 http2: handle server errors after sending GOAWAY

Fixes CVE-2022-27664
Fixes golang/go#54658

Change-Id: Ie1f58a8d769c7fd75c67d202c611a3abfd7dbb35
Reviewed-on: https://go-review.googlesource.com/c/go/+/428717
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2022-09-06 23:07:55 +00:00
Michael Pratt
c83e1b6d5b cmd/link,runtime: remove unused fields from inlinedCall
The parent, file, and line fields are no longer used now that we have
parentPc to find the parent and NOPs in the parent to attach file/line
pcdata to.

Removing these fields reduces the binary size of cmd/go on linux-amd64
by 1.1%.

Fixes #54849.

Change-Id: If58f08622736b2b322288608776f8bedf0c3fd17
Reviewed-on: https://go-review.googlesource.com/c/go/+/427960
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-06 22:23:43 +00:00
Cuong Manh Le
c82304b712 cmd/compile: do not devirtualize defer/go calls
For defer/go calls, the function/method value are evaluated immediately.
So after devirtualizing, it may trigger a panic when implicitly deref
a nil pointer receiver, causing the program behaves unexpectedly.

It's safer to not devirtualizing defer/go calls at all.

Fixes #52072

Change-Id: I562c2860e3e577b36387dc0a12ae5077bc0766bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/428495
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-06 22:14:56 +00:00
zhangyunhao
812fd2fe70 cmd/compile: gofmt comments
Change-Id: I79634efbd8d0189afdfe22e147d63c889e8047ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/427964
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-06 22:14:14 +00:00
Sean Liao
90f04dd461 net/http: clarify proxy selection from environment
For #40909
Fixes #54890

Change-Id: I00218bc1606eedb6194a3a7b81fd4d3f75325280
Reviewed-on: https://go-review.googlesource.com/c/go/+/428775
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
2022-09-06 22:13:54 +00:00
cuiweixie
86f8b8d3f2 cmd/compile/internal/syntax: use strings.Builder
Change-Id: Ic18d12b3d1c2f4819f2656371537df797e9970ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/428361
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-06 21:53:23 +00:00
cuiweixie
50bb42a46f net/http: using strings.Builder
Change-Id: I5d4c89a8d87a8697d038bf91b17d7ffc847a49c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428137
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-06 21:52:12 +00:00
cuiweixie
11c5bf521e go/doc: using strings.Builder
Change-Id: I9658c37a548a386c57d83dc13d5e9925a9c13211
Reviewed-on: https://go-review.googlesource.com/c/go/+/428140
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-06 21:50:52 +00:00
cuiweixie
a8237ba61a go/ast: using strings.Builder
Change-Id: I05ebaf4e11b5b6ca7d9bbb0b2241def7773b11cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428138
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
2022-09-06 21:50:49 +00:00
Cuong Manh Le
ef69718dd7 all: make sure *Pointer[T]'s methods are inlined as intended
Updates #50860

Change-Id: I65bced707e50364b16edf4b087c541cf19bb1778
Reviewed-on: https://go-review.googlesource.com/c/go/+/428362
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-06 18:16:03 +00:00