Robert Griesemer [Wed, 19 Oct 2022 03:41:14 +0000 (20:41 -0700)]
go/types, types2: replace typecheck with mustTypecheck almost everywhere (cleanup)
Replace even in places where before we have a specific error message
or different control-flow (except in TestTypeString or TestObjectString)
because failing to type-check in virtually all cases represents an error
in the test itself.
Change-Id: I9f1e6d25bddd92c168353409b281b5a3f29a747c
Reviewed-on: https://go-review.googlesource.com/c/go/+/443915
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Bryan C. Mills [Wed, 19 Oct 2022 18:09:54 +0000 (14:09 -0400)]
go/internal/gcimporter,cmd/compile/internal/importer: use testenv.MustHaveGoBuild directly
These tests previously had a “skipSpecialPlatforms” function, added in
CL 8611 to skip tests on (apparently) NaCL and iOS. The iOS builders
no longer match the condition (GOOS=ios is its own thing now), and the
NaCL port no longer exists.
The name of the function also isn't very evocative, since it doesn't
say what is “special” about the platforms to cause them to be
skipped.m
Since the check is intending to run the tests only on platforms where
gc export data is available, and to a first approximation
“gc export data is available” on exactly the platforms that can run
“go build” to produce that export data, we can use the testenv function
instead of a one-off.
Michael Pratt [Tue, 18 Oct 2022 16:11:43 +0000 (12:11 -0400)]
runtime: throw in unreachable exitThread
Several OSes don't ever reach exitThread, On AIX, Plan9, Solaris, and
Windows, we throw if this function is accidentally reached. Do the same
on Darwin and OpenBSD for consistency.
Change-Id: Icd189b11179755a28b3ec48b267349c57facbf24
Reviewed-on: https://go-review.googlesource.com/c/go/+/443717 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Michael Pratt [Tue, 18 Oct 2022 16:01:18 +0000 (12:01 -0400)]
runtime: always keep global reference to mp until mexit completes
Ms are allocated via standard heap allocation (`new(m)`), which means we
must keep them alive (i.e., reachable by the GC) until we are completely
done using them.
Ms are primarily reachable through runtime.allm. However, runtime.mexit
drops the M from allm fairly early, long before it is done using the M
structure. If that was the last reference to the M, it is now at risk of
being freed by the GC and used for some other allocation, leading to
memory corruption.
Ms with a Go-allocated stack coincidentally already keep a reference to
the M in sched.freem, so that the stack can be freed lazily. This
reference has the side effect of keeping this Ms reachable. However, Ms
with an OS stack skip this and are at risk of corruption.
Fix this lifetime by extending sched.freem use to all Ms, with the value
of mp.freeWait determining whether the stack needs to be freed or not.
Fixes #56243.
Change-Id: Ic0c01684775f5646970df507111c9abaac0ba52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/443716
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Michael Matloob [Wed, 21 Sep 2022 19:51:27 +0000 (15:51 -0400)]
go,cmd,internal: update to anticipate missing targets and .a files
go/build and cmd/go will stop returing Targets for stdlib .a files, and
stop producing the .a files is pkg/GOOS_GOARCH. update tests to
anticipate that and to pass in importcfgs instead of expecting the
compiler can find .a files in their old locations.
Adds code to determine locations of .a files to internal/goroot. Also
adds internal/goroot to dist's bootstrap directories and changes
internal/goroot to build with a bootstrap version of Go.
Change-Id: Ie81e51105bddb3f0e374cbf47e81c23edfb67fa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/442303 Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Than McIntosh [Tue, 18 Oct 2022 15:28:52 +0000 (11:28 -0400)]
cmd/compile: special case coverage vars in pkg init order
When computing package initialization order, special case the counter
variables inserted by "cmd/cover" for coverage instrumentation, since
their presence can perturb the order in which variables are
initialized in ways that are user-visible and incorrect with respect
to the original (uninstrumented) program.
Fixes #56293.
Change-Id: Ieec9239ded4f8e2503ff9bbe0fe171afb771b335
Reviewed-on: https://go-review.googlesource.com/c/go/+/443715
Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Youlin Feng [Wed, 5 Oct 2022 07:29:29 +0000 (15:29 +0800)]
runtime: replace all uses of CtzXX with TrailingZerosXX
Replace all uses of Ctz64/32/8 with TrailingZeros64/32/8, because they
are the same and maybe duplicated. Also renamed CtzXX functions in 386
assembly code.
Change-Id: I19290204858083750f4be589bb0923393950ae6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/438935 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Michael Pratt [Mon, 17 Oct 2022 19:57:48 +0000 (15:57 -0400)]
runtime: avoid unsafe.{Slice,String} in debuglog
CL 428157 and CL 428759 switched debuglog to using unsafe.String and
unsafe.Slice, which broke the build with -tags=debuglog because this is
a no write barrier context, but runtime.unsafeString and unsafeSlice can
panic, which includes write barriers.
We could add a panicCheck1 path to these functions to reallow write
barriers, but it is a big mess to pass around the caller PC,
particularly since the compiler generates calls. It is much simpler to
just avoid unsafe.String and Slice.
Also add a basic test to build the runtime with -tags=debuglog to help
avoid future regressions.
For #54854.
Change-Id: I702418b986fbf189664e9aa4f40bc7de4d9e7781
Reviewed-on: https://go-review.googlesource.com/c/go/+/443380
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Russ Cox [Mon, 17 Oct 2022 19:34:50 +0000 (15:34 -0400)]
internal/godebug: remove dependency on os
The immediate reason is that we want to use godebug from math/rand,
and math/rand importing godebug importing os causes an import cycle
in package testing.
More generally, the new approach to backward compatibility outlined
in discussion #55090 will require using this package from other similarly
sensitive places, perhaps even package os itself. Best to remove all
dependencies.
fangguizhen [Mon, 17 Oct 2022 18:32:36 +0000 (18:32 +0000)]
errors: add test for Join
Change-Id: I77c61211a488c66f1d445c0bf01e35aaf4f83565
GitHub-Last-Rev: c411a56a3b5215e6dd093be7069affb176b48dfd
GitHub-Pull-Request: golang/go#56279
Reviewed-on: https://go-review.googlesource.com/c/go/+/443316
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Russ Cox [Thu, 6 Oct 2022 01:13:08 +0000 (21:13 -0400)]
all: use Go 1.17.13 for bootstrap
Previously we used Go 1.17, but we realized thanks to tickling
a pre-Go1.17.3 bug that if we are going to change the bootstrap
toolchain that we should default to the latest available point release
at the time we make the switch, not the initial major release, so as
to avoid bugs that were fixed in the point releases.
This CL updates the default search locations and the release notes.
Users who run make.bash and depend on finding $HOME/sdk/go1.17
may need to run
go install golang.org/dl/go1.17.13@latest
go1.17.13 download
to provide a Go 1.17.13 toolchain to their builds.
Change-Id: I3a2511f088cf852470a7216a5a41ae775fb561b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/439419 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Russ Cox [Mon, 17 Oct 2022 13:29:05 +0000 (09:29 -0400)]
internal/fuzz: write shorter testdata corpus file names
The only purpose of using the SHA256 in the file name is
collision avoidance. Using just the first 64 bits (16 hex digits)
will be more than enough, unless people start storing billions
of test cases in their corpora.
The shorter names are nicer for just about everything:
command lines, repository listings, and so on.
David Chase [Fri, 14 Oct 2022 20:24:44 +0000 (16:24 -0400)]
cmd/compile: fix position of fake receivers; be more careful in logopt
The src.NoXPos in fake receivers was leaking, through a series of
mishaps, all the way to logopt. If done just so, this can lead to
a compiler crash. This makes logopt crash-proof and eliminates the
root cause as well.
I'm reluctant to write a test for this because it's kinda slow
and involved; my working test is "compile something that mentions
the flag package with -json=0,$TMPDIR flag, then be sure that
$TMPDIR/flag/__unnamed__.json was not created".
Change-Id: I384b717c0e7522953d22d61f7e06319e11192d7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/443156
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
Ian Lance Taylor [Fri, 14 Oct 2022 23:19:11 +0000 (16:19 -0700)]
os/signal: pass *int32 to ioctl that expects pid_t
Fixes #56233
Change-Id: I1cf176bc2f39c5e41d5a390ec6893426cdd39be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/443175
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Austin Clements [Fri, 14 Oct 2022 13:51:52 +0000 (09:51 -0400)]
misc/cgo/fortran: convert to Go test
Currently, the entry-point to this test is a Bash script that smoke
tests the FORTRAN compiler and then runs a FORTRAN-containing Go test.
This CL rearranges things so a pure Go Go test smoke tests the FORTRAN
compiler and then runs a non-test FORTRAN-containing Go binary.
While we're here, we fix a discrepancy when the host is GOARCH=amd64,
but the target is GOARCH=386. Previously, we would pick the wrong
libgfortran path because we didn't account for the cross-compilation,
causing the link to fail. Except for some reason this was ignored and
the test nevertheless "passed". In the new test we're a little more
strict, so this build failure will cause the test to fail, so we add a
little logic to account for cross-compilation with the host toolchain.
Austin Clements [Fri, 14 Oct 2022 19:36:58 +0000 (15:36 -0400)]
runtime: improve coverage of TestCgoSigfwd
Currently, TestCgoSigfwd will pass incorrectly if the SIGSEGV that
originates in Go mistakenly goes to the C SIGSEGV handler. Fix this by
adding a signal-atomic variable that tracks what the expected behavior
is.
Austin Clements [Fri, 14 Oct 2022 18:50:19 +0000 (14:50 -0400)]
misc/cgo/testsigfwd: move to runtime/testprog/testprogcgo
This migrates testsigfwd, which uses some one-off build
infrastructure, to be part of the runtime's testprogcgo.
The test is largely unchanged. Because it's part of a larger binary,
this CL renames a few things and gates the constructor-time signal
handler registration on an environment variable. This CL also replaces
an errant fmt.Errorf with fmt.Fprintf.
For #37486, since it eliminates a non-go-test from dist.
Wayne Zuo [Fri, 7 Oct 2022 04:19:32 +0000 (12:19 +0800)]
cmd/compile: split 3 operand LEA in late lower pass
On newer amd64 cpus 3 operand LEA instructions are slow, CL 114655 split
them to 2 LEA instructions in genssa.
This CL make late lower pass run after addressing modes, and split 3
operand LEA in late lower pass so that we can do common-subexpression
elimination for splited LEAs.
Updates #21735
Change-Id: Ied49139c7abab655e1a14a6fd793bdf9f987d1f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/440035
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Joedian Reid <joedian@golang.org>
hopehook [Fri, 7 Oct 2022 14:42:15 +0000 (22:42 +0800)]
reflect: panic when Value.Equal using two non-comparable values
Assuming the two values are valid and non-comparable, Equal should panic.
x := reflect.ValueOf([]int{1, 2, 3})
x.Equal(x) // can not report false, should panic
Assuming one of them is non-comparable and the other is invalid, it should
always report false.
x := reflect.ValueOf([]int{1, 2, 3})
y := reflect.ValueOf(nil)
x.Equal(y) // should report false
For #46746.
Change-Id: Ifecd77ca0b3de3019fae2be39048f9277831676c
Reviewed-on: https://go-review.googlesource.com/c/go/+/440037 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Zamicol [Fri, 14 Oct 2022 03:10:28 +0000 (03:10 +0000)]
flag: remove "// BUG" comment
Remove a vestigial " // BUG" comment as there is no bug in the relevant code section and comment predated other changes. Also removed a needless allocation and conformed to the "v, ok := a[x]" standard convention. Tests are passing.
Change-Id: Id28ad1baf77447052b54b341f018e573bac0c11a
GitHub-Last-Rev: 26084698bfc0972d7e0fec0de4f31cc87e3a5f7a
GitHub-Pull-Request: golang/go#56210
Reviewed-on: https://go-review.googlesource.com/c/go/+/442815 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Change-Id: I171905d5cd7a121de549827ef4d5968510aa3efc
Reviewed-on: https://go-review.googlesource.com/c/go/+/436705 Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Dan Kortschak [Sun, 16 Oct 2022 09:30:42 +0000 (20:00 +1030)]
runtime: remove redundant conversion
This appears to have been left over from a C cast during the rewrite of
malloc into Go in https://golang.org/cl/108840046.
Change-Id: I88f212089c2bcf79d5881b3e8bf3f94f343331d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/443235
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Joe Tsai [Wed, 2 Mar 2022 21:01:48 +0000 (13:01 -0800)]
reflect: add Value.Grow
The Grow method is like the proposed slices.Grow function
in that it ensures that the slice has enough capacity to append
n elements without allocating.
The implementation of Grow is a thin wrapper over runtime.growslice.
This also changes Append and AppendSlice to use growslice under the hood.
Fixes #48000
Change-Id: I992a58584a2ff1448c1c2bc0877fe76073609111
Reviewed-on: https://go-review.googlesource.com/c/go/+/389635
Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Austin Clements [Fri, 14 Oct 2022 18:19:14 +0000 (14:19 -0400)]
misc/cgo/testasan: drop test
The testasan test was added back in 2013 (CL 10126044), many years
before Go added ASAN support in 2021 (CL 298611). So, in fact,
testasan does not test Go ASAN support at all, as you might expect
(misc/cgo/testsanitizers does that). It's intended to test whether the
Go memory allocator works in a mixed C/Go binary where the C code is
compiled with ASAN. The test doesn't actually use ASAN in any way; it
just simulates where ASAN of 2013 put its shadow mappings. This made
sense to test at the time because Go was picky about where its heap
landed and ASAN happened to put its mappings exactly where Go wanted
to put its heap. These days, Go is totally flexible about its heap
placement, and I wouldn't be surprised if ASAN also works differently.
Given all of this, this test adds almost no value today. Drop it.
For #37486, since it eliminates a non-go-test from dist.
Austin Clements [Wed, 9 Feb 2022 14:38:01 +0000 (09:38 -0500)]
cmd/dist: drop support for pre-compiled test binaries
We haven't used this in a while and it's going to complicate later
changes to dist, so drop support. This was primarily for supporting
slow QEMU-based builders, but an alternative and simpler way to do
that if we need to in the future is to supply a go_exec wrapper to run
tests in QEMU, like we do for other emulated platforms.
Dmitri Goutnik [Thu, 22 Sep 2022 11:59:42 +0000 (06:59 -0500)]
cmd/link: return correct default linker for the platform
If no external linker was passed with -extld, link currently assumes
that it is "gcc" which is not correct for platforms that use clang
toolchain. Return "clang" for platforms that use it, this fixes dir
tests on freebsd/riscv64.
For #53466
Change-Id: Ie3bce1b9581839d0b3b2129908355cd30ae9a713
Reviewed-on: https://go-review.googlesource.com/c/go/+/432756
Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Mikaël Urankar <mikael.urankar@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org>
Florian Zenker [Fri, 14 Oct 2022 09:13:38 +0000 (09:13 +0000)]
debug/elf: fix inccorrect value in COMPRESS_ZLIB string name
LLVM recently introduced ZSTD compression for ELF sections. The error
message when failing to read the compressed section calls this
COMPRESS_ZLIB+2 while it should report it as COMPRESS_ZLIB+1.
Change-Id: I869aa69baf0c8c86665475b47343c790587cb39b
Reviewed-on: https://go-review.googlesource.com/c/go/+/443035 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Pratt [Tue, 4 Oct 2022 16:50:03 +0000 (12:50 -0400)]
os/signal: rewrite TestTerminalSignal without bash
The existing version of this test contains several races it tries to
control with sleeps. Unfortunately, it is still flaky on darwin because
writing `fg` in bash too early can apparently result in failure to
actually continue the stopped child.
Rather than continuing to get perfect timing with bash, rewrite this to
eliminate bash and instead perform the same PTY operations that bash
would do.
This test is still quite complex because psuedo-terminals are
interminably complicated, but I believe it is no longer racy.
Technically there are still two races (waiting for child to enter read()
and waiting for the darwin kernel to wake the read after TIOCSPGRP), but
loss of either of these races should only mean we fail to test the
desired darwin EINTR case, not failure.
This test is skipped on DragonflyBSD, as it tickles a Wait hang bug
(#56132).
Updates #56132.
Fixes #37329.
Change-Id: I0ceaf5aa89f6be0f1bf68b2140f47db673cedb33
Reviewed-on: https://go-review.googlesource.com/c/go/+/440220
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Michael Pratt [Fri, 30 Sep 2022 21:08:43 +0000 (17:08 -0400)]
runtime/pprof: set Function.start_line field
Now that we plumb the start line to the runtime, we can include in pprof
files. Since runtime.Frame.startLine is not (currently) exported, we
need a runtime helper to get the value.
For #55022.
Updates #56135.
Change-Id: Ifc5b68a7b7170fd7895e4099deb24df7977b22ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/438255
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Austin Clements <austin@google.com>
Michael Pratt [Wed, 7 Sep 2022 17:23:19 +0000 (13:23 -0400)]
cmd/compile,cmd/link,runtime: add start line numbers to func metadata
This adds the function "start line number" to runtime._func and
runtime.inlinedCall objects. The "start line number" is the line number
of the func keyword or TEXT directive for assembly.
Subtracting the start line number from PC line number provides the
relative line offset of a PC from the the start of the function. This
helps with source stability by allowing code above the function to move
without invalidating samples within the function.
Encoding start line rather than relative lines directly is convenient
because the pprof format already contains a start line field.
This CL uses a straightforward encoding of explictly including a start
line field in every _func and inlinedCall. It is possible that we could
compress this further in the future. e.g., functions with a prologue
usually have <line of PC 0> == <start line>. In runtime.test, 95% of
functions have <line of PC 0> == <start line>.
According to bent, this is geomean +0.83% binary size vs master and
-0.31% binary size vs 1.19.
Note that //line directives can change the file and line numbers
arbitrarily. The encoded start line is as adjusted by //line directives.
Since this can change in the middle of a function, `line - start line`
offset calculations may not be meaningful if //line directives are in
use.
For #55022.
Change-Id: Iaabbc6dd4f85ffdda294266ef982ae838cc692f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/429638
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Dmitri Goutnik [Wed, 8 Jun 2022 15:55:42 +0000 (10:55 -0500)]
cmd/go: enable -msan on freebsd/amd64
Enable -msan flag on freebsd/amd64 and amend PIE comment in
internal/work/init.go to indicate that MSAN requires PIE on all platforms
except linux/amd64.
R=go1.20
For #53298
Change-Id: I93d94efa95d7f292c23c433fb1d3f4301d820bde
Reviewed-on: https://go-review.googlesource.com/c/go/+/411275 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Bryan C. Mills [Wed, 12 Oct 2022 18:57:47 +0000 (14:57 -0400)]
os: split wait6 syscall wrapper into per-platform files
There are getting to be enough special cases in this wrapper that
the increase in clarity from having a single file is starting to be
outweighed by the complexity from chained conditionals.
Dmitri Goutnik [Wed, 15 Jun 2022 19:50:19 +0000 (14:50 -0500)]
cmd/link: define ELF .note section on FreeBSD
Write .note signature section when targeting FreeBSD, similar to NetBSD
and OpenBSD. This allows binaries to declare the ABI version they were
compiled for and opt out of ASLR when compiled with -race.
Fixes #48164
Change-Id: Ie54dd5c70697a3f42a75fd640540350fd8a4dc71
Reviewed-on: https://go-review.googlesource.com/c/go/+/412494 Reviewed-by: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Michael Matloob [Wed, 5 Oct 2022 23:06:23 +0000 (19:06 -0400)]
cmd/go: avoid setting mod=vendor in workspace mode
Workspaces with a single module would enter mod=vendor mode even when
in workspace mode. Fix that by explicitly checking that we're not in
workspace mode when deciding whether to enter vendor mode.
Bryan C. Mills [Wed, 12 Oct 2022 19:11:16 +0000 (15:11 -0400)]
os/exec: reduce arbitrary sleeps in TestWaitid
If we use the "pipetest" helper command instead of "sleep",
we can use its stdout pipe to determine when the process
is ready to handle a SIGSTOP, and we can additionally check
that sending a SIGCONT actually causes the process to continue.
This also allows us to remove the "sleep" helper command,
making the test file somewhat more concise.
Cherry Mui [Wed, 12 Oct 2022 20:24:34 +0000 (16:24 -0400)]
cmd/link: don't reset variable size when handling -X flag
The linker's -X flag allows setting/changing a string variable's
content at link time. Currently it resets its size then write a
new string header pointing to the new content. This mostly works.
But under ASAN build the string variable can have larger size
than the usual 2 words, due to the red zone. Resetting the size
can cause the variable to "overlap" (in ASAN's view) with other
variables. Don't reset the size.
Fixes #56175.
Change-Id: Ib364208201a7a2fd7f44f9b1797834198736a405
Reviewed-on: https://go-review.googlesource.com/c/go/+/442635
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Roland Shoemaker [Wed, 28 Sep 2022 21:52:33 +0000 (14:52 -0700)]
debug: add top level security docs for dwarf, elf, macho, pe, and plan9obj
Adds a package level doc comment to the debug/dwarf, debug/elf,
debug/macho, debug/pe, and debug/plan9obj noting that these packages
are not designed to be hardened against adversarial inputs.
Change-Id: I678d01bcdc8ad01c23805f09cc59e64cec6c3f76
Reviewed-on: https://go-review.googlesource.com/c/go/+/435417 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Park Zhou [Sat, 8 Oct 2022 17:00:39 +0000 (17:00 +0000)]
crypto/x509: add blank line before package declaration
The package doc included the copying header by mistake.
Change-Id: I37ac2d14b1b8a389e6b603fbb1c6a3a33b1d80d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/440456 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org>
Robert Findley [Sat, 13 Aug 2022 16:35:57 +0000 (12:35 -0400)]
go/types, types2: optimize instance lookup in LookupFieldOrMethod
LookupFieldOrMethod appears as a hotspot when benchmarking gopls'
auto-completion. In particular, instanceLookup.add was allocating in the
common case of structs with no embedding.
This is easily fixed, by using a small array in front of the map inside
of instanceLookup. Do this, and additionally add a microbenchmark.
The benchmark improvement is significant:
name old time/op new time/op delta
LookupFieldOrMethod-12 388µs ± 6% 154µs ± 3% -60.36% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
LookupFieldOrMethod-12 152kB ± 0% 2kB ± 0% -98.77% (p=0.000 n=9+10)
name old allocs/op new allocs/op delta
LookupFieldOrMethod-12 1.41k ± 0% 0.07k ± 0% -95.38% (p=0.000 n=10+10)
It should also be noted that instanceLookup is used elsewhere, in
particular by validType. In those contexts, the scope is not just the
current type but the entire package, and so the newly added buffer is
likely to simply cause extra Identical checks. Nevertheless, those
checks are cheap, and on balance the improved LookupFieldOrMethod
performance leads overall to improved type-checking performance.
Standard library benchmark results varied by package, but type checking
speed for many packages improved by ~5%, with allocations improved by
~10%. If this weren't the case we could let the caller control the
buffer size, but that optimization doesn't seem necessary at this time.
Ian Lance Taylor [Mon, 10 Oct 2022 21:07:10 +0000 (14:07 -0700)]
debug/elf: validate phentsize and shentsize
No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.
Fixes #56129
Change-Id: I6c81933781384c5e2c8ba0fd99cec50455b9664a
Reviewed-on: https://go-review.googlesource.com/c/go/+/441976 Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Tue, 11 Oct 2022 22:09:02 +0000 (15:09 -0700)]
os/signal: document behavior of SIGPIPE on non-Go thread
Fixes #56150
Change-Id: Id990783562950ba8be7ce9526b7a811625f2190a
Reviewed-on: https://go-review.googlesource.com/c/go/+/442415
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Michael Anthony Knyszek [Fri, 12 Aug 2022 23:25:56 +0000 (23:25 +0000)]
arena: add experimental arena package
This change adds the arenas package and a function to reflect for
allocating from an arena via reflection, but all the new API is placed
behind a GOEXPERIMENT.
For #51317.
Change-Id: I026d46294e26ab386d74625108c19a0024fbcedc
Reviewed-on: https://go-review.googlesource.com/c/go/+/423361 Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Anthony Knyszek [Fri, 12 Aug 2022 21:40:46 +0000 (21:40 +0000)]
runtime: add safe arena support to the runtime
This change adds an API to the runtime for arenas. A later CL can
potentially export it as an experimental API, but for now, just the
runtime implementation will suffice.
The purpose of arenas is to improve efficiency, primarily by allowing
for an application to manually free memory, thereby delaying garbage
collection. It comes with other potential performance benefits, such as
better locality, a better allocation strategy, and better handling of
interior pointers by the GC.
This implementation is based on one by danscales@google.com with a few
significant differences:
* The implementation lives entirely in the runtime (all layers).
* Arena chunks are the minimum of 8 MiB or the heap arena size. This
choice is made because in practice 64 MiB appears to be way too large
of an area for most real-world use-cases.
* Arena chunks are not unmapped, instead they're placed on an evacuation
list and when there are no pointers left pointing into them, they're
allowed to be reused.
* Reusing partially-used arena chunks no longer tries to find one used
by the same P first; it just takes the first one available.
* In order to ensure worst-case fragmentation is never worse than 25%,
only types and slice backing stores whose sizes are 1/4th the size of
a chunk or less may be used. Previously larger sizes, up to the size
of the chunk, were allowed.
* ASAN, MSAN, and the race detector are fully supported.
* Sets arena chunks to fault that were deferred at the end of mark
termination (a non-public patch once did this; I don't see a reason
not to continue that).
For #51317.
Change-Id: I83b1693a17302554cb36b6daa4e9249a81b1644f
Reviewed-on: https://go-review.googlesource.com/c/go/+/423359 Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Michael Anthony Knyszek [Tue, 20 Sep 2022 18:33:03 +0000 (18:33 +0000)]
runtime: make (*mheap).sysAlloc more general
This change makes (*mheap).sysAlloc take an explicit list of hints and a
boolean as to whether or not any newly-created heapArenas should be
registered in the full arena list.
This is a refactoring in preparation for arenas.
For #51317.
Change-Id: I0584a033fce3fcb60c5d0bc033d5fb8bd23b2378
Reviewed-on: https://go-review.googlesource.com/c/go/+/432078
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Bryan C. Mills [Wed, 12 Oct 2022 17:29:01 +0000 (13:29 -0400)]
os: use the correct constant for P_PID on NetBSD
Dragonfly and FreeBSD both used numerical values for these constants
chosen to be the same as on Solaris. For some reason, NetBSD did not,
and happens to interpret value 0 as P_ALL instead of P_PID
(see https://github.com/NetBSD/src/blob/3323ceb7822f98b3d2693aa26fd55c4ded6d8ba4/sys/sys/idtype.h#L43-L44).
Using the correct value for P_PID should cause wait6 to wait for the
correct process, which may help to avoid the deadlocks reported in
Bill Zissimopoulos [Wed, 12 Oct 2022 10:39:27 +0000 (10:39 +0000)]
runtime: fix invalid pointer in windows/arm64 badsignal2
Initializes the R3 register with an available address in the stack. The addressed location is used to receive the number of bytes written by WriteFile.
Cuong Manh Le [Tue, 11 Oct 2022 04:56:51 +0000 (11:56 +0700)]
all: prevent fakePC overflow on 386 in libfuzzer mode
fakePC uses hash.Sum32, which returns an uint32. However, libfuzzer
trace/hook functions declare fakePC argument as int, causing overflow on
386 archs.
Fixing this by changing fakePC argument to uint to prevent the overflow.
Fixes #56141
Change-Id: I3994c461319983ab70065f90bf61539a363e0a2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/441996
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Robert Griesemer [Mon, 10 Oct 2022 20:13:14 +0000 (13:13 -0700)]
go/types: add errorcalls_test, apply it, and fix errorf call sites
The errorcalls_test makes sure that we use error instead of errorf
where possible. Copied from types2 and adjusted for go/types.
Change-Id: Ib0572308c87e4415bf89aec8d64e662abe94754b
Reviewed-on: https://go-review.googlesource.com/c/go/+/441958 Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Michael Matloob [Thu, 6 Oct 2022 20:14:47 +0000 (16:14 -0400)]
cmd/go: set dependency go versions for go install --mod=readonly mod@vers
When running go install --mod=readonly module@version. modfetch.GoSumFile
was not set, so the checksumOk check that's done when checking whether
we need to set the GoVersion from the go mod file was failing. Bypass
the checksumOk check when there's no GoSumFile.
Ian Lance Taylor [Tue, 11 Oct 2022 18:21:13 +0000 (11:21 -0700)]
math/big: error on buffer length overflow in Rat.GobDecode
Fixes #56156
Change-Id: Ib85ff45f0b0d0eac83c39606ee20b3a312e6e919
Reviewed-on: https://go-review.googlesource.com/c/go/+/442335
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Matloob [Fri, 30 Sep 2022 20:49:42 +0000 (16:49 -0400)]
cmd/go: do not exit with non-zero code from go list -e -export
go list -e -export puts errors running build actions on the load.Package
corresponding to the failed action rather than exiting with a non zero
exit code.
Bryan C. Mills [Wed, 5 Oct 2022 18:04:55 +0000 (14:04 -0400)]
os/exec: remove protection against a duplicate Close on StdinPipe
As of CL 438347, multiple concurrents calls to Close should be safe.
This removes some indirection and may also make some programs that use
type-assertions marginally more efficient. For example, if a program
calls (*exec.Cmd).StdinPipe to obtain a pipe and then sets that as the
Stdout of another command, that program will now allow the second
command to inherit the file descriptor directly instead of copying
everything through a goroutine.
This will also cause calls to Close after the first to return an error
wrapping os.ErrClosed instead of nil. However, it seems unlikely that
programs will depend on that error behavior: if a program is calling
Write in a loop followed by Close, then if a racing Close occurs it is
likely that the Write would have already reported an error. (The only
programs likely to notice a change are those that call Close — without
Write! — after a call to Wait.)
Joel Sing [Sun, 4 Sep 2022 17:03:35 +0000 (03:03 +1000)]
cmd/compile: convert SLT/SLTU with constant into immediate form on riscv64
Convert SLT/SLTU with a suitably valued constant into a SLTI/SLTIU instruction.
This can reduce instructions and avoid register loads. Now that we generate
more SLTI/SLTIU instructions, absorb these into branches when it makes sense
to do so.
Removes more than 800 instructions from the Go binary on linux/riscv64.
Change-Id: I42c4e00486697acd4da7669d441b5690795f18ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/428499 Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org>
Ian Lance Taylor [Sat, 8 Oct 2022 18:17:47 +0000 (11:17 -0700)]
test: add test case that caused a bogus error from gofrontend
For #56109
Change-Id: I999763e463fac57732a92f5e396f8fa8c35bd2e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/440297
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>