1
0
mirror of https://github.com/golang/go synced 2024-11-24 13:20:15 -07:00
Commit Graph

50240 Commits

Author SHA1 Message Date
Dan Scales
640a49b8d4 test: add a test for parameterized embedded field
Make sure that an embedded field like "MyStruct[T]" works and can be
referenced via the name MyStruct.

Change-Id: I8be1f1184dd42c4e54e4144aff2fd85e30af722f
Reviewed-on: https://go-review.googlesource.com/c/go/+/356312
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-10-16 16:27:40 +00:00
Richard Musiol
680caf1535 misc/wasm: expect environment to provide polyfills
The list of environments to support with wasm_exec.js was becoming too
large to maintain. With this change, wasm_exec.js expects that the
environment provides all necessary polyfills.

The standardized "globalThis" is used for accessing the environment.
wasm_exec.js now only provides stub fallbacks for globalThis.fs and
globalThis.process.

All code specific to Node.js is now in a separate file.

Change-Id: I076febbd94d4d7845260faad972f450f74a7b983
Reviewed-on: https://go-review.googlesource.com/c/go/+/347353
Trust: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-16 14:50:21 +00:00
Dan Scales
ed1c8db308 cmd/compile: cleanup code in getInstInfo to use switch statement
Simple cleanup: convert a bunch of if's to a switch statement in
getInstInfo. Also, use a few extra variables to avoid repeated node
conversions (such as n.(*ir.CallExpr))

Change-Id: I7a2a4efb569415256a8bc9350fb100bd2d8cfb39
Reviewed-on: https://go-review.googlesource.com/c/go/+/356311
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-10-15 21:46:06 +00:00
Dan Scales
4a7975e73a cmd/compile: convert to using a map in getInstInfo, rather than SetImplicit()
SetImplicit() has an explicit meaning and really shouldn't be used in
this way - its use is left over from early prototype of the dictionary
code. Convert from using SetImplicit to just using a map during
traversal.

Change-Id: I3d257c101a859f000e159d7ced307d1b7cf990d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/356310
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-10-15 21:44:07 +00:00
Michael Pratt
1b072b3ed5 runtime: consistently access pollDesc r/w Gs with atomics
Both netpollblock and netpollunblock read gpp using a non-atomic load.
When consuming a ready event, netpollblock clears gpp using a non-atomic
store, thus skipping a barrier.

Thus on systems with weak memory ordering, a sequence like so this is
possible:

             T1                                T2

1. netpollblock: read gpp -> pdReady
2. netpollblock: store gpp -> 0

                                 3. netpollunblock: read gpp -> pdReady
                                 4. netpollunblock: return

i.e., without a happens-before edge between (2) and (3), netpollunblock
may read the stale value of gpp.

Switch these access to use atomic loads and stores in order to create
these edges.

For ease of future maintainance, I've simply changed rg and wg to always
be accessed atomically, though I don't believe pollOpen or pollClose
require atomics today.

Fixes #48925

Change-Id: I903ea667eea320277610b4f969129935731520c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/355952
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-10-15 20:34:15 +00:00
Jay Conrod
85cbdda5a6 doc/go1.18: add release notes for build and VCS info
Fixes #37475
For #39301

Change-Id: I765bc667004931ff8973b947f2e95624a4a0375d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356013
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
2021-10-15 20:29:48 +00:00
Jay Conrod
a17b2e8655 cmd/go: allow nested VCS repositories when preparing build stamp
The go command no longer reports an error when invoked in a repository
nested inside another. This check is still used by 'go get' in GOPATH
mode when locating a repository, but it's not needed when preparing
the build stamp.

Fixes #49004

Change-Id: I4ed4dcc04174d2d42da8651d47e52ab1d7d66e35
Reviewed-on: https://go-review.googlesource.com/c/go/+/356309
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-15 20:29:36 +00:00
Keith Randall
22951fbc89 cmd/compile: make for loops with range statements not terminating
Fixes #49003

Change-Id: If09c6f028dce5440b1be238612653ffdd626113a
Reviewed-on: https://go-review.googlesource.com/c/go/+/356189
Trust: Keith Randall <khr@golang.org>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-10-15 19:54:44 +00:00
Katie Hockman
cfe6763783 internal/fuzz: fix bugs with minimization
This pulls in some code and tests from CL 353355.

This change makes some refactors for when we read
to and write from memory during minimization.
That fixes a bug when minimizing interesting inputs.
Now, if an error occurs while minimizing an interesting
input, that value will continue to be minimized as a
crash, and returned to the user.

This change also allows minimization of a crash that
occurred during the warmup phase. We don't want to
minimize failures in the seed corpus, but if an entry
in the cache causes a new failure, then there's no
compelling reason why we shouldn't try to minimize it.

Fixes #48731

Change-Id: I7262cecd8ea7ae6fdf932f3a36db55fb062a1f2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/355691
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-10-15 19:03:33 +00:00
Keith Randall
8331f25e96 reflect: make Elem panic on bad notinheap pointers
This CL fixes the subtle issue that Elem can promote a
not-in-heap pointer, which could be any bit pattern, into an
unsafe.Pointer, which the garbage collector can see. If that
resulting value is bad, it can crash the GC.

Make sure that we don't introduce bad pointers that way. We can
make Elem() panic, because any such bad pointers are in the Go heap,
and not-in-heap pointers are not allowed to point into the Go heap.

Update #48399

Change-Id: Ieaf35a611b16b4dfb5e907e229ed4a2aed30e18c
Reviewed-on: https://go-review.googlesource.com/c/go/+/350153
Trust: Keith Randall <khr@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-15 18:07:49 +00:00
Robert Griesemer
8c99421f01 cmd/compile/internal/types2: add debugging support for delayed actions
Add a simple mechanism to provide formatted descriptions for
delayed actions. The comment strings are printed when tracing
is enabled and the delayed action is executed. This results
in more easily decipherable tracing output.

Requires debug mode in order to minimize the overhead during normal
execution. Use the mechanism in a few places to show typical use.

Also cleaned up a few unrelated comments.

Change-Id: Ic273c380c3963341500396ec62b694d143c25de2
Reviewed-on: https://go-review.googlesource.com/c/go/+/355871
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-15 17:05:16 +00:00
Dan Scales
a80e53ec43 cmd/compile: support new fully-inst types referenced during inlining
Modify the phase for creating needed function/method instantiations and
modifying functions to use those instantiations, so that the phase is
self-contained and can be called again after inlining. This is to deal
with the issue that inlining may reveal new fully-instantiated types
whose methods must be instantiated.

With this change, we have an extra phase for instantiation after
inlining, to take care of the new fully-instantiated types that have
shown up during inlining. We call inline.InlineCalls() for any new
instantiated functions that are created.

Change-Id: I4ddf0b1907e5f1f7d45891db7876455a99381133
Reviewed-on: https://go-review.googlesource.com/c/go/+/352870
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-15 16:57:36 +00:00
Bryan C. Mills
fad4a16fd4 cmd/go: use portable flags in TestScript/version_build_settings
This fixes a test failure on the 386-longtest builder.

For #37475

Change-Id: Icd1d3474968fcf85ef893190760fb488302abc3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/356209
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-10-15 16:00:01 +00:00
Keith Randall
1cbec68512 reflect: fix SetIter test
Missed one review comment in CL 356049

Change-Id: I05be585d15e77afc1aa57b737cdc8ba7204bab98
Reviewed-on: https://go-review.googlesource.com/c/go/+/356051
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-15 07:13:43 +00:00
Keith Randall
81484cf626 doc: document new reflect.SetIter{Key,Value} functions
Update #48294
Update #47694

Change-Id: I4d4c01be74a9736d89a4ec92318ce29ff7289a0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/356050
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
2021-10-15 05:20:52 +00:00
Keith Randall
8dab959a8e reflect: rename Mapiter.SetKey to Value.SetIterKey
Same for Value.

Add a bigger test. Include some shouldPanic checks.

Fix a bug in assignment conversion.

Fixes #48294

Change-Id: Id863ee5122a5787a7b35574b18586fd24d118788
Reviewed-on: https://go-review.googlesource.com/c/go/+/356049
Trust: Keith Randall <khr@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-10-15 03:49:17 +00:00
Jay Conrod
3da0ff8e3b cmd/go: don't stamp build or vcs info for GOROOT binaries
Fixes a test failure in cmd/go TestScript/mod_outside.

make.bash (cmd/dist) builds everything with -gcflags=all= -ldflags=all=
by default. If those no-op flags aren't used, all GOROOT binaries
appear stale.

It's likely safe to omit those flags in cmd/dist if they're
empty. Checking out a new commit in GOROOT would always cause
staleness since the VCS info would change.

For #37475

Change-Id: Ic9aa0f3b7318e05fbb2f7d2c008ad07a4c61952f
Reviewed-on: https://go-review.googlesource.com/c/go/+/356014
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-15 02:02:50 +00:00
Cuong Manh Le
0c45ed0561 cmd/compile: fix irgen reports wrong error message for misuse of //go:embed
Fixes #48230

Change-Id: Ic6490e065e7e79793faa0d0201dc94f5fcea694a
Reviewed-on: https://go-review.googlesource.com/c/go/+/355529
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-10-15 01:35:56 +00:00
Jay Conrod
9e8ed86813 debug/buildinfo: fix test for build settings
This CL fixes the debug/buildinfo test, which did not expect build settings.

For #37475

Change-Id: Ie8c15ec633b4eec6a976120c8db64f116589d98e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356012
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 23:32:09 +00:00
Brad Fitzpatrick
b59467e036 net/http: also use Server.ReadHeaderTimeout for TLS handshake deadline
Fixes #48120

Change-Id: I72e89af8aaf3310e348d8ab639925ce0bf84204d
Reviewed-on: https://go-review.googlesource.com/c/go/+/355870
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-10-14 22:15:24 +00:00
Robert Griesemer
0400d536e4 go/types, types2: add a test case to ConvertibleTo
string(int) conversions are somewhat special and deserve an entry.

Change-Id: Ia68d047cfdb2f98e837bf663659f7f46404b16ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/355989
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-14 21:08:41 +00:00
Robert Griesemer
440b63bd6f cmd/compile/internal/types2: remove Config.AllowTypeLists (cleanup)
This flag is not used anymore.

Change-Id: Id083ffa4f0a3051d3f1905a211db8acaaf525cf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/355931
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2021-10-14 21:08:35 +00:00
Robert Findley
4cbc0a5554 cmd/go: produce a better error for generic test functions
Test functions with type parameters cannot be invoked without type
arguments, so cmd/go would previously fail with a type-checking error in
the test harness.

Avoid this by producing an error explaining that test functions cannot
have type parameters.

Fixes #48953

Change-Id: I4e39c9b7a06c964fad5f12d74d262aa090c25d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/355889
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-14 19:24:35 +00:00
Jay Conrod
0fd0639e4c cmd/go: stamp tags and flags in build info
Toolchain flags (like -gcflags), build tags (including race and msan),
and cgo variables (including CGO_ENABLED, CGO_CPPFLAGS and others) are
now stamped into binaries.

For #37475

Change-Id: I9023e682c0618f91805434946c6bc937536b69bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/355493
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:44:48 +00:00
Jay Conrod
a37bebc042 cmd/go: stamp VCS revision and uncommitted status into binaries
When the go command builds a binary, it will now stamp the current
revision from the local Git or Mercurial repository, and it will also
stamp whether there are uncommitted edited or untracked files. Only
Git and Mercurial are supported for now.

If no repository is found containing the current working directory
(where the go command was started), or if either the main package
directory or the containing module's root directory is outside the
repository, no VCS information will be stamped. If the VCS tool is
missing or returns an error, that error is reported on the main
package (hinting that -buildvcs may be disabled).

This change introduces the -buildvcs flag, which is enabled by
default. When disabled, VCS information won't be stamped when it would
be otherwise.

Stamped information may be read using 'go version -m file' or
debug.ReadBuildInfo.

For #37475

Change-Id: I4e7d3159e1c270d85869ad99f10502e546e7582d
Reviewed-on: https://go-review.googlesource.com/c/go/+/353930
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:44:37 +00:00
Jay Conrod
a8c5a994d6 cmd/go: migrate 'go version' to use buildinfo.ReadFile
The same code was copied into debug/buildinfo. 'go version' doesn't
need its own copy.

For #37475

Change-Id: I9e473ce574139a87a5f9c63229f0fc7ffac447a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/353929
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:44:29 +00:00
Jay Conrod
85a068fdf2 runtime/debug: add GoVersion to BuildInfo
BuildInfo now includes the version of Go used to build a binary, as
reported by runtime.Version() or 'go version'.

For #37475

Change-Id: Id07dda357dc70599d64a9202dab894c7288de1de
Reviewed-on: https://go-review.googlesource.com/c/go/+/353888
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:44:21 +00:00
Jay Conrod
434cdd0337 debug/buildinfo: new package with Read and ReadFile
These functions provide access to module information stamped into Go
binaries. In the future, they'll provide access to other information
(like VCS info).

These functions are added in a new package instead of runtime/debug
since they use binary parsing packages like debug/elf, which would
make runtime/debug an unacceptably heavy dependency. The types in
runtime/debug are still used; debug/buildinfo uses them via type
aliases.

This information is already available for the running binary through
debug.ReadBuildInfo and for other binaries with 'go version -m', but
until now, there hasn't been a way to get it for other binaries
without installing cmd/go.

This change copies most of the code in cmd/go/internal/version. A
later CL will migrate 'go version -m' to use this package.

For #37475
Fixes #39301

Change-Id: I0fbe0896e04f12ef81c6d79fb61b20daede86159
Reviewed-on: https://go-review.googlesource.com/c/go/+/353887
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:44:08 +00:00
Jay Conrod
765c9116be cmd/go: move module build info formatting into runtime/debug
Previously, modload.PackageBuildInfo returned a string containing
information about modules used to build an executable. This string is
embedded in the binary and can be read with debug.ReadBuildInfo or
'go version -m'.

With this change, debug.BuildInfo now has a MarshalText method that
returns a string in the same format as modload.PackageBuildInfo.

Package.load now calls Package.setBuildInfo, which constructs a
debug.BuildInfo, formats it with MarshalText, then sets
Package.Internal.BuildInfo. This is equivalent to what
modload.PackageBuildInfo did.

modload.PackageBuildInfo is deleted, since it's no longer used.

For #37475

Change-Id: I5875a98cb64737637fec2a450ab2ffa7f1805707
Reviewed-on: https://go-review.googlesource.com/c/go/+/353886
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-14 18:43:59 +00:00
Damien Neil
011fd00245 sync: remove TestWaitGroupMisuse2 and TestWaitGroupMisuse3
These tests are inherently nondeterministic: They exercise a racy
code path for up to one million iterations, and require that an
error occur at least once.

TestWaitGroupMisuse2 in particular is an ongoing source of trybot
flakiness.

Fixes #38163.

Change-Id: Ibbbda2c998c915333487ad262d3df6829de01c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/340249
Trust: Damien Neil <dneil@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2021-10-14 17:38:39 +00:00
Robert Griesemer
fbdf83072c go/types: avoid infinite expansion for invalid recursive generic types
This is a clean port of CL 355732 from types2 to go/types.

Fixes #48951.

Change-Id: I9f8cc0655166835d9450608f6e50b726659a73f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/355733
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-14 15:17:03 +00:00
Robert Griesemer
ad99d8840e cmd/compile/internal/types2: avoid infinite expansion for invalid recursive generic types
The algorithm for detecting invalid recursive types that
expand indefinitely suffered from the exact problem is was
intended to detect: if the indefinite expansion is happening
through type parameters, the algorithm ended up in an infinite
sequence of instantiations. (This is only a problem for generic
types).

Changed the algorithm to always only consider the "original"
uninstantiated types. This avoids the problem but it will also
not detect some invalid recursive generic types anymore. That
requires a more sophisticated type flow analysis.
Opened #48962 to track.

Addressed with help from @findleyr.

For #48951.

Change-Id: Ie29cea8f810dae55153dbb1b17c9390cd823c2d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/355732
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-14 15:16:55 +00:00
Tobias Klauser
24e798e287 syscall: use fcntl with F_DUP2FD_CLOEXEC in forkAndExecInChild on FreeBSD
Use fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd) to duplicate the file
descriptor and mark is as close-on-exec instead of dup2 & fcntl.

FreeBSD implements dup3 like this in libc.

Change-Id: I36e37bc61c2e31561adb49001f287764125a74de
Reviewed-on: https://go-review.googlesource.com/c/go/+/355571
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-14 13:09:28 +00:00
Tobias Klauser
2feb2cc450 syscall: add support for SysProcAttr.Pdeathsig on FreeBSD
Fixes #46258

Change-Id: I63f70e67274a9df39c757243b99b12e50a9e4784
Reviewed-on: https://go-review.googlesource.com/c/go/+/355570
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-14 07:19:29 +00:00
Tobias Klauser
1349c6eb1e syscall: separate ProcSysAttr and forkAndExecInChild for FreeBSD
To allow adding fields to ProcSysAttr which are supported on FreeBSD but
not on other BSDs.

For now exec_freebsd.go is an exact copy of exec_bsd.go with adjusted
build tags and copyright year.

For #46258
For #46259

Change-Id: I7667a0cdf1ca86ef64a147b77c06db70c5f8eb90
Reviewed-on: https://go-review.googlesource.com/c/go/+/355569
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-14 07:18:59 +00:00
Ian Lance Taylor
9e4dc6f37f cmd/link/internal/ld: don't use linkname before 1.12
Before the 1.12 release the use of linkname did not prevent a compiler
error for an empty function body (see #23311). Add some build tags so
that cmd/link will build with earlier releases.

It's true that we currently require Go 1.16 as the bootstrap compiler (#44505).
But for this simple case keep things working with older compilers for now.

Change-Id: I67fe021406096c64c01d6e2c9adbcc4388988a6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/355690
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-10-14 04:18:44 +00:00
Robert Griesemer
276fb279d1 cmd/compile/internal/syntax: remove AllowTypeSets mode
The respective issue has been accepted, so we can always
accept constraint literals with omitted interfaces.

For #48424.

Change-Id: Ia3d325401252a5a22d5ffa98d2ae6af73178dec0
Reviewed-on: https://go-review.googlesource.com/c/go/+/355709
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-10-14 01:51:22 +00:00
Dan Scales
b90d258b18 cmd/compile: fix inst_test.go for riscv5
On riscv5, apparently extra wrappers (trampolines) are created for some
functions with the suffix "-tramp". Modify inst_test.go to not match
these "-tramp" wrappers.

Change-Id: I754c724f03555c30f8e1b5cfc08152555bbbcf17
Reviewed-on: https://go-review.googlesource.com/c/go/+/355650
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-10-13 20:31:25 +00:00
Matthew Dempsky
40f82f8a09 unsafe: optimize Slice bounds checking
This reduces the number of branches to bounds check non-empty slices
from 5 to 3. It does also increase the number of branches to handle
empty slices from 1 to 3; but for non-panicking calls, they should all
be predictable.

Updates #48798.

Change-Id: I3ffa66857096486f4dee417e1a66eb8fdf7a3777
Reviewed-on: https://go-review.googlesource.com/c/go/+/355490
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-13 18:15:48 +00:00
Matthew Dempsky
4efa216c9d unsafe: allow unsafe.Slice up to end of address space
Allow the user to construct slices that are larger than the Go heap as
long as they don't overflow the address space.

Updates #48798.

Change-Id: I659c8334d04676e1f253b9c3cd499eab9b9f989a
Reviewed-on: https://go-review.googlesource.com/c/go/+/355489
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-13 18:15:16 +00:00
James Harris
4a3daeee63 net/http/httputil: allow MIME parameters when detecting SSE in ReverseProxy
This change allows httputil.ReverseProxy to detect SSE (server-sent events)
content when the response's Content-Type header includes MIME parameters,
such as "text/event-stream;charset=utf-8".

Prior to this change the value of the Content-Type header was compared
directly to the literal "text/event-stream". This caused a false-negative
which failed to set the FlushInterval correctly when MIME parameters were
present.

Change-Id: If8bb43efb78787b6519d7fe7599ca018a0da0023
GitHub-Last-Rev: 224518c5eb
GitHub-Pull-Request: golang/go#48427
Reviewed-on: https://go-review.googlesource.com/c/go/+/350509
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-10-13 17:16:12 +00:00
Tamir Duberstein
b5904f3de0 net: remove timeout in TestDialTimeoutMaxDuration
This test seems only to be testing that Dial does not time out
immediately as a result of integer overflow; the precise time taken to
connect is immaterial. Replace naked loop with sub-tests.

Fixes #43069.

Change-Id: Ib5e38a1d8cd191b74c2bc7c26bef57b180e16f68
Reviewed-on: https://go-review.googlesource.com/c/go/+/355390
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-10-13 17:02:43 +00:00
Koichi Shiraishi
aded1679ef internal/poll,net: support poll.Sendfile for darwin
darwin already supports syscall.Sendfile.

Change-Id: Id3db06591ffad0550b4173bacddeb0acfe355f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/355109
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 16:41:20 +00:00
kjgorman
3986e5c8e7 bytes: fix Cut godoc typo
If sep does not appear in s, we return nil here
rather than the empty string. Presumably the docs
were copied from the  strings package implementation
and brought that along.

Change-Id: I3706c94fe04abd9e2a2c8840f7cc6116386965c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/354969
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 16:39:23 +00:00
Amelia Downs
69041c79dc net: add examples for remaining IP functions
Fixes #48848

Change-Id: If85fc16ed10a26eca840ed128ab47c5f00776ddd
Reviewed-on: https://go-review.googlesource.com/c/go/+/346289
Reviewed-by: Amelia Downs <adowns@vmware.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 16:36:59 +00:00
Forest Johnson
53260943ea os: explain ProccessState.Exited() SIGKILL interaction
When a process is forcefully killed (for example, with SIGKILL on unix), its ProccessState.Exited() will return false.

Change-Id: I8cebc8d28f2ba1b687c145f6d941647fc3a10665
GitHub-Last-Rev: 414ae1980f
GitHub-Pull-Request: golang/go#48871
Reviewed-on: https://go-review.googlesource.com/c/go/+/354698
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 15:56:29 +00:00
Mark Hansen
b8e4df01dd cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof

This adds the tagroot and tagleaf options from
7fe48b4c82

Done with:

  go get -d github.com/google/pprof@latest
  go mod tidy
  go mod vendor

Fixes #48839

Change-Id: I85bf0e0689310014eb198c8d5e0bb3a86b0aef1c
GitHub-Last-Rev: b26260f305
GitHub-Pull-Request: golang/go#48856
Reviewed-on: https://go-review.googlesource.com/c/go/+/354692
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:38:39 +00:00
zhouguangyuan
f687831e4c cmd/link: disable weak reference in itab if build with "-linkshared"
When build with "-linkshared", we can't tell if the interface method will be used or not. It can be used in shared library.

Fixes #47873

Change-Id: Iba12812f199b7679cf2fd41a304268d6d6dd03c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/350189
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:12:46 +00:00
helbing
0454d7346f embed: add example
Change-Id: I4e50e469047ac7efbf4ed464e238000dbdf53d6b
GitHub-Last-Rev: 8d29b73d11
GitHub-Pull-Request: golang/go#48785
Reviewed-on: https://go-review.googlesource.com/c/go/+/353936
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-10-13 15:11:16 +00:00
nicksherron
e8f99da8ed all: fix spelling mistakes
Corrections were only made to comments and can be reproduced with the
following sed.

sed -i 's/communciation/communication/g'  src/internal/fuzz/sys_windows.go
sed -i 's/communciation/communication/g'  src/internal/fuzz/sys_posix.go
sed -i 's/substitued/substituted/g'     src/cmd/compile/internal/noder/irgen.go

Change-Id: I435aee2fdb41e73b694e6233d52742559d32cf7e
GitHub-Last-Rev: a471e3d123
GitHub-Pull-Request: golang/go#48932
Reviewed-on: https://go-review.googlesource.com/c/go/+/355494
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-13 04:00:15 +00:00