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

41641 Commits

Author SHA1 Message Date
Matthew Dempsky
dded58760d cmd/compile: enable -d=checkptr when -race or -msan is specified
It can still be manually disabled again using -d=checkptr=0.

It's also still disabled by default for GOOS=windows, because the
Windows standard library code has a lot of unsafe pointer conversions
that need updating.

Updates #34964.

Change-Id: Ie0b8b4fdf9761565e0dcb00d69997ad896ac233d
Reviewed-on: https://go-review.googlesource.com/c/go/+/201783
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-22 23:28:20 +00:00
Matthew Dempsky
5a5854c2d1 runtime: fix -d=checkptr failure for testing/quick
This CL extends checkptrBase to recognize pointers into the stack and
data/bss sections. I was meaning to do this eventually anyway, but
it's also an easy way to workaround #35068.

Updates #35068.

Change-Id: Ib47f0aa800473a4fbc249da52ff03bec32c3ebe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/202639
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2019-10-22 23:14:03 +00:00
Ian Lance Taylor
7d84245a9c runtime: implement time.Sleep for new timers
Updates #27707

Change-Id: I51da8a04ec12ba1efa435e86e3a15d4d13c96c45
Reviewed-on: https://go-review.googlesource.com/c/go/+/171879
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 22:35:20 +00:00
Ian Lance Taylor
432ca0ea83 runtime: add new runtimer function
Updates #27707

Change-Id: I1e65effb708911c727d126c51e0f50fe219f42ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/171878
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 22:15:25 +00:00
Ian Lance Taylor
220150ff3c runtime: add new adjusttimers function
The adjusttimers function is where we check the adjustTimers field in
the P struct to see if we need to resort the heap. We walk forward in
the heap and find and resort timers that have been modified, until we
find all the timers that were modified to run earlier. Along the way
we remove deleted timers.

Updates #27707

Change-Id: I1cba7fe77b8112b7e9a9dba80b5dfb08fcc7c568
Reviewed-on: https://go-review.googlesource.com/c/go/+/171877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 21:40:27 +00:00
Jay Conrod
b2ea4e6d34 cmd/go: make 'go mod verify' report an error outside a module
Also, test that 'go mod download' without arguments reports an error.

Fixes #32027

Change-Id: I873fc59fba4c78ee2b4f49f0d846ee2ac0eee4db
Reviewed-on: https://go-review.googlesource.com/c/go/+/202697
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 21:34:48 +00:00
Ian Lance Taylor
7d891d5e4d runtime: implement new movetimers function
Updates #27707

Change-Id: Idda31d0065064a81c570e291ef588d020871997d
Reviewed-on: https://go-review.googlesource.com/c/go/+/171836
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 21:23:03 +00:00
Ian Lance Taylor
4665470147 runtime: add new cleantimers function
Also add a skeleton of the runOneTimer function.

Updates #27707

Change-Id: Ic6a0279354a57295f823093704b7e152ce5d769d
Reviewed-on: https://go-review.googlesource.com/c/go/+/171835
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 21:04:09 +00:00
Matthew Dempsky
daeb5efb20 runtime: somewhat better checkptr error messages
They're still lacking in details, but at least better than being
printed as raw interface values.

Updates #22218.

Change-Id: I4fd813253afdd6455c0c9b5a05c61659805abad1
Reviewed-on: https://go-review.googlesource.com/c/go/+/202677
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-22 20:50:04 +00:00
Ian Lance Taylor
9093b1def0 runtime: add new dodeltimer and dodeltimer0 functions
The dodeltimer function removes a timer from a heap. The dodeltimer0
function removes the first timer from a heap; in the old timer code
this common special case was inlined in the timerproc function.

Updates #27707

Change-Id: I1b7c0af46866abb4bffa8aa4d8e7143f9ae8f402
Reviewed-on: https://go-review.googlesource.com/c/go/+/171834
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-10-22 20:45:48 +00:00
Ben Shi
b12703e052 cmd/compile: remove amd64p32 related SSA rules
Updates golang/go#30439

Change-Id: Iadc737e4c6bb05bb576fe4bb344ad92403697352
Reviewed-on: https://go-review.googlesource.com/c/go/+/201380
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-10-22 20:41:47 +00:00
Ian Lance Taylor
eff3c1e426 runtime: add new resettimer function
Updates #27707

Change-Id: I02f97ec7869ec8a3fb2dfc94cff246badc7ea0fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/171833
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 20:22:27 +00:00
Jay Conrod
4be6b4a73d cmd/go/internal/modfile: prepare to move to x/mod
- Deleted dead code in gopkgin.go.
- Minor documentation changes.

Updates #34924

Change-Id: Ie2c744bbf6662cae20f09163200f20d7589fd237
Reviewed-on: https://go-review.googlesource.com/c/go/+/202565
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 20:00:32 +00:00
Jay Conrod
8ba43eaad8 cmd/go: support -modcacherw in 'go mod' subcommands
The -modcacherw flag is now registered in work.AddModCommonFlags,
which is called from work.AddBuildFlags, where it was registered
before. 'go mod' subcommands register the flag by calling
work.AddModCommonFlags directly.

Also, build commands now exit with an error if -modcacherw is set
explicitly (not in GOFLAGS) in GOPATH mode.

Updates #31481

Change-Id: I461e59a51ed31b006fff4d5c57c2a866be0bbf38
Reviewed-on: https://go-review.googlesource.com/c/go/+/202563
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 20:00:03 +00:00
Brad Fitzpatrick
88186e5e23 net/http: don't cache http2.erringRoundTripper connections
Fixes #34978

Change-Id: I3baf1392ba7366ae6628889c47c343ef702ec438
Reviewed-on: https://go-review.googlesource.com/c/go/+/202078
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 19:46:38 +00:00
smasher164
03fb1f607b cmd/compile: don't use FMA on plan9
CL 137156 introduces an intrinsic on AMD64 that executes vfmadd231sd
when feature detection is successful. However, because floating-point
isn't allowed in note handler, the builder disables SSE instructions,
and fails when attempting to execute this instruction. This change
disables FMA on plan9 to immediately use the software fallback.

Fixes #35063.

Change-Id: I87d8f0995bd2f15013d203e618938f5079c9eed2
Reviewed-on: https://go-review.googlesource.com/c/go/+/202617
Reviewed-by: Keith Randall <khr@golang.org>
2019-10-22 19:36:42 +00:00
Ian Lance Taylor
48eb79ec21 runtime: add new modtimer function
This adds a new field to P, adjustTimers, that tells the P that one of
its existing timers was modified to be earlier, and that it therefore
needs to resort them.

Updates #27707

Change-Id: I4c5f5b51ed116f1d898d3f87cdddfa1b552337f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/171832
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 19:35:04 +00:00
Jean de Klerk
a813d3c788 testing: stream log output in verbose mode
Fixes #24929

Change-Id: Icc426068cd73b75b78001f55e1e5d81ccebbe854
Reviewed-on: https://go-review.googlesource.com/c/go/+/127120
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-22 19:21:02 +00:00
Ian Lance Taylor
7416315e33 runtime: add new deltimer function
Updates #27707

Change-Id: I720e8af9e183c75abcb63ccc30466734c8dba74f
Reviewed-on: https://go-review.googlesource.com/c/go/+/171831
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 19:05:29 +00:00
Ian Lance Taylor
2e0aa581b4 runtime: add new addtimer function
When we add a timer, make sure that the network poller is initialized,
since we will use it if we have to wait for the timer to be ready.

Updates #27707

Change-Id: I0637fe646bade2cc5ce50b745712292aa9c445b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/171830
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22 18:41:00 +00:00
LE Manh Cuong
3db6d46a4e cmd/compile: add marker for skipping dowidth when tracing typecheck
The root cause of #33658 is that fmt.Printf does have side effects when
printing Type.

typefmt for TINTER will call Type.Fields to get all embedded fields and
methods. The thing is that type.Fields itself will call dowidth, which will
expand the embedded interface, make it non-embedded anymore.

To fix it, we add a marker while we are tracing, so dowidth can know and
return immediately without doing anything.

Fixes #33658

Change-Id: Id4b70ff68a3b802675deae96793fdb8f7ef1a4a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/190537
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-10-22 18:26:35 +00:00
Matthew Dempsky
5eec0a91ea reflect: fix unsafe conversions reported by -d=checkptr
The code for generating gcdata was (technically) unsafe. It was also
rather repetitive. This CL refactors it a bit and abstracts use of
gcdata into a helper gcSlice method.

Updates #34972.

Change-Id: Ie86d7822eafe263f1d3d150eedf0ec66be1ec85d
Reviewed-on: https://go-review.googlesource.com/c/go/+/202582
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 18:09:15 +00:00
Matthew Dempsky
a97ccc8940 sync/atomic: suppress checkptr errors for hammerStoreLoadPointer
This test could be updated to use unsafe.Pointer arithmetic properly
(e.g., see discussion at #34972), but it doesn't seem worthwhile. The
test is just checking that LoadPointer and StorePointer are atomic.

Updates #34972.

Change-Id: I85a8d610c1766cd63136cae686aa8a240a362a18
Reviewed-on: https://go-review.googlesource.com/c/go/+/202597
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 18:09:03 +00:00
Bryan C. Mills
22278ca0d4 net: convert TestTCPServer to use subtests
My fix in CL 202618 inadvertently violated an invariant in the inner
loop of TestTCPServer (namely, that len(trchs) == i). That causes a
panic when one or more of the channels is omitted due to a flake.

Instead of trying to fix up the test, let's just factor out a subtest
and skip the whole thing if the transceiver's Dial flakes out.

Updates #32919

Change-Id: Ib6f274a44194311c8c5a2faf19f586cc9eccfd4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/202561
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 17:34:15 +00:00
Robert Griesemer
51504f0a2d go/types: don't update package-external types when checking validity
The recently added type-validity check uses a new field of Named
types for marking (to detect cycles). That field was modified even
if the type was not part of the current package or belonged to the
Universe scope (error type). This led to race conditions if the
package's type was imported by multiple, concurrently type-checked
packages.

A test would be nice but it's a bit cumbersome to set one up.
Verified manually that package-external types are left alone.

Fixes #35049.

Change-Id: I51686bef47fcca48b99b91ecb1b2e9d58e135ea6
Reviewed-on: https://go-review.googlesource.com/c/go/+/202483
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 16:13:55 +00:00
David du Colombier
19d2a1cc2c cmd/go: fix TestScript/list_ambiguous_path on Plan 9
CL 198459 added TestScript/list_ambiguous_path. This
test is failing on Plan 9, because the expected error
doesn't match the error message returned on Plan 9.

This change fixes the test by matching the correct
error message on Plan 9.

Fixes #35072.

Change-Id: If8cdb641e0e9544ae4ac24f8d0c54859a3b23a69
Reviewed-on: https://go-review.googlesource.com/c/go/+/202447
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 15:28:05 +00:00
Bryan C. Mills
95544cc2c2 net: ignore or skip known-flaky localhost Dial operations on macOS 10.12 builder
Fixes #22019
Fixes #32919

Change-Id: I60bf6c69b18c3e2d78b494e54adc958fe40134da
Reviewed-on: https://go-review.googlesource.com/c/go/+/202618
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-22 15:15:06 +00:00
Brave Cow
07ccdeb192 net/http: update sanitizeCookieValue description
Commit 8f6d68eb (CL 37328) changed the code of sanitizeCookieValue without updating its description.

Change-Id: Ib4a1a1f316548258b828458a31b09706bbd59b53
GitHub-Last-Rev: 9731494e17
GitHub-Pull-Request: golang/go#34790
Reviewed-on: https://go-review.googlesource.com/c/go/+/200041
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-22 15:03:09 +00:00
Baokun Lee
ea726d8dc6 cmd/go/internal/modcmd: error out if one module with two different paths
If a single module is imported via two different paths, go mod tidy
should have reported this error instead of deferring it until go build.

Fixes #34650.

Change-Id: I9d09df1551b3e2083ed9f0bc77f2989073057717
Reviewed-on: https://go-review.googlesource.com/c/go/+/199598
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 14:26:04 +00:00
Ian Lance Taylor
d29c14f3d2 runtime: factor signal stack code out of sigtrampgo
This reduces the required nosplit stack size, which permits building
on Solaris with -gcflags=all=-N -l.

Fixes #35046

Change-Id: Icb3a421bb791c73e2f670ecfadbe32daea79789f
Reviewed-on: https://go-review.googlesource.com/c/go/+/202446
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 13:57:02 +00:00
Ian Lance Taylor
4f364be08d runtime: correctly negate errno value for *BSD ARM
Fixes #35037

Change-Id: I0b9bcd001556cd409994d83dabcdd6e32b001d28
Reviewed-on: https://go-review.googlesource.com/c/go/+/202441
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22 11:49:50 +00:00
Jason A. Donenfeld
16f0f9c8e1 syscall: respect permission bits on file opening on Windows
On Windows, os.Chmod and syscall.Chmod toggle the FILE_ATTRIBUTES_
READONLY flag depending on the permission bits. That's a bit odd but I
guess some compromises were made at some point and this is what was
chosen to map to a Unix concept that Windows doesn't really have in the
same way. That's fine. However, the logic used in Chmod was forgotten
from os.Open and syscall.Open, which then manifested itself in various
places, most recently, go modules' read-only behavior.

This makes syscall.Open consistent with syscall.Chmod and adds a test
for the permission _behavior_ using ioutil. By testing the behavior
instead of explicitly testing for the attribute bits we care about, we
make sure this doesn't regress in unforeseen ways in the future, as well
as ensuring the test works on platforms other than Windows.

In the process, we fix some tests that never worked and relied on broken
behavior, as well as tests that were disabled on Windows due to the
broken behavior and had TODO notes.

Fixes #35033

Change-Id: I6f7cf54517cbe5f6b1678d1c24f2ab337edcc7f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/202439
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 10:09:39 +00:00
Ian Lance Taylor
7f98c0eb03 os/exec: skip possible netpoll pipe in known FDs in test
Fixes #35045

Change-Id: I90ac29882c7d03936c98c4116a8bccdd2ecbf76b
Reviewed-on: https://go-review.googlesource.com/c/go/+/202445
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-10-22 08:54:50 +00:00
Ian Lance Taylor
4ec51894ee runtime: force testing calls of netpoll to run on system stack
Fixes #35053

Change-Id: I31853d434610880044c169e0c1e9732f97ff1bdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/202444
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
2019-10-22 08:46:40 +00:00
ajz01
57ad6ef15d go/parser: remove superfluous case from switch statement
Change-Id: I96a9b34bf8e42c21a3e0258cbc8b1416328834be
GitHub-Last-Rev: 32709619a6
GitHub-Pull-Request: golang/go#35066
Reviewed-on: https://go-review.googlesource.com/c/go/+/202598
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-10-22 04:05:25 +00:00
Cuong Manh Le
9979366e07 cmd/compile: disable checkptr for //go:nosplit functions
Make go test -a -short -gcflags=all=-d=checkptr passes on darwin.

Update #34972

Change-Id: I71cf14ec1faccd4837713aa30c90ed665899b908
Reviewed-on: https://go-review.googlesource.com/c/go/+/202158
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 01:03:29 +00:00
Cuong Manh Le
2e1a6a28df runtime: fix unsafe.Pointer alignment on Linux
Caught by go test -a -short -gcflags=all=-d=checkptr runtime

TestMincoreErrorSign intentionally uses uintptr(1) to get -EINVAL,
but it violates unsafe pointer rules 2. So use another misaligned
pointer add(new(int32), 1), but do not violate unsafe pointer rules.

TestEpollctlErrorSign passes an unsafe.Pointer of &struct{}{} to
Epollctl, which is then casted to epollevent, causes mis-alignment.
Fixing it by exporting epollevent on runtime_test package, so it can be
passed to Epollctl.

Updates #34972

Change-Id: I78ebfbeaf706fd1d372272af0bbc4e2cabca4631
Reviewed-on: https://go-review.googlesource.com/c/go/+/202157
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-22 01:03:09 +00:00
Ian Lance Taylor
0050c079d5 runtime, syscall, time: prepare for adding timers to P's
Add new fields to runtime.timer, and adjust the various timer
functions in preparation for adding timers to P's. This continues to
use the old timer code.

Updates #6239
Updates #27707

Change-Id: I9adb3814f657e083ec5e22736c4b5b52b77b6a3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/171829
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-21 23:41:41 +00:00
Robert Griesemer
a59808ed01 go/parser: better error (recovery) for Allman/BSD-style func decls
This matches the behavior and error of cmd/compile.

Fixes #34946.

Change-Id: I329ef358deea63d8425f76f1d54c95749b96c365
Reviewed-on: https://go-review.googlesource.com/c/go/+/202484
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-21 23:36:02 +00:00
Ian Lance Taylor
6b3bb4ba3b runtime: handle timers on P's in procresize/(*pp).destroy
Updates #6239
Updates #27707

Change-Id: I52cab8bf3dc8c552463725fc1d9e4e6b12230b03
Reviewed-on: https://go-review.googlesource.com/c/go/+/171828
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-21 23:18:36 +00:00
Matthew Dempsky
9989221ac1 reflect, internal/reflectlite: set capacity when slicing unsafe pointers
Follow the idiom for allowing -d=checkptr to recognize and verify
correctness.

Updates #22218.
Updates #34972.

Change-Id: Ib6001c6f0e6dc535a36bcfaa1ae48e29e0c737f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/202580
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-21 23:16:36 +00:00
Matthew Dempsky
7b58581a23 cmd/compile: recognize (*[Big]T)(ptr)[:n:m] pattern for -d=checkptr
A common idiom for turning an unsafe.Pointer into a slice is to write:

    s := (*[Big]T)(ptr)[:n:m]

This technically violates Go's unsafe pointer rules (rule #1 says T2
can't be bigger than T1), but it's fairly common and not too difficult
to recognize, so might as well allow it for now so we can make
progress on #34972.

This should be revisited if #19367 is accepted.

Updates #22218.
Updates #34972.

Change-Id: Id824e2461904e770910b6e728b4234041d2cc8bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/201839
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-21 23:16:27 +00:00
Keith Randall
dba19c65a7 bytes/hash: initialize all 64 bits of hash seed
Fixes #34925

Change-Id: Iadf12ca47a69b62c3f48d732b430cc85cf62a91c
Reviewed-on: https://go-review.googlesource.com/c/go/+/202577
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-21 22:01:12 +00:00
Cherry Zhang
c480d32fad [dev.link] cmd/link: do not put static symbols into name lookup table
Since the previous CL, we will not reference static symbols by
name. Therefore no need to put them into the name lookup table.

On Linux/ARM, in runtime/internal/atomic/sys_linux_arm.s, the
kernelcas function has a definition and a reference written in
two different forms, one with package prefix, one without. This
way, the assembler cannot know they are the same symbol, only the
linker knows. This is quite unusual, unify the names to so the
assembler can resolve it to index.

Change-Id: Ie7223097be6a3b65f3fa43ed4575da9972ef5b69
Reviewed-on: https://go-review.googlesource.com/c/go/+/201998
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-21 21:58:03 +00:00
Cherry Zhang
d56c8149ac [dev.link] cmd/internal/obj: use index for static symbols
In assembly we always reference symbols by name. But for static
symbols, as they are reachable only within the current file, we
can assign them local indices and use the indices to reference
them. The index is only meaningful locally, and it is fine.

Change-Id: I16e011cd41575ef703ceb6f35899e5fa58fbcf1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/201997
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-21 21:57:32 +00:00
Cherry Zhang
4fa524b776 [dev.link] cmd/dist: reenable shared library tests
Change-Id: Ifa4de9333b9275d832ebf68c89d3239ed438b104
Reviewed-on: https://go-review.googlesource.com/c/go/+/201819
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-21 21:57:10 +00:00
Cherry Zhang
97e497b253 [dev.link] cmd: reference symbols by name when linking against Go shared library
When building a program that links against Go shared libraries,
it needs to reference symbols defined in the shared library. At
compile time, we don't know where the shared library boundary is.
If we reference a symbol in package p by index, and package p is
actually part of a shared library, we cannot resolve the index at
link time, as the linker doesn't see the object file of p.

So when linking against Go shared libraries, always use named
reference for now.

To do this, the compiler needs to know whether we will be linking
against Go shared libraries. The -dynlink flag kind of indicates
that (as the document says), but currently it is actually
overloaded: it is also used when building a plugin or a shared
library, which is self-contained (if -linkshared is not otherwise
specified) and could use index for symbol reference. So we
introduce another compiler flag, -linkshared, specifically for
linking against Go shared libraries. The go command will pass
this flag if its -linkshared flag is specified
("go build -linkshared").

There may be better way to handle this. For example, we can
put the symbol indices in a special section in the shared library
that the linker can read. Or we can generate some per-package
description file to include the indices. (Currently we generate
a .shlibname file for each package that is included in a shared
library, which contains the path of the library. We could
consider extending this.) That said, this CL is a stop-gap
solution. And it is no worse than the old object files.

If we were to redesign the build system so that the shared
library boundary is known at compile time, we could use indices
for symbol references that do not cross shared library boundary,
as well as doing other things better.

Change-Id: I9c02aad36518051cc4785dbe25c4b4cef8f3faeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/201818
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2019-10-21 21:57:01 +00:00
Ian Lance Taylor
10e7bc994f runtime: add wasm support for timers on P's
When we put timers on P's, the wasm code will not be able to rely on
the timer goroutine. Use the beforeIdle hook to schedule a wakeup.

Updates #6239
Updates #27707

Change-Id: Idf6309944778b8c3d7178f5d09431940843ea233
Reviewed-on: https://go-review.googlesource.com/c/go/+/171827
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-10-21 21:43:41 +00:00
Michael Munday
7c3060e923 cmd/compile/internal/ssa: regenerate rewrite rules
Slight differences existed due to a change in rulegen after the
FMA intrinsic code was generated.

Change-Id: Ieb6b3ec1b29985a18d1bbbc5a820ffea699306fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/202443
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-21 21:14:04 +00:00
Matthew Dempsky
b282efa022 cmd/compile: recognize reflect.{Slice,String}Header for -d=checkptr
Avoids false positive pointer arithmetic panic.

Fixes #35027.

Change-Id: Idd008caaab25fcf739327ac50a021b835ef13def
Reviewed-on: https://go-review.googlesource.com/c/go/+/202560
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-21 20:51:06 +00:00