1
0
mirror of https://github.com/golang/go synced 2024-09-29 09:14:29 -06:00
Commit Graph

51755 Commits

Author SHA1 Message Date
Cherry Mui
d8bee94be2 reflect, runtime: drop RegabiArgs conditions
With the previous CL, internal/abi.IntArgRegs and FloatArgRegs
is controlled by RegabiArgs (or always enabled), so there is no
need to check for that goexperiment.

There are a few places we guard register-ABI specific code and
tests with the RegabiArgs flag. Switch to checking for the number
of argument registers instead.

Change-Id: I79fff9fd1e919684ffaf73aba9e7e85d5a9e1629
Reviewed-on: https://go-review.googlesource.com/c/go/+/393363
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-18 15:17:37 +00:00
Cherry Mui
3684abbf6c all: delete regabireflect goexperiment
regabireflect goexperiment was helpful in the register ABI
development, to control code paths for reflect calls, before the
compiler can generate register ABI everywhere. It is not necessary
for now. Drop it.

Change-Id: I2731197d2f496e29616c426a01045c9b685946a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/393362
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-03-18 14:45:56 +00:00
Tobias Klauser
12eca21f1c syscall: use bytealg.IndexByte in clen
Change-Id: Ib3f92ea8371a13471acf9304dc9db66c0aae9bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/393756
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-18 12:07:27 +00:00
Changkun Ou
4432059485 A+C: update Changkun Ou's email
Add my current public email in both A+C, but keep old one too.
Add my @changkun.de email to CONTRIBUTORS.

Change-Id: Ic5a585582a5f5142fbdd0a132235c19f05d9e680
Reviewed-on: https://go-review.googlesource.com/c/go/+/367116
Run-TryBot: Changkun Ou <mail@changkun.de>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ben Shi <powerman1st@163.com>
2022-03-18 09:40:34 +00:00
Nuno Cruces
f02108636c runtime: allow TestCtrlHandler to run in ConPTY
Fixes #51602. Previous test would not run in a pseudo-console (ConPTY).

New test avoids taskkill entirely by having the child request its own
console window be closed.

Verified that this runs locally (within a real console), over SSH
(within a pseudo-console), and that it breaks if #41884 were reverted.

Change-Id: If868b92ec36647e5d0e4107e29a2a6e048d35ced
GitHub-Last-Rev: b1421e4bed
GitHub-Pull-Request: golang/go#51681
Reviewed-on: https://go-review.googlesource.com/c/go/+/392874
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
2022-03-18 07:37:53 +00:00
Tobias Klauser
3d19e8da79 syscall: unskip TestDirentRepeat on freebsd
TestDirentRepeat fails on FreeBSD 11, but seems to pass on newer
versions. Go 1.18 is the last release to support FreeBSD 11 per
https://golang.org/doc/go1.18#freebsd and there are no FreeBSD 11
builders anymore. Thus unskip TestDirentRepeat to verify the issue is
indeed fixed on FreeBSD 12 and later.

For #31416

Change-Id: I189ef06719ff830ffe2e402c74a75874c9e5b97b
Reviewed-on: https://go-review.googlesource.com/c/go/+/393618
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-18 06:03:39 +00:00
Tobias Klauser
adfee1e1e7 runtime/cgo: remove memset in _cgo_sys_thread_start on freebsd/arm
pthread_attr_init on freebsd properly initializes the pthread_attr,
there is no need to zero it before the call. The comment and code were
probably copied from the linux/arm implementation.

This aligns the implementation on freebsd/arm with the implementation on
other freebsd architectures.

Fixes #44248

Change-Id: If82ebb115b877b6c6f4862018a9419ba8d870f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/393617
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
2022-03-18 06:03:19 +00:00
Tobias Klauser
489102de18 syscall: optimize UTF16{,Ptr}FromString
Use bytealg.IndexByteString in UTF16FromString instead of an open-coded
loop.

Change-Id: I366448382f2d0adeca6b254131e0087a1f489258
Reviewed-on: https://go-review.googlesource.com/c/go/+/393614
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-18 05:55:52 +00:00
cuiweixie
3ea22cf3c4 crypto/x509: return err ans1.Marshal gives an error
Fixes #50663

Change-Id: I18754922bf139049443c0395eaa1606049df1331
GitHub-Last-Rev: 57ff5ddfe3
GitHub-Pull-Request: golang/go#50667
Reviewed-on: https://go-review.googlesource.com/c/go/+/379094
Reviewed-by: Katie Hockman <katie@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-18 04:28:47 +00:00
Matt Layher
485d67bd38 A+C: add PlanetScale, Inc.
Change-Id: Ide2567dc66e55880b938b5814879f012c88159b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/393697
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Matt Layher <mdlayher@gmail.com>
2022-03-18 01:28:47 +00:00
Ian Lance Taylor
2d32594396 runtime: call testenv.MustHaveCGO in a couple of tests
Fixes #51695

Change-Id: Icfe9d26ecc28a7db9040d50d4661cf9e8245471e
Reviewed-on: https://go-review.googlesource.com/c/go/+/392916
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-03-18 00:49:08 +00:00
fangguizhen
3d7392a08f net/rpc: reduce the execution of reflect and decode
Change-Id: Ief4b5e1c2d1002392901124c0694afe58c271573
GitHub-Last-Rev: e3b8a60377
GitHub-Pull-Request: golang/go#46421
Reviewed-on: https://go-review.googlesource.com/c/go/+/323014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2022-03-18 00:39:23 +00:00
Heschi Kreinick
79861be205 all: update vendored x dependencies for Go 1.19 development cycle
Generated with x/build/cmd/updatestd.

Updates #36905.

Change-Id: I5d12dfc3b49c1476ce4b8d4cbeb35bd3d3443d26
Reviewed-on: https://go-review.googlesource.com/c/go/+/393369
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 20:32:25 +00:00
Bryan C. Mills
3046ae927d cmd/doc: use the 'go' command from buildCtx.GOROOT, not whatever is in $PATH
For #51483.

Change-Id: I6150fdf97763d858e9ab012e807515da3387c25f
Reviewed-on: https://go-review.googlesource.com/c/go/+/393366
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 20:09:38 +00:00
Bryan C. Mills
2b0ac284cf cmd/doc: use 'go env' to identify GOROOT if it isn't otherwise known
Updates #51483.

Change-Id: I13d8e58b30639d8a5ed3c9e8b72c8bbaa6a6f1cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/391813
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 20:09:18 +00:00
Bryan C. Mills
c6244b5909 runtime/debug: do not require a GOROOT/src prefix in TestStack
When paths are trimmed, the reported file locations begin with the
package import path (not GOROOT/src).

Updates #51461.

Change-Id: Ia6814f970aee11f3d933e75c75136d679d19e220
Reviewed-on: https://go-review.googlesource.com/c/go/+/391815
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 19:24:19 +00:00
Brad Fitzpatrick
0fca8a8f25 crypto/x509: fix Certificate.Verify crash
(Primarily from Josh)

Fixes #51759

Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com>
Change-Id: I0a6f2623b57750abd13d5e194b5c6ffa3be6bf72
Reviewed-on: https://go-review.googlesource.com/c/go/+/393655
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 17:42:32 +00:00
fanzha02
c379c3d58d cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled
When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

Change-Id: I6281e77f6ba581d7008d610f0b24316078b6e746
Reviewed-on: https://go-review.googlesource.com/c/go/+/393315
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Run-TryBot: Fannie Zhang <Fannie.Zhang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2022-03-17 08:43:51 +00:00
Fannie Zhang
599d5395eb Revert "cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled"
This reverts commit 5fd0ed7aaf.

Reason for revert: <The internal information in commit message is not removed.>

Change-Id: Id6845a9c8114ac71c56a1007a4d133a560a37fbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/393314
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2022-03-17 08:43:15 +00:00
Robert Griesemer
9956a5423e text/scanner: guard against installed IsIdentRune that accepts EOF
IsIdentRune may be installed by a client of the scanner. If the
installed function accepts EOF as a valid identifier rune, Scan
calls may not terminate.

Check for EOF when a user-defined IsIdentRune is used.

Fixes #50909.

Change-Id: Ib104b03ee59e2d58faa71f227c3b51ba424f7f61
Reviewed-on: https://go-review.googlesource.com/c/go/+/393254
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17 03:41:50 +00:00
Russ Cox
8427429c59 os: raise open file rlimit at startup
Some systems set an artificially low soft limit on open file count,
for compatibility with code that uses select and its hard-coded
maximum file descriptor (limited by the size of fd_set).

Go does not use select, so it should not be subject to these limits.
On some systems the limit is 256, which is very easy to run into, even
in simple programs like gofmt when they parallelize walking a file tree.

After a long discussion on go.dev/issue/46279, we decided the best
approach was for Go to raise the limit unconditionally for itself, and
then leave old software to set the limit back as needed. Code that
really wants Go to leave the limit alone can set the hard limit, which
Go of course has no choice but to respect.

Take 2, after CL 392415 was rolled back for macOS and OpenBSD failures.
The macOS failures should be handled by the new call to sysctl("kern.maxfilesperproc"),
and the OpenBSD failures are handled by skipping the test (and filing #51713).

Fixes #46279.

Change-Id: I45c81b94590b447b483018a05ae980b8f02dc5de
Reviewed-on: https://go-review.googlesource.com/c/go/+/393354
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 03:04:30 +00:00
Josh Bleecher Snyder
f839aaa22b syscall: allow EINVAL in TestSCMCredentials
This can occur on NixOS.

Change-Id: I0571b0cc5345d01396dca6a4116aa1024c390a5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393437
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17 02:43:05 +00:00
Cherry Mui
66865363f0 syscall: call ABI0 exitsyscall on Plan 9/AMD64
CL 376356 changes syscall.Syscall to call ABIInternal entersyscall
and exitsyscall. As mentioned in the CL description, it is
important to call entersyscall without ABI wrapper, but it is not
important to call exitsyscall this way. In fact, it is actually
problematic -- on Plan 9, syscall may clobber our fixed G register,
and we did not restore it. This CL changes it back to ABI0
exitsyscall, which will restore the G register through the wrapper.

Should fix Plan 9/AMD64 build.

Change-Id: I1f03d553f03e7b9f36d64686f20f2b2df0a0bf79
Reviewed-on: https://go-review.googlesource.com/c/go/+/393494
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-03-17 01:29:17 +00:00
Matthew Dempsky
1cfe1007cd cmd/compile: remove typecheckdef and Name.Walkdef
The only remaining use for typecheckdef after CL 393256 is to
typecheck the ONAME node that represents function names, so we might
as well just move that code into tcFunc instead.

Updates #51691.

Change-Id: Icbca51d4b0fb33c90faa95f16254c7171b171d8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/393367
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-17 00:12:40 +00:00
Robert Findley
8d4da2c7b5 all: update vendored golang.org/x/tools
Update the vendored golang.org/x/tools to pick up the fix for #51717.

This also picks up some changes to support Fuzz tests in the tests
analyzer, but they are currently still guarded by an internal flag.

Fixes #51717
Updates #36905

Change-Id: Ibcd5006624dd9cd9797c811093985e8775c57d51
Reviewed-on: https://go-review.googlesource.com/c/go/+/393373
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-17 00:08:36 +00:00
Keith Randall
e5e638e512 cmd/compile: allow noop conversions when comparing expressions
Allows mapclear optimization to trigger in more cases, including
some generic instantiations.

Fixes #51699

Change-Id: Ic54f7686e5fcb8fbcad640aa77ed326d7338b938
Reviewed-on: https://go-review.googlesource.com/c/go/+/393434
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-16 23:03:54 +00:00
Russ Cox
ed4db86118 cmd/api: remove debug print
Left over from CL 392414.

Change-Id: I32ff1d660ba03d6c2005ad247e2129daf83aac04
Reviewed-on: https://go-review.googlesource.com/c/go/+/393361
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-03-16 20:39:14 +00:00
Cherry Mui
91631bc7e0 cmd/link: mark unexported methods for plugins
When plugin is used, we already mark all exported methods
reachable. However, when the plugin and the host program share
a common package, an unexported method could also be reachable
from both the plugin and the host via interfaces. We need to mark
them as well.

Fixes #51621.

Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-03-16 20:10:07 +00:00
Matthew Dempsky
81d3c25c6c cmd/compile: remove unused code from typecheckdef
typecheckdef used to be used to handle references to package-level
declarations that hadn't yet been typechecked yet. It's no longer
needed, as the current IR frontends construct package-level
declarations with proper types upfront.

Exception: this code is still used for compiler-generated function
declarations, so that code needs to be kept. Eventually that code can
be moved elsewhere, but for now this CL makes it obvious that the rest
of the code paths really are unused.

Updates #51691.

Change-Id: I5322edb686aaf5dc4627288f3d9ba910a017b41d
Reviewed-on: https://go-review.googlesource.com/c/go/+/393256
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-16 18:34:31 +00:00
Matthew Dempsky
d661bdeabf cmd/compile: remove OIOTA
OIOTA used to be used to represent "iota" in the pre-typechecked IR,
before we knew whether it was safe to replace it with a constant
(because it could be redefined as a global symbol later).

However, now types2 handles constant folding, including handling of
"iota". So this can go away.

Updates #51691.

Change-Id: I3cec45b22c4c8f1c357dcc4003292c21ae32aa90
Reviewed-on: https://go-review.googlesource.com/c/go/+/393255
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-16 18:34:22 +00:00
Matthew Dempsky
1024503f84 cmd/compile: Fatalf in Type.SetBroke(true) and Node.SetDiag(true)
Type.Broke and Node.Diag were used in the legacy typechecker to allow
reporting of multiple errors in a compilation unit, while suppressing
unhelpful follow-on errors. However, that's no longer needed now that
types2 handles (most) user-visible diagnostics.

Updates #51691.

Change-Id: I919c1598d8acebe5703939256bdca3e8d021f7ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/392918
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-16 18:33:53 +00:00
Matthew Dempsky
a1bf50eefe cmd/compile: detect invalid NIH conversions within unified IR
Unified IR currently relies on typecheck to diagnose invalid
//go:notinheap conversions, which prevents removing all of
its (otherwise) dead error-reporting code.

This CL updates the unified IR reader to instead proactively diagnose
these invalid conversions. This logic can be removed again once #46731
is implemented, but in the mean time it allows progress on #51691.

Updates #46731.
Updates #51691.

Change-Id: Ifae81aaad770209ec7a67bc10b55660f291e403e
Reviewed-on: https://go-review.googlesource.com/c/go/+/392917
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-03-16 18:30:48 +00:00
Bryan C. Mills
c0158b6a00 go/internal/srcimporter: use the 'go' command from the Importer's GOROOT
We have no guarantee in general that there is any 'go' command in
$PATH at all, let alone the correct one. However, we can expect that
if a 'go' command is not in scope, the Importer should have a correct
GOROOT setting: otherwise, it would not be able to import anything
from 'std' at all.

Given that information, when we run `go tool cgo` we should use
GOROOT/bin/go specifically, not whatever 'go' we find in $PATH.

This fixes a failure in go/types.TestStdlib that manifests as a
timeout in when the 'go' command is not present in $PATH, due to
repeated retries for every package that transitively depends on
runtime/cgo.

For #51461

Change-Id: I30cc4613f6f02a04e83c8d55657ef01888c7770f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391807
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-16 17:41:38 +00:00
Russ Cox
3efc7215cb fmt, strconv: document use of Unicode replacement character in %q
Fixes #51526.

Change-Id: I365a763454bd201f804df29f800416b1731b8ebc
Reviewed-on: https://go-review.googlesource.com/c/go/+/390436
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-16 16:28:38 +00:00
Kir Kolyshkin
33e752edd3 syscall: ensure that Getwd returns absolute path
Since Linux kernel 2.6.36, the pathname returned by the getcwd() system
call can be prefixed with the string "(unreachable)" in some cases [1].

Getcwd should return an absolute path, and doing otherwise is a
conformance issue; it also can be dangerous, since the path returned
can be an existing relative path.

Fix by returning ENOENT in case the path is not absolute. This is
essentially the same as what glibc does (since [2]).

[1] https://man7.org/linux/man-pages/man2/getcwd.2.html#BUGS
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94

Change-Id: I444c80eb3c836ff7d32c64c8b65d5112fa8c710f
Reviewed-on: https://go-review.googlesource.com/c/go/+/387174
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-16 16:07:26 +00:00
Russ Cox
a3fcc755db internal/txtar: bring back to main repo, for tests in std
This used to be cmd/go/internal/txtar,
and then it was moved to golang.org/x/tools/txtar
and revendored from there into cmd/vendor/golang.org/x/tools/txtar.

We have a use for txtar in a new test in the standard library,
which cannot access cmd/vendor. But we also don't really want
to vendor it into the standard library as is, because that would
be the first vendoring of x/tools in std, and it would be better
to keep std separate from x/tools, even for testing.

Instead, since a little copying is better than a little dependency,
just make a copy in internal/txtar. The package does not change.

Having done that, replace the uses in cmd/go so that there's
only one copy in the main repo.

Change-Id: I70b5cc05da3f6ebcc0fd9052ebcb3d369fb57956
Reviewed-on: https://go-review.googlesource.com/c/go/+/384254
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-16 16:06:15 +00:00
Cherry Mui
95395fdbe3 syscall: call ABIInternal entersyscall on register ABI platforms
Currently, when register ABI is used, syscall.Syscall calls
entersyscall via a wrapper, so the actual entersyscall records the
caller PC and SP of the wrapper. At the point of the actual
syscall, the wrapper frame is gone, so the recorded PC and SP are
technically invalid. Furthermore, in some functions on some
platforms (e.g. Syscall9 on NetBSD/AMD64), that frame is
overwritten. If we unwind the stack from the recorded syscallpc
and syscallsp, it may go wrong. Fix this by calling the
ABIInternal function directly.

exitsyscall calls are changed as well. It doesn't really matter,
just changed for consistency.

Change-Id: Iead8dd22cf32b05e382414fef664b7c4c1719b7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/376356
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-03-16 15:40:39 +00:00
Bryan C. Mills
1a2f726195 runtime/pprof: do not require a GOROOT/src prefix in tests
When paths are trimmed, the reported file locations begin with the
package import path (not GOROOT/src).

Updates #51461

Change-Id: Idbd408a02e8d03329d10e30b0b08263e69e66285
Reviewed-on: https://go-review.googlesource.com/c/go/+/391812
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-16 15:20:22 +00:00
fanzha02
5fd0ed7aaf cmd/compile: set conversions to unsafe.Pointer as an escaping operation when -asan is enabled
When ASan is enabled, treat conversions to unsafe.Pointer as
an escaping operation. In this way, all pointer operations on
the stack objects will become operations on the escaped heap
objects. As we've already supported ASan detection of error
memory accesses to heap objects. With this trick, we can use
-asan option to report errors on bad stack operations.

Add test cases.

Updates #44853.

CustomizedGitHooks: yes
Change-Id: I4e7fe46a3ce01f0d219e6a67dc50f4aff7d2ad87
Reviewed-on: https://go-review.googlesource.com/c/go/+/325629
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-03-16 07:03:20 +00:00
Meng Zhuo
d34287a4f6 cmd/link: default generic ABI compression for ELF
This CL change all debug dwarf headers to generic ABI
"Compression header" for ELF
(http://www.sco.com/developers/gabi/latest/ch4.sheader.html#compression_header)

Fixes #50796

Change-Id: I188625e596f11cd120dbd802ac2d79341d5eaf41
Reviewed-on: https://go-review.googlesource.com/c/go/+/380755
Trust: mzh <mzh@golangcn.org>
Run-TryBot: mzh <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-03-16 05:32:52 +00:00
Matthew Dempsky
6e49c592de go/types: return Universe for (*Package)(nil).Scope()
Port of go.dev/cl/325469.

Fixes #46594.

Change-Id: I4bcdafecaa86885360599c204678871646bb221b
Reviewed-on: https://go-review.googlesource.com/c/go/+/385997
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-16 00:34:27 +00:00
Matthew Dempsky
1cb34fbb26 go/types, cmd/compile: remove unused Interface.obj field
Change-Id: I6d0f629f9c7379074a03c8f13b99924d872872a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/385996
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-03-16 00:34:15 +00:00
Russ Cox
0d71234ee4 reflect: avoid panic in reflect.Kind.String for negative Kind
Kind(-1).String() used to panic; let's not.

Change-Id: I1dfc0e3298beb37d77713d8327579bbde90dd156
Reviewed-on: https://go-review.googlesource.com/c/go/+/393015
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 20:06:05 +00:00
Cherry Mui
db3045b4be cmd/asm: support -d=pctab flag
To debug PC data generation.

Change-Id: Id7ac8d607cc27ad52db490bd758c3a768c3e1df2
Reviewed-on: https://go-review.googlesource.com/c/go/+/388015
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 18:37:49 +00:00
Bryan Mills
b4428325e2 Revert "os: raise open file rlimit at startup"
This reverts CL 392415.

Reason for revert: new test is failing on at least darwin-amd64-10_14, darwin-amd64-10_15, and openbsd-arm64-jsing.

Updates #46279.

Change-Id: I2890b72f8ee74f31000d65f7d47b5bb0ed5d6007
Reviewed-on: https://go-review.googlesource.com/c/go/+/393016
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-03-15 18:09:24 +00:00
Ian Lance Taylor
201a2e9c2f compress/gzip: add example of compressing reader
For #51092

Change-Id: If0a233651ac75f113569ddfffd056084f6092564
Reviewed-on: https://go-review.googlesource.com/c/go/+/389514
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 17:59:01 +00:00
Ian Lance Taylor
4e26ab0ed8 cmd/go: document that 'go run' strips debug info
Change-Id: Ie7293a33862853ac56ee0a9017b201d8ff0ba1f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/392574
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-03-15 17:29:54 +00:00
Russ Cox
1178255f85 all: untab /* */ doc comments
A long time ago, gofmt insisted on inserting tabs in /* */ comments
at the top level of the file, like this:

	/*
		Package doc comment.
	*/
	package p

Gofmt still insists on the tab for comments not at top level,
but it has relaxed the rules about top-level comments.
A few very old doc comments are indented, left over from the old rule.

We are considering formatting doc comments, and so to make
everything consistent, standardize on unindented doc comments
by removing tabs in the few doc comments that are still indented this way.

Also update some cmd/gofmt testdata to match.

Change-Id: I293742e39b52f8a48ec41f72ca4acdafa7ce43bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/384261
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 17:17:30 +00:00
Keith Randall
9b112cec83 internal/cpu: don't run SSE3 disable test if GOAMD64>1
That feature can't be disabled if the microarchitectural version
requires it.

Change-Id: Iad8aaa8089d2f023e9ae5044c6da33224499f09b
Reviewed-on: https://go-review.googlesource.com/c/go/+/392994
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-15 17:04:57 +00:00
Russ Cox
b054c7dc17 os: raise open file rlimit at startup
Some systems set an artificially low soft limit on open file count,
for compatibility with code that uses select and its hard-coded
maximum file descriptor (limited by the size of fd_set).

Go does not use select, so it should not be subject to these limits.
On some systems the limit is 256, which is very easy to run into, even
in simple programs like gofmt when they parallelize walking a file tree.

After a long discussion on go.dev/issue/46279, we decided the best
approach was for Go to raise the limit unconditionally for itself, and
then leave old software to set the limit back as needed. Code that
really wants Go to leave the limit alone can set the hard limit, which
Go of course has no choice but to respect.

Fixes #46279.

Change-Id: Id6107503437d47a870a41be25e822fc79cea08b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/392415
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 15:21:54 +00:00