1
0
mirror of https://github.com/golang/go synced 2024-11-08 09:06:15 -07:00
Commit Graph

55517 Commits

Author SHA1 Message Date
cuiweixie
4b3726e99b encoding/binary: add var NativeEndian
Updates #57237

Change-Id: I149c8b7eeac91b87b5810250f96d48ca87135807
Reviewed-on: https://go-review.googlesource.com/c/go/+/463218
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-01-27 18:17:20 +00:00
Bryan C. Mills
092671423c syscall: avoid making assumptions about syscall permissions
We currently check for at least three different permission bits before
running tests that require root permissions: we look for UID 0, lack
of an LXC container, and lack of a Docker container, and probe a
number of distro-specific files in /proc and /sys.

The sheer number of these checks suggests that we have probably missed
at least one. Per Alan J. Perlis, “If you have a procedure with ten
parameters, you probably missed some.” (And, indeed, we definitely
have: a Debian patch¹ adds one more environment check!)

CL 58170 added some of these container checks, but “decided to go this
way instead of just skipping os.IsPermission errors because many of
those tests were specifically written to check false positive
permission errors.” However, we can't in general distinguish between a
false-positive error and a real one caused by a container: if one is
making a change to the syscall package, they should run the tests with
-v and check for unexpected skips.

Notably:

- TestUnshare already skips itself if the command fails with an error
  ending in the string "operation not permitted", which could be caused
  by a variety of possible bugs.

- The Unshare tests added in CL 38471 will fail with a permission
  error if CLONE_NEWNS is not supported, but it seems to me that if
  CLONE_NEWNS is supported — sufficient to start the process! — then
  Unmount must also be supported, and the test can at least check that
  the two are consistent.

- The AmbientCaps tests should fail to start the subprocess with
  EINVAL or similar (not produce bogus output) if the kernel does not
  support ambient caps for any reason, which we can then detect.
  (If the subprocess fails in the way the test is concerned about, it
  will exit with status 2, not fail to start in the first place.)

By executing the system calls and checking for permission errors,
this change exposed an existing bug for AmbientCaps (filed as #57208),
which was detected by the linux-arm-aws builder.

For #57208.
Updates #21379.
Updates #14693.

¹https://sources.debian.org/patches/golang-1.19/1.19.3-1/0006-skip-userns-test-in-schroot-as-well.patch/

Change-Id: I9b167661fa1bb823168c8b50d8bbbf9643e49f76
Reviewed-on: https://go-review.googlesource.com/c/go/+/456375
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alexander Morozov <lk4d4math@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-27 17:37:09 +00:00
Bryan C. Mills
c8c646d31b cmd/go/internal/modfetch: avoid path.Join in URL errors
path.Join collapses duplicated '/' tokens, but an HTTP URL
intentionally includes a '://' after the scheme.

This should fix the syntax of the errors seen in
https://build.golang.org/log/a17d0c7b6159ea4dad0a9e5378ab5a36ee30ce44.

Updates #52727.

Change-Id: I6e1773a7eb8b3e7e2b3ca29540c1e94a7cd2d99d
Reviewed-on: https://go-review.googlesource.com/c/go/+/461682
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-27 17:13:20 +00:00
Benjamin Prosnitz
a106defdda hex: fix panic in Decode when len(src) > 2*len(dst)
hex.Decode never checks the length of dst and triggers a panic
if there are insufficient bytes in the slice.

There isn't document on what the behavior *should* be in this case.
Two possibilities:
1. Error dst has insufficient space (as done in this change)
2. Reduce the length of the decode to min(dst, src)

Option 1 was chosen because it seems the least surprising or
subtle.

Change-Id: I3bf029e3d928202de716830434285e3c165f26dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/461958
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: 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>
Reviewed-by: Benjamin Prosnitz <bprosnitz@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-01-27 15:28:30 +00:00
Robert Griesemer
6b8b7823c7 go/types, types2: move tparamIndex from unify.go into infer.go
Minor code reorganization: the next version of unify.go doesn't
need this function anymore, so move it where it is still used.

Change-Id: I6744a2361b5dfe2564ec73787a7a110e85ac9f1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/463230
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-01-27 14:34:03 +00:00
Robert Griesemer
21b4e0146a go/types, types2: simplify unifier
The unifier was written such that it was possible to specify
a different set of type parameters (declared by different
generic declarations) for each type x, y being unified,
to allow for what is called "bidirectional unification"
in the documentation (comments).

However, in the current implementation, this mechanism is
not used:

- For function type inference, we only consider the
type parameter list of the generic function (type parameters
that appear in the arguments are considered stand-alone types).
We use type parameter renaming to avoid any problems in case
of recursive generic calls that rely on type inference.

- For constraint type inference, the type parameters for the
types x and y (i.e., the type parameter and its constraint)
are the same and had to be explicitly set to be identical.

This CL removes the ability to set separate type parameter
lists. Instead a single type parameter list is used during
unification and is provided when we initialize a unifier.

As a consequence, we don't need to maintain the separate
tparamsList data structure: since we have a single list
of type parameters we can keep it directly in the unifier.

Adjust all the unifier code accordingly and update comments.

As an aside, remove the `exact` flag from the unifier as it
was never set. However, keep the functionality for now and
use a constant (exactUnification) instead. This makes it
easy to find the respectice code without incurring any cost.

Change-Id: I969ba6dbbed2d65d06ba4e20b97bdc362c806772
Reviewed-on: https://go-review.googlesource.com/c/go/+/463223
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-27 14:33:39 +00:00
Matthew Dempsky
178080740c cmd/compile/internal/noder: remove unused noding code
This CL simplifies and removes some old noding code, which isn't
necessary any more.

Most notably, we no longer need separate posMaps for each noder,
because noders are only used for parsing now. Before we started using
types2, noders were also responsible for constructed (untyped) IR, so
posMaps were necessary to translate syntax.Pos into src.XPos.

Change-Id: Ic761abcd727f5ecefc71b611635a0f5b088c941f
Reviewed-on: https://go-review.googlesource.com/c/go/+/463738
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-27 03:43:35 +00:00
Matthew Dempsky
7cf8593140 cmd/compile: apply FixVariadicCall and FixMethodCall during typecheck
To simplify backend analysis, we normalize variadic and method calls:
variadic calls are rewritten with an explicit slice argument, and
method calls are turned into function calls that pass the receiver
argument as the first parameter.

But because we've been supporting multiple frontends, this
normalization was scattered in various later passes. Now that we're
back to just one frontend, we can move the normalization forward into
typecheck (where most other IR normalization already happens).

Change-Id: Idd05ae231fc180ae3dd1664452414f6b6d578962
Reviewed-on: https://go-review.googlesource.com/c/go/+/463737
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-27 03:37:13 +00:00
Keith Randall
4e3abee245 cmd/compile: remove go119UseJumpTables flag
Change-Id: Iaaac46e96b74289096ce0c6186c73000d1fc6faa
Reviewed-on: https://go-review.googlesource.com/c/go/+/463224
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-27 03:32:07 +00:00
Oleksii Sholik
5ad799ef8a net/http: fix missing word in ServeMux doc
Change-Id: I324cedfcdfa1d7eac7be43dc89febb584359c8e3
GitHub-Last-Rev: 7724cd84f3
GitHub-Pull-Request: golang/go#57799
Reviewed-on: https://go-review.googlesource.com/c/go/+/462039
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2023-01-27 00:42:16 +00:00
Mateusz Poliwczak
3dc85a32fc net: report completed when context is done in cgoLookupIP and cgoLookupPTR
All the Lookup* methods that resolve hostnames eventually call lookupIP
or lookupHost method. When the order is selected to be hostLookupCGO
then lookupHost calls cgoLookupHost which internally calls cgoLookupIP
(the lookupIP directly calls cgoLookupIP).
When we provide a context that is cancelled after cgo call, then the
cgoLookupIP returns completed  == false, which caues the
lookupIP/lookupHost to fallback to the go resolver.
This fallback is unnecessary because our context is already cancelled.

The same thing can happen to LookupAddr.

Change-Id: Ifff7716c461f05d954ef43b5205865103558b410
GitHub-Last-Rev: 2ef2023e8c
GitHub-Pull-Request: golang/go#57042
Reviewed-on: https://go-review.googlesource.com/c/go/+/454696
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-27 00:42:08 +00:00
Bryan C. Mills
d0851777da runtime/debug: expand fuzz corpus for FuzzParseBuildInfoRoundTrip
Updates #51026

Change-Id: Id7af2ffa8c99970274b2a2b12622d986ea105b1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/384161
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-26 23:37:45 +00:00
Bryan C. Mills
c611ef2860 cmd/dist: restore the original GOCACHE before building std and cmd
The user is likely to run other commands that need these libraries
immediately after they are built.

For #57734.
Updates #56889.

Change-Id: I2a1a234e6031d85f017ee692ea1ace8c6e0e7355
Reviewed-on: https://go-review.googlesource.com/c/go/+/452679
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2023-01-26 23:32:05 +00:00
Bryan C. Mills
8e0781e5ff cmd/dist: require absolute path to executable in flattenCommandLine
This should help to prevent bugs from unintended use of system tools,
especially the system or bootstrap "go" command.
(Suggested by Austin on CL 452678.)

Updates #31567.

Change-Id: I71809ee30d06eda4b5ff8f90656d4f1a462d35dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/452776
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-26 23:30:15 +00:00
Matthew Dempsky
6f6276ce36 cmd/compile/internal/inline: adjust isBigFunc to recognize unified IR codegen
Unified IR generates uniform IR for "a, b = f()" to be able to insert
implicit conversion expressions, but the result is somewhat more
verbose and trips up the inliner's naive cost metrics.

The hairyVisitor.doNode method was already adjusted to account for
this, but isBigFunc needs the same adjustment.

Fixes #57563.

Change-Id: Ia8d86a6e314ec60190c78f40ace4fb30dadc4413
Reviewed-on: https://go-review.googlesource.com/c/go/+/460395
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26 23:27:24 +00:00
Bryan C. Mills
a0bebffa33 cmd/dist: consistently use $GOROOT/bin/go instead of just "go"
Also remove existing special cases that transform "go" into
gorootBinGo, because they make debugging and code-reviews more
difficult: log messages that don't include the full path can mask bugs
like #31567, and the reader of the code has to trace through the
various call chains to verify that the correct "go" is being used.

Instead, we can make the use of the correct "go" command plainly
obvious in the code by using one consistent name for it.
(Prior to this CL, we had three different names for it:
gorootBinGo, "go", and cmdGo. Now we have only one.

Updates #31567.

Change-Id: Ia9ff27e5e800c79af5a4e9f2803c9ea5ccafbf35
Reviewed-on: https://go-review.googlesource.com/c/go/+/452678
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-26 23:26:19 +00:00
Matthew Dempsky
13c70b12d7 cmd/compile/internal/types: remove Markdcl/Pushdcl/Popdcl
Sym.Def used to be used for symbol resolution during the
old (pre-types2) typechecker. But since moving to types2-based IR
construction, we haven't really had a need for Sym.Def to ever refer
to anything but the package-scope definition, because types2 handles
symbol resolution for us.

This CL finally removes the Markdcl/Pushdcl/Popdcl functions that have
been a recurring source of issues in the past.

Change-Id: I2b012a0f17203efdd724ebd1e9314bd128cc2d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/458625
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-01-26 21:56:56 +00:00
Matthew Dempsky
f0b1563535 cmd/compile/internal/types: remove unneeded functionality
This CL removes a handful of features that were only needed for the
pre-unified frontends.

In particular, Type.Pkg was a hack for iexport so that
go/types.Var.Pkg could be precisely populated for struct fields and
signature parameters by gcimporter, but it's no longer necessary with
the unified export data format because we now write export data
directly from types2-supplied type descriptors.

Several other features (e.g., OrigType, implicit interfaces, type
parameters on signatures) are no longer relevant to the unified
frontend, because it only uses types1 to represent instantiated
generic types.

Updates #57410.

Change-Id: I84fd1da5e0b65d2ab91d244a7bb593821ee916e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/458622
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26 21:56:49 +00:00
Matthew Dempsky
f5eb0a7a5a cmd/compile/internal/types: remove TTYPEPARAM and TUNION types
These were used by the nounified frontend for representing
uninstantiated generic types; however, the unified frontend only needs
types1 to represent instantiated types.

Updates #57410.

Change-Id: Iac417fbf2b86f4e08bd7fdd26ae8ed17395ce833
Reviewed-on: https://go-review.googlesource.com/c/go/+/458621
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26 21:56:38 +00:00
Tobias Klauser
ea6d4b0eaf internal/syscall/unix: use atomic.Bool for getrandomUnsupported
Change-Id: I50522ed782dd963f445419fc45495f6608909c47
Reviewed-on: https://go-review.googlesource.com/c/go/+/463124
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-01-26 21:54:02 +00:00
Matthew Dempsky
da9761303c cmd/compile: remove GOEXPERIMENT=nounified frontend
This CL removes most of the code specific to the nounified
frontend. To simplify review, it's a strict remove-only CL.

Updates #57410.

Change-Id: Ic3196570aa4286618c1d5e7fd0d0e6601a18195b
Reviewed-on: https://go-review.googlesource.com/c/go/+/458620
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26 21:52:50 +00:00
Matthew Dempsky
a7de684e1b cmd/compile/internal/noder: stop creating TUNION types
In the types1 universe under the unified frontend, we never need to
worry about type parameter constraints, so we only see pure
interfaces. However, we might still see interfaces that contain union
types, because of interfaces like "interface{ any | int }" (equivalent
to just "any").

We can handle these without needing to actually represent type unions
within types1 by simply mapping any union to "any".

Updates #57410.

Change-Id: I5e4efcf0339edbb01f4035c54fb6fb1f9ddc0c65
Reviewed-on: https://go-review.googlesource.com/c/go/+/458619
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26 21:43:08 +00:00
Robert Griesemer
627f12868c go/types, types2: remove misleading example from comment
Before this CL, the comment used the case of a recursive generic
function call as an example for uni-directional unification.
However, such cases are now more generally (and correctly) addressed
through renaming of the type parameters.

Change-Id: I69e94f53418e1fb4ca9431aeb27c639c40d19b09
Reviewed-on: https://go-review.googlesource.com/c/go/+/463735
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26 19:45:22 +00:00
David Chase
e9c5e60cfd misc: update go.mod to 1.21
Doing this allows updates to swig so it can access slices
and strings in a somewhat less-unsafe way.

Change-Id: If2af8f8cf58d2287569dcd7c7ce09728e20b5ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/463396
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26 16:55:59 +00:00
Quim Muntal
a9780d8dfd Revert "runtime: use explicit NOFRAME on darwin/amd64"
This reverts CL 460235.

Reason for revert: This breaks darwin 10 and 11

Change-Id: I3c663ebe3b77eba45a006a3ebec5cabe667faa9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/463635
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-26 15:41:28 +00:00
Tobias Klauser
4df10fba16 crypto/rand, internal/syscall/unix: add support for getrandom on NetBSD ≥ 10.0
The getrandom syscall was added to NetBSD in version 10.0, see
https://man.netbsd.org/NetBSD-10.0-STABLE/getrandom.2

Change-Id: I2714c1040791f7f4728be8d869058a38cbd93d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/463123
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2023-01-26 10:15:35 +00:00
qmuntal
cea70301e2 runtime: use explicit NOFRAME on darwin/amd64
This CL marks some darwin assembly functions as NOFRAME to avoid relying
on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Change-Id: I797f3909bcf7f7aad304e4ede820c884231e54f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/460235
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-01-26 07:17:26 +00:00
Cameron Bedard
89de906aa2 cmd/go/internal/vcs: fix outdated comment
Function was was replaced in https://go.dev/cl/12143.

Fixes #57718

Change-Id: I56ff9390af9ae31803805fa27d2c08b5e1d842e1
GitHub-Last-Rev: b8c9dbccbc
GitHub-Pull-Request: golang/go#57767
Reviewed-on: https://go-review.googlesource.com/c/go/+/461610
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-01-26 01:06:22 +00:00
Gustavo Falco
451106921f net/http: keep sensitive headers on redirects to the same host
Preserve sensitive headers on a redirect to a different port of the same host.

Fixes #35104

Change-Id: I5ab57c414ce92a70e688ee684b9ff02fb062b3c6
GitHub-Last-Rev: 8d53e71e22
GitHub-Pull-Request: golang/go#54539
Reviewed-on: https://go-review.googlesource.com/c/go/+/424935
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2023-01-26 00:52:05 +00:00
Matthew Dempsky
de9bffb5f1 cmd/compile: change some unreachable code paths into Fatalf
Now that GOEXPERIMENT=nounified is removed, we can assume InlineCall
and HaveInlineBody will always be overridden with the unified
frontend's implementations. Similarly, we can assume expandDecl will
never be called.

This CL changes the code paths into Fatalfs, so subsequent CLs can
remove all the unreachable code.

Updates #57410.

Change-Id: I2a0c3edb32916c30dd63c4dce4f1bd6f18e07468
Reviewed-on: https://go-review.googlesource.com/c/go/+/458618
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26 00:29:56 +00:00
Matthew Dempsky
532e34dd38 cmd/compile: remove -d=typecheckinl flag
This flag forced the compiler to eagerly type check all available
inline function bodies, which presumably was useful in the early days
of implementing inlining support. However, it shouldn't have any
significance with the unified frontend, since the same code paths are
used for constructing normal function bodies as for inlining.

Updates #57410.

Change-Id: I6842cf86bcd0fbf22ac336f2fc0b7b8fe14bccca
Reviewed-on: https://go-review.googlesource.com/c/go/+/458617
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-26 00:28:48 +00:00
Matthew Dempsky
6d4101ea68 cmd/compile/internal/pkginit: remove dependency on typecheck.Resolve
The use of typecheck.Resolve was previously necessary to interoperate
with the non-unified frontend, because it hooked into iimport. It's no
longer necessary with unified IR, where we can just lookup the
".inittask" symbol and access Def directly.

Updates #57410.

Change-Id: I73bdfd53f65988ececd2b777743cd8b591a6db48
Reviewed-on: https://go-review.googlesource.com/c/go/+/458616
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-01-26 00:28:25 +00:00
Keith Randall
4a0e84a1be cmd/compile: improve register overwrite decision for resultInArg0 ops
When we're compiling a resultInArg0 op, we need to clobber the
register containing the input value. So we first make a register copy
of the input value. We can then clobber either of the two registers
the value is in and still have the original input value in a register
for future uses.

Before this CL, we always clobbered the original, not the copy.
But that's not always the right decision - if the original is already
in a specific register that it needs to be in later (typically, a
return value register), clobber the copy instead.

This optimization can remove a mov instruction. It saves 1376 bytes
of instructions in cmd/go.

Redo of CL 460656, reverted at CL 463475, with a fix for s390x.

The new code just ensures that the copied value is in a register
which is a valid input register for the instruction.

Change-Id: Id570b8a60a6d2da9090de80a90b6bb0266e9e38a
Reviewed-on: https://go-review.googlesource.com/c/go/+/463221
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-26 00:07:40 +00:00
qmuntal
2c7856087a runtime: delete unused cbctxts variable on windows assembly
runtime·cbctxts has been unused since CL 258938, but it was left over.

Change-Id: I374ad26e668a36994e41f5d17593b33090bdc644
Reviewed-on: https://go-review.googlesource.com/c/go/+/463119
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-25 22:05:14 +00:00
Matthew Dempsky
4f467f1082 cmd: remove GOEXPERIMENT=nounified knob
This CL removes the GOEXPERIMENT=nounified knob, and any conditional
statements that depend on that knob. Further CLs to remove unreachable
code follow this one.

Updates #57410.

Change-Id: I39c147e1a83601c73f8316a001705778fee64a91
Reviewed-on: https://go-review.googlesource.com/c/go/+/458615
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-25 21:16:32 +00:00
Bryan C. Mills
3d49b683c6 context: eliminate arbitrary timeouts in examples
ExampleWithDeadline and ExampleWithTimeout used an arbitrary 1-second
timeout for a “blocked” select case, which could fail if the test
goroutine happens to be descheduled for over a second, or perhaps if
an NTP synchronization happens to jump by a second at just the right
time.

Either case is plausible, especially on a heavily-loaded or slow
machine (as is often the case for builders for unusual ports).

Instead of an arbitrary timeout, use a “ready” channel that is never
actually ready.

Fixes #57594.

Change-Id: I9ff68f50b041a3382e7b267c28c5259e886a9d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/460999
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-25 21:12:45 +00:00
Bryan C. Mills
6e82febaf0 os: eliminate arbitrary timeout in testClosewithBlockingRead
The 1-second timeout on execution of this test is empirically too
short on some platforms. Rather than trying to tune the timeout, allow
the test to time out on its own (and dump goroutines) if it deadlocks.

Fixes #57993.
Fixes #57994.

Change-Id: I69ee86c75034469e4b4cd391b8dc5616b93468b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/463180
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-25 20:45:53 +00:00
Ian Lance Taylor
1f29f39795 cmd/link: don't export all symbols for ELF external linking
Since this may add a large number of --export-dynamic-symbol options,
use a response file if the command line gets large.

Fixes #53579

Change-Id: Ic226bf372bf1e177a3dae886d1c48f4ce3569c0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414654
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-25 20:45:42 +00:00
Keith Randall
2bf0f54bbd Revert "cmd/compile: improve register overwrite decision for resultInArg0 ops"
This reverts CL 460656
Reason for revert: This breaks s390x.

Change-Id: I8fada14fabc90593b8033ed11188c04963d2da75
Reviewed-on: https://go-review.googlesource.com/c/go/+/463475
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2023-01-25 19:25:48 +00:00
Keith Randall
3c7884a21b cmd/compile: improve register overwrite decision for resultInArg0 ops
When we're compiling a resultInArg0 op, we need to clobber the
register containing the input value. So we first make a register copy
of the input value. We can then clobber either of the two registers
the value is in and still have the original input value in a register
for future uses.

Before this CL, we always clobbered the original, not the copy.
But that's not always the right decision - if the original is already
in a specific register that it needs to be in later (typically, a
return value register), clobber the copy instead.

This optimization can remove a mov instruction. It saves 1376 bytes
of instructions in cmd/go.

Change-Id: I162870c84b9a180da6715bb24c296a902974fed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/460656
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2023-01-25 18:50:22 +00:00
Heschi Kreinick
f85c282a18 internal/testpty: fix error handling
When calling a c library function, you discover that an error has
occurred, typically by looking at the return value of the function. Only
after that can you use errno to figure out the cause of the error.

Nothing about cgo changes that story -- you still have to look at the
result before checking the error that represents errno. If not you can
get false errors if the function happens to leak a non-zero errno.

Fix testpty to check errors correctly.

Change-Id: Idb95f8dd6a8ed63f653190c2e722e742cf50542b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463397
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-25 18:38:54 +00:00
Matthew Dempsky
a896219b38 cmd/compile: revert package typecheck part of CL 422914
This code path is unreachable anyway, and it adds new uses of
Type.Pkg, which shouldn't be used anymore.

Mark Type.Pkg as deprecated while here.

Updates #57410.

Change-Id: I1eec1c8ed99207d58d0ba0c44822bbad29dc64f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/458575
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-25 18:32:34 +00:00
Bryan C. Mills
77cd3a46a8 cmd/go/internal/str: fix PathPrefix functions for root directories
For #51506.
For #50807.

Change-Id: I4c0ae85a2103ac4f07351a4f01ce24fa02f03104
Reviewed-on: https://go-review.googlesource.com/c/go/+/463176
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2023-01-25 16:49:13 +00:00
Bryan C. Mills
1d3088effd os: make Lstat for symlinks on Windows consistent with POSIX
This also makes path/filepath.Walk more consistent between
Windows and POSIX platforms.

According to
https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/basedefs/V1_chap04.html#tag_04_12
symlinks in a path that includes a trailing slash must be resolved
before a function acts on that path.

POSIX defines an lstat function, whereas the Win32 API does not, so
Go's os.Lstat should follow the (defined) POSIX semantics instead of
doing something arbitrarily different.

CL 134195 added a test for the correct POSIX behavior when os.Lstat is
called on a symlink. However, the test turned out to be broken on Windows,
and when it was fixed (in CL 143578) it was fixed with different Lstat
behavior on Windows than on all other platforms that support symlinks.

In #50807 we are attempting to provide consistent symlink behavior for
cmd/go. This unnecessary platform difference, if left uncorrected,
will make that fix much more difficult.

CL 460595 reworked the implementation of Stat and Lstat on Windows,
and with the new implementation this fix is straightforward.

For #50807.
Updates #27225.

Change-Id: Ia28821aa4aab6cefa021da2d9b803506cdb2621b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463177
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-25 16:38:21 +00:00
qmuntal
7a5460ed9b runtime: mark amd64 runtime·rt0_go as NOFRAME
This CL adds the NOFRAME flag to runtime·rt0_go, which should
had been added in CL 459395 but didn't and broke fix windows-amd64-2008.

Change-Id: I4583f2034bf114e1f7aaddef9ba505f53536c3eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/463120
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-01-25 15:14:29 +00:00
Than McIntosh
cc82867f6b runtime/race: update race_windows_amd64.syso
Update race_windows_amd64.syso to latest tsan (V3) runtime.

This version of the runtime depends on libsynchronization.a, so to
use this syso, you need to also be using a sufficiently up to date
version of GCC (notably GCC 5.1, installed on the Go windows builders
right now, does not include this library).

Updates #48231.
Updates #35006.
Fixes #49761.

Change-Id: Ia1e2b1d8fe7e2c99728150734935a2c522006caa
Reviewed-on: https://go-review.googlesource.com/c/go/+/420197
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-25 14:18:57 +00:00
Nigel Tao
a11b8e3765 os: have RemoveAll loop on EINTR
Fixes #57966

Change-Id: Ia732d499ff9bd6e70030daab8fac42d1e204be37
Reviewed-on: https://go-review.googlesource.com/c/go/+/463076
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
2023-01-25 07:07:01 +00:00
Bryan C. Mills
e216ee7e74 syscall: clean up variable declarations in forkAndExecInChild
The various forkAndExecInChild implementations have comments
explaining that they pre-declare variables to force allocations
to occur before forking, but then later use ":=" declarations
for additional variables.

To make it clearer that those ":=" declarations do not allocate,
we move their declarations up to the predeclared blocks.

For #57208.

Change-Id: Ie8cb577fa7180b51b64d6dc398169053fdf8ea97
Reviewed-on: https://go-review.googlesource.com/c/go/+/456516
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-25 03:23:11 +00:00
Bryan C. Mills
01636cf3fd syscall: export X__ifi_pad and X_f on s390x and riscv64
This brings the exported field names on these GOARCHes
in line with the other supported linux platforms.

Fixes #57313.

Change-Id: I2107a7116ba60dc0c0a27f776318e3eb69e51682
Reviewed-on: https://go-review.googlesource.com/c/go/+/457557
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-01-25 02:59:05 +00:00
Paul E. Murphy
a37672bb7b test/codegen: accept ppc64x as alias for ppc64le and ppc64 arches
This helps simplify the noise when adding ppc codegen tests. ppc64x
is used in other places to indicate something which runs on either
endian.

This helps cleanup existing codegen tests which are mostly
identical between endian variants.

condmove tests are converted as an example.

Change-Id: I2b2d98a9a1859015f62db38d62d9d5d7593435b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/462895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
2023-01-24 22:55:18 +00:00