From ee392ac10c7bed0ef1984dbb421491ca7b18e190 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 21 Jul 2017 16:37:40 -0700 Subject: [PATCH 01/36] cmd/compile: consider exported flag in namedata It is possible to have an unexported name with a nil package, for an embedded field whose type is a pointer to an unexported type. We must encode that fact in the type..namedata symbol name, to avoid incorrectly merging an unexported name with an exported name. Fixes #21120 Change-Id: I2e3879d77fa15c05ad92e0bf8e55f74082db5111 Reviewed-on: https://go-review.googlesource.com/50710 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: David Crawshaw --- src/cmd/compile/internal/gc/reflect.go | 6 +++++- test/fixedbugs/issue21120.dir/a.go | 13 ++++++++++++ test/fixedbugs/issue21120.dir/b.go | 29 ++++++++++++++++++++++++++ test/fixedbugs/issue21120.dir/main.go | 25 ++++++++++++++++++++++ test/fixedbugs/issue21120.go | 11 ++++++++++ 5 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue21120.dir/a.go create mode 100644 test/fixedbugs/issue21120.dir/b.go create mode 100644 test/fixedbugs/issue21120.dir/main.go create mode 100644 test/fixedbugs/issue21120.go diff --git a/src/cmd/compile/internal/gc/reflect.go b/src/cmd/compile/internal/gc/reflect.go index decd3beda7..91e6f46804 100644 --- a/src/cmd/compile/internal/gc/reflect.go +++ b/src/cmd/compile/internal/gc/reflect.go @@ -582,7 +582,11 @@ func dname(name, tag string, pkg *types.Pkg, exported bool) *obj.LSym { sname += "-noname-unexported." + tag } } else { - sname += name + "." + tag + if exported { + sname += name + "." + tag + } else { + sname += name + "-" + tag + } } } else { sname = fmt.Sprintf(`%s"".%d`, sname, dnameCount) diff --git a/test/fixedbugs/issue21120.dir/a.go b/test/fixedbugs/issue21120.dir/a.go new file mode 100644 index 0000000000..f2ee252671 --- /dev/null +++ b/test/fixedbugs/issue21120.dir/a.go @@ -0,0 +1,13 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package a + +type S struct { + x int +} + +func V() interface{} { + return S{0} +} diff --git a/test/fixedbugs/issue21120.dir/b.go b/test/fixedbugs/issue21120.dir/b.go new file mode 100644 index 0000000000..b00bd53a5d --- /dev/null +++ b/test/fixedbugs/issue21120.dir/b.go @@ -0,0 +1,29 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package b + +import "reflect" + +type X int + +func F1() string { + type x X + + s := struct { + *x + }{nil} + v := reflect.TypeOf(s) + return v.Field(0).PkgPath +} + +func F2() string { + type y X + + s := struct { + *y + }{nil} + v := reflect.TypeOf(s) + return v.Field(0).PkgPath +} diff --git a/test/fixedbugs/issue21120.dir/main.go b/test/fixedbugs/issue21120.dir/main.go new file mode 100644 index 0000000000..1f1ec30e56 --- /dev/null +++ b/test/fixedbugs/issue21120.dir/main.go @@ -0,0 +1,25 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import ( + "fmt" + "os" + + "./a" + "./b" +) + +func main() { + // Make sure the reflect information for a.S is in the executable. + _ = a.V() + + b1 := b.F1() + b2 := b.F2() + if b1 != b2 { + fmt.Printf("%q (from b.F1()) != %q (from b.F2())\n", b1, b2) + os.Exit(1) + } +} diff --git a/test/fixedbugs/issue21120.go b/test/fixedbugs/issue21120.go new file mode 100644 index 0000000000..ea896ce8e1 --- /dev/null +++ b/test/fixedbugs/issue21120.go @@ -0,0 +1,11 @@ +// rundir + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// The compiler was using an incomplete symbol name for reflect name data, +// permitting an invalid merge in the linker, producing an incorrect +// exported flag bit. + +package ignored From b9661a14eabeb6ee3b9bf4a001aed4c88991be28 Mon Sep 17 00:00:00 2001 From: Zac Bergquist Date: Mon, 24 Jul 2017 19:05:43 -0400 Subject: [PATCH 02/36] doc: add Atom to editor guide Fixes #20569 Change-Id: I752a49ed50c1567f8db7112859ac073f37dd77dc Reviewed-on: https://go-review.googlesource.com/50952 Reviewed-by: Jaana Burcu Dogan --- doc/editors.html | 27 ++++++++++++++++++++++++--- doc/editors/go-plus.png | Bin 0 -> 15558 bytes 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 doc/editors/go-plus.png diff --git a/doc/editors.html b/doc/editors.html index 1448781036..5228dfc7a8 100644 --- a/doc/editors.html +++ b/doc/editors.html @@ -24,6 +24,7 @@ editing, navigation, testing, and debugging experience. an extension for Visual Studio Code to provide support for the Go programming language
  • Gogland: Gogland is distributed either as a standalone IDE or as a plugin for the IntelliJ Platform IDEs
  • +
  • Go-Plus: Go-Plus is an Atom package that provides enhanced Go support
  • @@ -44,6 +45,7 @@ The following feature matrix lists and compares the most significant features.
    Vim Go
    Visual Studio Code Go
    Gogland +
    Go-Plus Editing features @@ -53,42 +55,49 @@ The following feature matrix lists and compares the most significant features. Yes Yes Yes + Yes Autocompletion of identifers (variable, method, and function names) Yes Yes Yes + Yes Autocompletion based on type No No Yes + No Rename identifiers Yes Yes Yes + Yes Auto format, build, vet, and lint on save Yes Yes Yes1 + Yes Auto insert import paths and remove unused on save Yes Yes Yes2 + Yes Auto generate JSON, XML tags for struct fields Yes Yes Yes + Yes Navigation features @@ -98,30 +107,35 @@ The following feature matrix lists and compares the most significant features. Yes Yes Yes + Yes Switch between *.go and *_test.go file Yes Yes Yes + No Jump to definition and referees Yes Yes Yes + Yes Look up for interface implementations Yes Yes Yes + Yes Search for callers and callees Yes Yes Yes + Yes Testing and debugging features @@ -131,36 +145,43 @@ The following feature matrix lists and compares the most significant features. No Yes Yes + Yes3 + Run a single test case, all tests from file, or all tests from a package Yes Yes Yes + No Auto generate tests for packages, files and identifiers No Yes No + No Debug tests No Yes Yes + Yes3 Display test coverage Yes Yes Yes + Yes Install Install Install + Install @@ -168,6 +189,8 @@ The following feature matrix lists and compares the most significant features. 1: Possible when enabled via Settings > Go > On Save, go vet and golint are available via plugins. Also runs tests on save if configured.
    2: Additionally, user input can disambiguate when two or more options are available. +
    +3: Available if the go-debug package is installed.

    @@ -205,6 +228,4 @@ The following feature matrix lists and compares the most significant features. background-color: #ebebeb; font-weight: bold; } - - - \ No newline at end of file + \ No newline at end of file diff --git a/doc/editors/go-plus.png b/doc/editors/go-plus.png new file mode 100644 index 0000000000000000000000000000000000000000..c09c7fe6756a7203964d15d079593811557c9672 GIT binary patch literal 15558 zcmY+r19)aJw8Cp*d7D+|f9 zvsbcK!W87h;bCxK0002Iq=bm#cd7TE383d4)f%T1`VXmz1q%JGNZD?yvuWw{)U`+33ZTF200PwnTe^;%Io%D&^tgUPu zx!w3k{tJWqyZ#?A0}0W8p*UIck*Lcm5DD8l7!$G4v(ht?@WT)h5%D@0nQ$wLi2YCZ z?-n14nUj+pHv@yKt1G=L3%#v_DFYK17Z(E~GXpa--8TlEqq~ihz8js5Bk6w=`TyvM z7&{s|nAr~t$?vq)MEf%IM81V}g#{OY9dM++V(bcc z$F#yj%UDlXQ?soR+&^C7hmCcuhimwf6lwjEU_F{tQSRJOb*Z}Ls^a{w@#~8uzwCFC z)i~u=b6`SZY-}tt!{^iPU^r&%Dv1xAkH~g3)H|{tA{@vvr0Si$YR2>tUFD-!1!{+2t(6ECN3 zxPgD#JSAuN!$&D9GWA4O>oglin*?K+cdEiOCjaP zkGTg#TM&$hMZo8}7cxDGR-+CeFpUTi5Z<9<%j0VacDzU*UEW7`iInw(Y{r{Db>J}H zk~LvcZzzE?V#ExI8a7a6#@gn3G?nRD)w28d&tYS)J_Lg!AsGul5`_A8G=Q(gbUG_h zMMcFlF)`5_N}#%D7H0bcqoLUmf>cpYiX*D>n0z`CG4f}--iiMt6^;J5#4=n~j#d{QSLB1uCc3=_4L!@sZ6vuI&6km8%`wX#bXrr~*izcj-ibkTx}-mFgw6yGku-v>P{R+7nxmBjXKs0BRiVrlkYz zF-EpehuOUz?Z$cK{PwF>a~ufykN&;hxlp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koljZrk;8m{^?UaT=t4%8R=7kV+UO za!tvukJD!hRO9i>JCf<{h3j?3E8@f#Z0(0NBED+DtM&oJrj1?n(i^u#?x0OVH-(!P z?cH?7TprcveGXVR|7*f_is&^!jnL*QAlGwn2yANGv`by+g4_u;>40QI3wOE?c)lJc ze19g;2D~l-EyLggC8Su`tLb$aeR@yR*3wXWBU)n?UhC|zb?SFRQlEbz+5r*R2_o)h zdI)@h*=z@zCpe}AUB7Xn2OVn0f@j_y^^>mL%~$qf-58`3~x!8w+Owl~jhaU{mcM=RC`BoJxgtp82JuG#^FB zG`V7{8&u6HW`_Vg1|WC^ff9$H-)PZ8=NKx;uN0-?4tGuTuSEOUIk`ReD9Qiqyowbk zAm0A=|AMW6<1^?&Q-1TX}z;BSrex~$!zOyuFz~xbQ!K^JViiQuiL6t~Bm34W5t0af4 zbHa)n;8@h4IhF5iacoPX_CpQ=l-ggs@mUz<+;a2G=7haH|J5iylQUp0BzjMQ8c#Rj zdj$X9IqJRrz7^@-aV29{ufT+T>{`Ao4XLUbO!wx^r`fl)EVY%xJPwz2@g1hRRc_yJ z)Ar2e4WZ5gDt2%aBJAij4Btr=LJ-@( Date: Tue, 25 Jul 2017 14:08:47 -0400 Subject: [PATCH 03/36] doc: cleanup editor page Fix some UI issues introduced with CL50952: - increase header colspan to account for additional column - remove ':' character from footnotes Change-Id: I56f59b8e4b2852612b3c6c7c0dfe99125dd8b57b Reviewed-on: https://go-review.googlesource.com/51113 Reviewed-by: Jaana Burcu Dogan --- doc/editors.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/editors.html b/doc/editors.html index 5228dfc7a8..1da83daf07 100644 --- a/doc/editors.html +++ b/doc/editors.html @@ -24,7 +24,7 @@ editing, navigation, testing, and debugging experience. an extension for Visual Studio Code to provide support for the Go programming language

  • Gogland: Gogland is distributed either as a standalone IDE or as a plugin for the IntelliJ Platform IDEs
  • -
  • Go-Plus: Go-Plus is an Atom package that provides enhanced Go support
  • +
  • Go-Plus: Go-Plus is an Atom package that provides enhanced Go support
  • @@ -48,7 +48,7 @@ The following feature matrix lists and compares the most significant features.
    Go-Plus - Editing features + Editing features Build and run from the editor/IDE @@ -100,7 +100,7 @@ The following feature matrix lists and compares the most significant features. Yes - Navigation features + Navigation features Display documentation inline, or open godoc in browser @@ -138,7 +138,7 @@ The following feature matrix lists and compares the most significant features. Yes - Testing and debugging features + Testing and debugging features Debugger support @@ -186,11 +186,11 @@ The following feature matrix lists and compares the most significant features.

    -1: Possible when enabled via Settings > Go > On Save, go vet and golint are available via plugins. Also runs tests on save if configured. +1Possible when enabled via Settings > Go > On Save, go vet and golint are available via plugins. Also runs tests on save if configured.
    -2: Additionally, user input can disambiguate when two or more options are available. +2Additionally, user input can disambiguate when two or more options are available.
    -3: Available if the go-debug package is installed. +3Available if the go-debug package is installed.

    @@ -228,4 +228,4 @@ The following feature matrix lists and compares the most significant features. background-color: #ebebeb; font-weight: bold; } - \ No newline at end of file + From df91b8044dbe790c69c16058330f545be069cc1f Mon Sep 17 00:00:00 2001 From: Jaana Burcu Dogan Date: Tue, 25 Jul 2017 13:03:48 -0700 Subject: [PATCH 04/36] doc: list editor options by name, not plugin name So the users can recognize their option by their editor's name. Fixes #20398. Change-Id: Id314d4dbe26f40231a479b179620d7e66512b506 Reviewed-on: https://go-review.googlesource.com/51114 Reviewed-by: Chris Broadfoot --- doc/editors.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/editors.html b/doc/editors.html index 1da83daf07..5df5d38bce 100644 --- a/doc/editors.html +++ b/doc/editors.html @@ -19,12 +19,12 @@ editing, navigation, testing, and debugging experience.

      -
    • Vim Go: a plugin for Vim to provide Go programming language support
    • -
    • Visual Studio Code Go: -an extension for Visual Studio Code to provide support for the Go programming language
    • +
    • vim: vim-go plugin provides Go programming language support
    • +
    • Visual Studio Code: +Go extension provides support for the Go programming language
    • Gogland: Gogland is distributed either as a standalone IDE or as a plugin for the IntelliJ Platform IDEs
    • -
    • Go-Plus: Go-Plus is an Atom package that provides enhanced Go support
    • +
    • Atom: Go-Plus is an Atom package that provides enhanced Go support

    @@ -42,10 +42,10 @@ The following feature matrix lists and compares the most significant features. - - + + - + From 835dfef939879b284d4c0f4e1726491f27e4f1ee Mon Sep 17 00:00:00 2001 From: Vladimir Stefanovic Date: Thu, 4 May 2017 16:45:29 +0200 Subject: [PATCH 05/36] runtime/pprof: prevent a deadlock that SIGPROF might create on mips{,le} 64bit atomics on mips/mipsle are implemented using spinlocks. If SIGPROF is received while the program is in the critical section, it will try to write the sample using the same spinlock, creating a deadloop. Prevent it by creating a counter of SIGPROFs during atomic64 and postpone writing the sample(s) until called from elsewhere, with pc set to _LostSIGPROFDuringAtomic64. Added a test case, per Cherry's suggestion. Works around #20146. Change-Id: Icff504180bae4ee83d78b19c0d9d6a80097087f9 Reviewed-on: https://go-review.googlesource.com/42652 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- src/runtime/cpuprof.go | 9 +++++++++ src/runtime/pprof/pprof_test.go | 31 +++++++++++++++++++++++++++++++ src/runtime/proc.go | 31 +++++++++++++++++++++++++++---- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/src/runtime/cpuprof.go b/src/runtime/cpuprof.go index c761e440b6..fb841a9f3d 100644 --- a/src/runtime/cpuprof.go +++ b/src/runtime/cpuprof.go @@ -163,6 +163,15 @@ func (p *cpuProfile) addExtra() { } } +func (p *cpuProfile) addLostAtomic64(count uint64) { + hdr := [1]uint64{count} + lostStk := [2]uintptr{ + funcPC(_LostSIGPROFDuringAtomic64) + sys.PCQuantum, + funcPC(_System) + sys.PCQuantum, + } + cpuprof.log.write(nil, 0, hdr[:], lostStk[:]) +} + // CPUProfile panics. // It formerly provided raw access to chunks of // a pprof-format profile generated by the runtime. diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index 22fea0a52f..992d2abb6a 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -12,6 +12,7 @@ import ( "fmt" "internal/testenv" "io" + "io/ioutil" "math/big" "os" "os/exec" @@ -20,6 +21,7 @@ import ( "runtime/pprof/internal/profile" "strings" "sync" + "sync/atomic" "testing" "time" ) @@ -713,3 +715,32 @@ func TestCPUProfileLabel(t *testing.T) { }) }) } + +// Check that there is no deadlock when the program receives SIGPROF while in +// 64bit atomics' critical section. Used to happen on mips{,le}. See #20146. +func TestAtomicLoadStore64(t *testing.T) { + f, err := ioutil.TempFile("", "profatomic") + if err != nil { + t.Fatalf("TempFile: %v", err) + } + defer os.Remove(f.Name()) + defer f.Close() + + if err := StartCPUProfile(f); err != nil { + t.Fatal(err) + } + defer StopCPUProfile() + + var flag uint64 + done := make(chan bool, 1) + + go func() { + for atomic.LoadUint64(&flag) == 0 { + runtime.Gosched() + } + done <- true + }() + time.Sleep(50 * time.Millisecond) + atomic.StoreUint64(&flag, 1) + <-done +} diff --git a/src/runtime/proc.go b/src/runtime/proc.go index a5ada4f6db..ed333bb92e 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3232,10 +3232,14 @@ var prof struct { hz int32 } -func _System() { _System() } -func _ExternalCode() { _ExternalCode() } -func _LostExternalCode() { _LostExternalCode() } -func _GC() { _GC() } +func _System() { _System() } +func _ExternalCode() { _ExternalCode() } +func _LostExternalCode() { _LostExternalCode() } +func _GC() { _GC() } +func _LostSIGPROFDuringAtomic64() { _LostSIGPROFDuringAtomic64() } + +// Counts SIGPROFs received while in atomic64 critical section, on mips{,le} +var lostAtomic64Count uint64 // Called if we receive a SIGPROF signal. // Called by the signal handler, may run during STW. @@ -3245,6 +3249,21 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { return } + // On mips{,le}, 64bit atomics are emulated with spinlocks, in + // runtime/internal/atomic. If SIGPROF arrives while the program is inside + // the critical section, it creates a deadlock (when writing the sample). + // As a workaround, create a counter of SIGPROFs while in critical section + // to store the count, and pass it to sigprof.add() later when SIGPROF is + // received from somewhere else (with _LostSIGPROFDuringAtomic64 as pc). + if GOARCH == "mips" || GOARCH == "mipsle" { + if f := findfunc(pc); f.valid() { + if hasprefix(funcname(f), "runtime/internal/atomic") { + lostAtomic64Count++ + return + } + } + } + // Profiling runs concurrently with GC, so it must not allocate. // Set a trap in case the code does allocate. // Note that on windows, one thread takes profiles of all the @@ -3371,6 +3390,10 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) { } if prof.hz != 0 { + if (GOARCH == "mips" || GOARCH == "mipsle") && lostAtomic64Count > 0 { + cpuprof.addLostAtomic64(lostAtomic64Count) + lostAtomic64Count = 0 + } cpuprof.add(gp, stk[:n]) } getg().m.mallocing-- From e157fac02d4700e9fa8e1c30265a2d90a51be6f3 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 24 Jul 2017 10:17:15 -0700 Subject: [PATCH 06/36] test: add README Updates #21034 Change-Id: I951fb48ab3b9ed54d225c11879db8f09048a36a3 Reviewed-on: https://go-review.googlesource.com/50950 Reviewed-by: Rob Pike --- test/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/README.md diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000000..ca6a8c6580 --- /dev/null +++ b/test/README.md @@ -0,0 +1,15 @@ +The test directory contains tests of the Go tool chain and runtime. +It includes black box tests, regression tests, and error output tests. +They are run as part of all.bash. + +To run just these tests, execute: + + go run run.go + +Standard library tests should be written as regular Go tests in the appropriate package. + +The tool chain and runtime also have regular Go tests in their packages. +The main reasons to add a new test to this directory are: + +* it is most naturally expressed using the test runner; or +* it is also applicable to `gccgo` and other Go tool chains. From 45a4609c0ae214e448612e0bc0846e2f2682f1b2 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Thu, 27 Jul 2017 04:33:18 +0000 Subject: [PATCH 07/36] cmd/dist: skip moved GOROOT on Go's Windows builders when not sharding tests Change-Id: I0bcae339624e7d61037d9ea0885b7bd07491bbb6 Reviewed-on: https://go-review.googlesource.com/51430 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/cmd/dist/test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 6846970ecf..73432d31ea 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -447,6 +447,17 @@ func (t *tester) registerTests() { t.runPending(dt) moved := t.goroot + "-moved" if err := os.Rename(t.goroot, moved); err != nil { + if t.goos == "windows" { + // Fails on Windows (with "Access is denied") if a process + // or binary is in this directory. For instance, using all.bat + // when run from c:\workdir\go\src fails here + // if GO_BUILDER_NAME is set. Our builders invoke tests + // a different way which happens to work when sharding + // tests, but we should be tolerant of the non-sharded + // all.bat case. + log.Printf("skipping test on Windows") + return nil + } return err } From ac29f30dbb35d8812c865aed6a6ae738a480def3 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Jul 2017 09:46:58 -0700 Subject: [PATCH 08/36] plugin: mention that there are known bugs with plugins Change-Id: I9e63661cac2bebc41d7aa3cd80e1920eec22b894 Reviewed-on: https://go-review.googlesource.com/51250 Reviewed-by: Brad Fitzpatrick Reviewed-by: David Crawshaw --- src/plugin/plugin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugin/plugin.go b/src/plugin/plugin.go index 3dc7964048..c774465812 100644 --- a/src/plugin/plugin.go +++ b/src/plugin/plugin.go @@ -4,8 +4,6 @@ // Package plugin implements loading and symbol resolution of Go plugins. // -// Currently plugins only work on Linux. -// // A plugin is a Go main package with exported functions and variables that // has been built with: // @@ -14,6 +12,9 @@ // When a plugin is first opened, the init functions of all packages not // already part of the program are called. The main function is not run. // A plugin is only initialized once, and cannot be closed. +// +// The plugin support is currently incomplete, only supports Linux, +// and has known bugs. Please report any issues. package plugin // Plugin is a loaded Go plugin. From 31b2c4cc255b98e4255854a008c0c9b53ad4fd26 Mon Sep 17 00:00:00 2001 From: Gustav Westling Date: Sun, 30 Jul 2017 22:14:22 +0200 Subject: [PATCH 09/36] .github: add .md extension to SUPPORT file This makes GitHub render the markdown file automatically on their web UI. SUPPORT.md is the recommended file name according to the GitHub documentation: https://help.github.com/articles/adding-support-resources-to-your-project/ Fixes #21223 Change-Id: I9f9b9daced9c29a16850e8c446656f353f50b1ae Reviewed-on: https://go-review.googlesource.com/52013 Reviewed-by: Brad Fitzpatrick --- .github/{SUPPORT => SUPPORT.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{SUPPORT => SUPPORT.md} (100%) diff --git a/.github/SUPPORT b/.github/SUPPORT.md similarity index 100% rename from .github/SUPPORT rename to .github/SUPPORT.md From 780249eed449ea8ae63f0dec258c55381f30173b Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 28 Jul 2017 18:06:03 -0400 Subject: [PATCH 10/36] runtime: fall back to small mmaps if we fail to grow reservation Right now, if it's possible to grow the arena reservation but mheap.sysAlloc fails to get 256MB more of memory, it simply fails. However, on 32-bit we have a fallback path that uses much smaller mmaps that could take in this situation, but fail to. This commit fixes mheap.sysAlloc to use a common failure path in case it can't grow the reservation. On 32-bit, this path includes the fallback. Ideally, mheap.sysAlloc would attempt smaller reservation growths first, but taking the fallback path is a simple change for Go 1.9. Updates #21044 (fixes one of two issues). Change-Id: I1e0035ffba986c3551479d5742809e43da5e7c73 Reviewed-on: https://go-review.googlesource.com/51713 Run-TryBot: Austin Clements Reviewed-by: Ian Lance Taylor TryBot-Result: Gobot Gobot --- src/runtime/malloc.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 8850659748..0ebd2c0ab2 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -416,7 +416,10 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer { var reserved bool p := uintptr(sysReserve(unsafe.Pointer(h.arena_end), p_size, &reserved)) if p == 0 { - return nil + // TODO: Try smaller reservation + // growths in case we're in a crowded + // 32-bit address space. + goto reservationFailed } // p can be just about anywhere in the address // space, including before arena_end. @@ -476,6 +479,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer { return unsafe.Pointer(p) } +reservationFailed: // If using 64-bit, our reservation is all we have. if sys.PtrSize != 4 { return nil From 623e2c4603053c8e2ecf4cd7ed5f8242a7a02226 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 28 Jul 2017 17:44:09 -0400 Subject: [PATCH 11/36] runtime: map bitmap and spans during heap initialization We lazily map the bitmap and spans areas as the heap grows. However, right now we're very slightly too lazy. Specifically, the following can happen on 32-bit: 1. mallocinit fails to allocate any heap arena, so arena_used == arena_alloc == arena_end == bitmap. 2. There's less than 256MB between the end of the bitmap mapping and the next mapping. 3. On the first allocation, mheap.sysAlloc sees that there's not enough room in [arena_alloc, arena_end) because there's no room at all. It gets a 256MB mapping from somewhere *lower* in the address space than arena_used and sets arena_alloc and arena_end to this hole. 4. Since the new arena_alloc is lower than arena_used, mheap.sysAlloc doesn't bother to call mheap.setArenaUsed, so we still don't have a bitmap mapping or a spans array mapping. 5. mheap.grow, which called mheap.sysAlloc, attempts to fill in the spans array and crashes. Fix this by mapping the metadata regions for the initial arena_used when the heap is initialized, rather than trying to wait for an allocation. This maintains the intended invariant that the structures are always mapped for [arena_start, arena_used). Fixes #21044. Change-Id: I4422375a6e234b9f979d22135fc63ae3395946b0 Reviewed-on: https://go-review.googlesource.com/51714 Run-TryBot: Austin Clements Reviewed-by: Ian Lance Taylor --- src/runtime/mheap.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index bf682ec97f..893587e5d2 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -503,6 +503,11 @@ func (h *mheap) init(spansStart, spansBytes uintptr) { sp.array = unsafe.Pointer(spansStart) sp.len = 0 sp.cap = int(spansBytes / sys.PtrSize) + + // Map metadata structures. But don't map race detector memory + // since we're not actually growing the arena here (and TSAN + // gets mad if you map 0 bytes). + h.setArenaUsed(h.arena_used, false) } // setArenaUsed extends the usable arena to address arena_used and From f20944de78012a257d1e66b8209e2990a14673a7 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Tue, 18 Jul 2017 08:35:00 -0400 Subject: [PATCH 12/36] cmd/compile: set/unset base register for better assembly print For address of an auto or arg, on all non-x86 architectures the assembler backend encodes the actual SP offset in the instruction but leaves the offset in Prog unchanged. When the assembly is printed in compile -S, it shows an offset relative to pseudo FP/SP with an actual hardware SP base register (e.g. R13 on ARM). This is confusing. Unset the base register if it is indeed SP, so the assembly output is consistent. If the base register isn't SP, it should be an error and the error output contains the actual base register. For address loading instructions, the base register isn't set in the compiler on non-x86 architectures. Set it. Normally it is SP and will be unset in the change mentioned above for printing. If it is not, it will be an error and the error output contains the actual base register. No change in generated binary, only printed assembly. Passes "go build -a -toolexec 'toolstash -cmp' std cmd" on all architectures. Fixes #21064. Change-Id: Ifafe8d5f9b437efbe824b63b3cbc2f5f6cdc1fd5 Reviewed-on: https://go-review.googlesource.com/49432 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: David Chase --- src/cmd/compile/internal/arm/ssa.go | 2 +- src/cmd/compile/internal/arm64/ssa.go | 2 +- src/cmd/compile/internal/gc/asm_test.go | 24 +++++++++++++++++++++++- src/cmd/compile/internal/mips/ssa.go | 2 +- src/cmd/compile/internal/mips64/ssa.go | 2 +- src/cmd/compile/internal/ppc64/ssa.go | 2 +- src/cmd/internal/obj/arm/asm5.go | 20 ++++++++++++++++++++ src/cmd/internal/obj/arm64/asm7.go | 20 ++++++++++++++++++++ src/cmd/internal/obj/mips/asm0.go | 20 ++++++++++++++++++++ src/cmd/internal/obj/ppc64/asm9.go | 20 ++++++++++++++++++++ src/cmd/internal/obj/s390x/asmz.go | 20 ++++++++++++++++++++ 11 files changed, 128 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/arm/ssa.go b/src/cmd/compile/internal/arm/ssa.go index 343f2d3aec..93abee3da0 100644 --- a/src/cmd/compile/internal/arm/ssa.go +++ b/src/cmd/compile/internal/arm/ssa.go @@ -464,6 +464,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case ssa.OpARMMOVWaddr: p := s.Prog(arm.AMOVW) p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() @@ -485,7 +486,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case nil: // No sym, just MOVW $off(SP), R wantreg = "SP" - p.From.Reg = arm.REGSP p.From.Offset = v.AuxInt } if reg := v.Args[0].RegName(); reg != wantreg { diff --git a/src/cmd/compile/internal/arm64/ssa.go b/src/cmd/compile/internal/arm64/ssa.go index dec6a4e93e..0f9e82c727 100644 --- a/src/cmd/compile/internal/arm64/ssa.go +++ b/src/cmd/compile/internal/arm64/ssa.go @@ -260,6 +260,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case ssa.OpARM64MOVDaddr: p := s.Prog(arm64.AMOVD) p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() @@ -281,7 +282,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case nil: // No sym, just MOVD $off(SP), R wantreg = "SP" - p.From.Reg = arm64.REGSP p.From.Offset = v.AuxInt } if reg := v.Args[0].RegName(); reg != wantreg { diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 221b8497f1..08ec638f44 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -898,6 +898,17 @@ var linuxAMD64Tests = []*asmTest{ }`, []string{"\tCMPL\t[A-Z]"}, }, + { + // make sure assembly output has matching offset and base register. + ` + func f72(a, b int) int { + var x [16]byte // use some frame + _ = x + return b + } + `, + []string{"b\\+40\\(SP\\)"}, + }, } var linux386Tests = []*asmTest{ @@ -1302,6 +1313,17 @@ var linuxARMTests = []*asmTest{ `, []string{"\tCLZ\t"}, }, + { + // make sure assembly output has matching offset and base register. + ` + func f13(a, b int) int { + var x [16]byte // use some frame + _ = x + return b + } + `, + []string{"b\\+4\\(FP\\)"}, + }, } var linuxARM64Tests = []*asmTest{ @@ -1473,7 +1495,7 @@ var linuxARM64Tests = []*asmTest{ return } `, - []string{"\tMOVD\t\"\"\\.a\\+[0-9]+\\(RSP\\), R[0-9]+", "\tMOVD\tR[0-9]+, \"\"\\.b\\+[0-9]+\\(RSP\\)"}, + []string{"\tMOVD\t\"\"\\.a\\+[0-9]+\\(FP\\), R[0-9]+", "\tMOVD\tR[0-9]+, \"\"\\.b\\+[0-9]+\\(FP\\)"}, }, } diff --git a/src/cmd/compile/internal/mips/ssa.go b/src/cmd/compile/internal/mips/ssa.go index d2b4885eaa..e65515a85b 100644 --- a/src/cmd/compile/internal/mips/ssa.go +++ b/src/cmd/compile/internal/mips/ssa.go @@ -273,6 +273,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case ssa.OpMIPSMOVWaddr: p := s.Prog(mips.AMOVW) p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() var wantreg string // MOVW $sym+off(base), R // the assembler expands it as the following: @@ -291,7 +292,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case nil: // No sym, just MOVW $off(SP), R wantreg = "SP" - p.From.Reg = mips.REGSP p.From.Offset = v.AuxInt } if reg := v.Args[0].RegName(); reg != wantreg { diff --git a/src/cmd/compile/internal/mips64/ssa.go b/src/cmd/compile/internal/mips64/ssa.go index 5a7a601942..db163f3e9d 100644 --- a/src/cmd/compile/internal/mips64/ssa.go +++ b/src/cmd/compile/internal/mips64/ssa.go @@ -247,6 +247,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case ssa.OpMIPS64MOVVaddr: p := s.Prog(mips.AMOVV) p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() var wantreg string // MOVV $sym+off(base), R // the assembler expands it as the following: @@ -265,7 +266,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case nil: // No sym, just MOVV $off(SP), R wantreg = "SP" - p.From.Reg = mips.REGSP p.From.Offset = v.AuxInt } if reg := v.Args[0].RegName(); reg != wantreg { diff --git a/src/cmd/compile/internal/ppc64/ssa.go b/src/cmd/compile/internal/ppc64/ssa.go index a95dabccf0..5fe140fdcf 100644 --- a/src/cmd/compile/internal/ppc64/ssa.go +++ b/src/cmd/compile/internal/ppc64/ssa.go @@ -638,6 +638,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case ssa.OpPPC64MOVDaddr: p := s.Prog(ppc64.AMOVD) p.From.Type = obj.TYPE_ADDR + p.From.Reg = v.Args[0].Reg() p.To.Type = obj.TYPE_REG p.To.Reg = v.Reg() @@ -660,7 +661,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { case nil: // No sym, just MOVD $off(SP), R wantreg = "SP" - p.From.Reg = ppc64.REGSP p.From.Offset = v.AuxInt } if reg := v.Args[0].RegName(); reg != wantreg { diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go index cfda99f602..8abf732b2c 100644 --- a/src/cmd/internal/obj/arm/asm5.go +++ b/src/cmd/internal/obj/arm/asm5.go @@ -1167,6 +1167,11 @@ func (c *ctxt5) aclass(a *obj.Addr) int { return C_ADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = c.autosize + a.Offset if t := immaddr(int32(c.instoffset)); t != 0 { if immhalf(int32(c.instoffset)) { @@ -1185,6 +1190,11 @@ func (c *ctxt5) aclass(a *obj.Addr) int { return C_LAUTO case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = c.autosize + a.Offset + 4 if t := immaddr(int32(c.instoffset)); t != 0 { if immhalf(int32(c.instoffset)) { @@ -1285,10 +1295,20 @@ func (c *ctxt5) aclass(a *obj.Addr) int { return C_LCONADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = c.autosize + a.Offset return c.aconsize() case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = c.autosize + a.Offset + 4 return c.aconsize() } diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go index 04a481863a..4419909f69 100644 --- a/src/cmd/internal/obj/arm64/asm7.go +++ b/src/cmd/internal/obj/arm64/asm7.go @@ -1149,10 +1149,20 @@ func (c *ctxt7) aclass(a *obj.Addr) int { return C_GOTADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset return autoclass(c.instoffset) case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + 8 return autoclass(c.instoffset) @@ -1228,10 +1238,20 @@ func (c *ctxt7) aclass(a *obj.Addr) int { return C_VCONADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset goto aconsize case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + 8 goto aconsize } diff --git a/src/cmd/internal/obj/mips/asm0.go b/src/cmd/internal/obj/mips/asm0.go index 3cfb260d60..6257e5b83d 100644 --- a/src/cmd/internal/obj/mips/asm0.go +++ b/src/cmd/internal/obj/mips/asm0.go @@ -556,6 +556,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int { return C_LEXT case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -563,6 +568,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int { return C_LAUTO case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -616,6 +626,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int { return C_LECON case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON @@ -623,6 +638,11 @@ func (c *ctxt0) aclass(a *obj.Addr) int { return C_LACON case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index bdbac03f9c..4d787b1c35 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -758,6 +758,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int { return C_GOTADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -765,6 +770,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int { return C_LAUTO case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -817,6 +827,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int { return C_LCON case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON @@ -824,6 +839,11 @@ func (c *ctxt9) aclass(a *obj.Addr) int { return C_LACON case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON diff --git a/src/cmd/internal/obj/s390x/asmz.go b/src/cmd/internal/obj/s390x/asmz.go index 3bba7b2a5c..6d2b870f0a 100644 --- a/src/cmd/internal/obj/s390x/asmz.go +++ b/src/cmd/internal/obj/s390x/asmz.go @@ -505,6 +505,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int { return C_GOTADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -512,6 +517,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int { return C_LAUTO case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SAUTO @@ -567,6 +577,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int { return C_SYMADDR case obj.NAME_AUTO: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-SP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON @@ -574,6 +589,11 @@ func (c *ctxtz) aclass(a *obj.Addr) int { return C_LACON case obj.NAME_PARAM: + if a.Reg == REGSP { + // unset base register for better printing, since + // a.Offset is still relative to pseudo-FP. + a.Reg = obj.REG_NONE + } c.instoffset = int64(c.autosize) + a.Offset + c.ctxt.FixedFrameSize() if c.instoffset >= -BIG && c.instoffset < BIG { return C_SACON From 6f08c935a9474a300d34e7a476628c2667142474 Mon Sep 17 00:00:00 2001 From: Seiji Takahashi Date: Sun, 30 Jul 2017 21:00:09 +0900 Subject: [PATCH 13/36] cmd/go: show examples with empty output in go test -list Fixes #21205 Change-Id: I81b001eb42cbf2a5d5b7b82eb63548b22f501be5 Reviewed-on: https://go-review.googlesource.com/52110 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- src/cmd/go/go_test.go | 17 +++++++++++++++ .../go/testdata/src/testlist/bench_test.go | 14 +++++++++++++ .../go/testdata/src/testlist/example_test.go | 21 +++++++++++++++++++ src/cmd/go/testdata/src/testlist/test_test.go | 10 +++++++++ src/testing/testing.go | 2 +- 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/cmd/go/testdata/src/testlist/bench_test.go create mode 100644 src/cmd/go/testdata/src/testlist/example_test.go create mode 100644 src/cmd/go/testdata/src/testlist/test_test.go diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index e706e27bdf..7d80d965ae 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -4314,3 +4314,20 @@ func TestTestRegexps(t *testing.T) { t.Errorf("reduced output:<<<\n%s>>> want:<<<\n%s>>>", have, want) } } + +func TestListTests(t *testing.T) { + var tg *testgoData + testWith := func(listName, expected string) func(*testing.T) { + return func(t *testing.T) { + tg = testgo(t) + defer tg.cleanup() + tg.run("test", "./testdata/src/testlist/...", fmt.Sprintf("-list=%s", listName)) + tg.grepStdout(expected, fmt.Sprintf("-test.list=%s returned %q, expected %s", listName, tg.getStdout(), expected)) + } + } + + t.Run("Test", testWith("Test", "TestSimple")) + t.Run("Bench", testWith("Benchmark", "BenchmarkSimple")) + t.Run("Example1", testWith("Example", "ExampleSimple")) + t.Run("Example2", testWith("Example", "ExampleWithEmptyOutput")) +} diff --git a/src/cmd/go/testdata/src/testlist/bench_test.go b/src/cmd/go/testdata/src/testlist/bench_test.go new file mode 100644 index 0000000000..22f147b633 --- /dev/null +++ b/src/cmd/go/testdata/src/testlist/bench_test.go @@ -0,0 +1,14 @@ +package testlist + +import ( + "fmt" + "testing" +) + +func BenchmarkSimplefunc(b *testing.B) { + b.StopTimer() + b.StartTimer() + for i := 0; i < b.N; i++ { + _ = fmt.Sprint("Test for bench") + } +} diff --git a/src/cmd/go/testdata/src/testlist/example_test.go b/src/cmd/go/testdata/src/testlist/example_test.go new file mode 100644 index 0000000000..0298dfde81 --- /dev/null +++ b/src/cmd/go/testdata/src/testlist/example_test.go @@ -0,0 +1,21 @@ +package testlist + +import ( + "fmt" +) + +func ExampleSimple() { + fmt.Println("Test with Output.") + + // Output: Test with Output. +} + +func ExampleWithEmptyOutput() { + fmt.Println("") + + // Output: +} + +func ExampleNoOutput() { + _ = fmt.Sprint("Test with no output") +} diff --git a/src/cmd/go/testdata/src/testlist/test_test.go b/src/cmd/go/testdata/src/testlist/test_test.go new file mode 100644 index 0000000000..bdc09f27c5 --- /dev/null +++ b/src/cmd/go/testdata/src/testlist/test_test.go @@ -0,0 +1,10 @@ +package testlist + +import ( + "fmt" + "testing" +) + +func TestSimple(t *testing.T) { + _ = fmt.Sprint("Test simple") +} diff --git a/src/testing/testing.go b/src/testing/testing.go index 3d1c0c6947..11af926c80 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -970,7 +970,7 @@ func listTests(matchString func(pat, str string) (bool, error), tests []Internal } } for _, example := range examples { - if ok, _ := matchString(*matchList, example.Name); ok && example.Output != "" { + if ok, _ := matchString(*matchList, example.Name); ok { fmt.Println(example.Name) } } From 193eda7291c570e84307b3122a4f496a77b0fa4c Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Tue, 1 Aug 2017 17:41:51 +0200 Subject: [PATCH 14/36] time: skip ZoneAbbr test in timezones with no abbreviation The testZoneAbbr assumes that Parse(RFC1123, t1.Format(RFC1123)) will always succeed. This is not true because Format will fall back to the numeric zone (ex. -07) for timezones with no abbreviation, but Parse won't accept the numeric zone when the layout specifies 'MST' (an abbreviation). Skip the zone abbreviation test in timezones with no abbreviation. Fixes #21183 Change-Id: If04691cc23ae1075d8a953733024e17f5a7646de Reviewed-on: https://go-review.googlesource.com/52430 Run-TryBot: Alberto Donizetti TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- src/time/zoneinfo_windows_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/time/zoneinfo_windows_test.go b/src/time/zoneinfo_windows_test.go index 7ac1e86822..cf3b428c09 100644 --- a/src/time/zoneinfo_windows_test.go +++ b/src/time/zoneinfo_windows_test.go @@ -14,6 +14,14 @@ func testZoneAbbr(t *testing.T) { t1 := Now() // discard nsec t1 = Date(t1.Year(), t1.Month(), t1.Day(), t1.Hour(), t1.Minute(), t1.Second(), 0, t1.Location()) + + // Skip the test if we're in a timezone with no abbreviation. + // Format will fallback to the numeric abbreviation, and + // Parse(RFC1123, ..) will fail (see Issue 21183). + if tz := t1.Format("MST"); tz[0] == '-' || tz[0] == '+' { + t.Skip("No zone abbreviation") + } + t2, err := Parse(RFC1123, t1.Format(RFC1123)) if err != nil { t.Fatalf("Parse failed: %v", err) From b63db76c4ae4e154ed40b4ec3c782d7fe9c0d3b6 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 2 Aug 2017 10:49:20 -0700 Subject: [PATCH 15/36] testsanitizers: check that tsan program runs, skip tsan10 on gcc Check not only that a tsan program can be built, but also that it runs. This fails with some installations of GCC 7. Skip the tsan10 program when using GCC, as it reportedly hangs. This is a patch to help people build 1.9; we may be able to do a better fix for 1.10. Updates #21196 Change-Id: Icd1ffbd018dc65a97ff45cab1264b9b0c7fa0ab2 Reviewed-on: https://go-review.googlesource.com/52790 Run-TryBot: Ian Lance Taylor Run-TryBot: Bryan Mills Reviewed-by: Bryan Mills TryBot-Result: Gobot Gobot --- misc/cgo/testsanitizers/test.bash | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/misc/cgo/testsanitizers/test.bash b/misc/cgo/testsanitizers/test.bash index ea08f37432..218af396a7 100755 --- a/misc/cgo/testsanitizers/test.bash +++ b/misc/cgo/testsanitizers/test.bash @@ -156,15 +156,18 @@ if test "$tsan" = "yes"; then if ! $CC -fsanitize=thread ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$ &> ${TMPDIR}/testsanitizers$$.err; then ok=no fi - if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then + if grep "unrecognized" ${TMPDIR}/testsanitizers$$.err >& /dev/null; then echo "skipping tsan tests: -fsanitize=thread not supported" tsan=no - elif test "$ok" != "yes"; then - cat ${TMPDIR}/testsanitizers$$.err - echo "skipping tsan tests: -fsanitizer=thread build failed" - tsan=no - fi - rm -f ${TMPDIR}/testsanitizers$$* + elif test "$ok" != "yes"; then + cat ${TMPDIR}/testsanitizers$$.err + echo "skipping tsan tests: -fsanitizer=thread build failed" + tsan=no + elif ! ${TMPDIR}/testsanitizers$$ 2>&1; then + echo "skipping tsan tests: running tsan program failed" + tsan=no + fi + rm -f ${TMPDIR}/testsanitizers$$* fi # Run a TSAN test. @@ -196,8 +199,10 @@ if test "$tsan" = "yes"; then # These tests are only reliable using clang or GCC version 7 or later. # Otherwise runtime/cgo/libcgo.h can't tell whether TSAN is in use. ok=false + clang=false if ${CC} --version | grep clang >/dev/null 2>&1; then ok=true + clang=true else ver=$($CC -dumpversion) major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/') @@ -213,7 +218,12 @@ if test "$tsan" = "yes"; then testtsan tsan5.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" testtsan tsan7.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" - testtsan tsan10.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" + + # tsan10 reportedly hangs when built with GCC: issue #21196. + if test "$clang" = "true"; then + testtsan tsan10.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" + fi + testtsan tsan11.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" testtsan tsan12.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan" From a8730cd93a6731a14519902ccfed604971d3e8dc Mon Sep 17 00:00:00 2001 From: Andrew Bonventre Date: Wed, 2 Aug 2017 16:31:46 -0400 Subject: [PATCH 16/36] doc: hide video and share if being served from CN In the case where requests are coming from mainland China, hide links to locations that are blocked and functionality that is not permitted. Additionally, some very small cleanup of the JS. This change requires https://go-review.googlesource.com/c/52873 Change-Id: I7fc68748e629dbe5b966d6bf117e7f7b546966eb Reviewed-on: https://go-review.googlesource.com/52872 Reviewed-by: Chris Broadfoot --- doc/root.html | 151 ++++++++++++++++++++++++++------------------------ 1 file changed, 80 insertions(+), 71 deletions(-) diff --git a/doc/root.html b/doc/root.html index 27dbc74ab6..0b3c74954b 100644 --- a/doc/root.html +++ b/doc/root.html @@ -6,7 +6,9 @@
    +{{if not $.GoogleCN}} +{{end}}
    Try Go

    Vim Go

    Visual Studio Code Go

    vim

    Visual Studio Code

    Gogland

    Go-Plus

    Atom
    Editing features