1
0
mirror of https://github.com/golang/go synced 2024-10-03 13:21:22 -06:00
Commit Graph

30414 Commits

Author SHA1 Message Date
Emmanuel Odeke
2b59b15f6b encoding/json: example on MarshalJSON, UnmarshalJSON
Updates #16360.

Change-Id: I5bf13d3367e68c5d8435f6ef2161d5a74cc747a7
Reviewed-on: https://go-review.googlesource.com/29611
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-03 20:18:52 +00:00
Russ Cox
43f954e098 testing: mark tests and benchmarks failed if a race occurs during execution
Before:

$ go test -race -v -run TestRace
=== RUN   TestRace
==================
WARNING: DATA RACE
Write at 0x00c420076420 by goroutine 7:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b

Previous write at 0x00c420076420 by goroutine 6:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104

Goroutine 7 (running) created at:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104

Goroutine 6 (running) created at:
  testing.(*T).Run()
      /Users/rsc/go/src/testing/testing.go:693 +0x536
  testing.runTests.func1()
      /Users/rsc/go/src/testing/testing.go:877 +0xaa
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104
  testing.runTests()
      /Users/rsc/go/src/testing/testing.go:883 +0x4ac
  testing.(*M).Run()
      /Users/rsc/go/src/testing/testing.go:818 +0x1c3
  main.main()
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f
==================
--- PASS: TestRace (0.00s)
PASS
Found 1 data race(s)
FAIL	_/Users/rsc/go/src/cmd/go/testdata/src/testrace	1.026s
$

After:

$ go test -race -v -run TestRace
=== RUN   TestRace
==================
WARNING: DATA RACE
Write at 0x00c420076420 by goroutine 7:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace.func1()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:10 +0x3b

Previous write at 0x00c420076420 by goroutine 6:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:13 +0xcc
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104

Goroutine 7 (running) created at:
  _/Users/rsc/go/src/cmd/go/testdata/src/testrace.TestRace()
      /Users/rsc/go/src/cmd/go/testdata/src/testrace/race_test.go:12 +0xbb
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104

Goroutine 6 (running) created at:
  testing.(*T).Run()
      /Users/rsc/go/src/testing/testing.go:693 +0x536
  testing.runTests.func1()
      /Users/rsc/go/src/testing/testing.go:877 +0xaa
  testing.tRunner()
      /Users/rsc/go/src/testing/testing.go:656 +0x104
  testing.runTests()
      /Users/rsc/go/src/testing/testing.go:883 +0x4ac
  testing.(*M).Run()
      /Users/rsc/go/src/testing/testing.go:818 +0x1c3
  main.main()
      _/Users/rsc/go/src/cmd/go/testdata/src/testrace/_test/_testmain.go:42 +0x20f
==================
--- FAIL: TestRace (0.00s)
	testing.go:609: race detected during execution of test
FAIL
FAIL	_/Users/rsc/go/src/cmd/go/testdata/src/testrace	0.022s
$

Fixes #15972.

Change-Id: Idb15b8ab81d65637bb535c7e275595ca4a6e450e
Reviewed-on: https://go-review.googlesource.com/32615
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 18:19:49 +00:00
Dan Harrington
f3862742b6 net/http: support If-Match in ServeContent
- Added support for If-Match and If-Unmodified-Since.
- Precondition checks now more strictly follow RFC 7232 section 6, which
affects precedence when multiple condition headers are present.
- When serving a 304, Last-Modified header is now removed when no ETag is
present (as suggested by RFC 7232 section 4.1).
- If-None-Match supports multiple ETags.
- ETag comparison now correctly handles weak ETags.

Fixes #17572

Change-Id: I35039dea6811480ccf2889f8ed9c6a39ce34bfff
Reviewed-on: https://go-review.googlesource.com/32014
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 18:14:56 +00:00
Robert Griesemer
18f0e88103 go/internal/gcimporter: backport changes from x/tools/go/gcimporter15
See https://go-review.googlesource.com/32581.

This makes x/tools/go/gcimporter15/bimport.go a close copy again
and the importer more robust.

Change-Id: If96ad6acd611878b7dfa6a13d005d847ece82ab6
Reviewed-on: https://go-review.googlesource.com/32647
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-11-03 18:10:35 +00:00
Mohit Agarwal
322436b78c cmd/compile: don't panic if syntax.ReadFile returns an error
Fixes #17772

Change-Id: I0f2094400c454828aa57a8d172dadeac4ddb6d35
Reviewed-on: https://go-review.googlesource.com/32691
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-03 18:05:38 +00:00
David Chase
4141054d19 runtime/cgo: correct type declaration for Windows
Newer versions of gcc notice a type mismatch and complain.
Fix code to match documented signature in MSDN.
Trybots say this still compiles with the older (5.1) version
of gcc.

Fixes #17771.

Change-Id: Ib3fe6f71b40751e1146249e31232da5ac69b9e00
Reviewed-on: https://go-review.googlesource.com/32646
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 17:42:01 +00:00
Russ Cox
b89135777b crypto/x509: expose UnknownAuthorityError.Cert
This matches exposing CertificateInvalidError.Cert.
and (exposing but not the spelling of) HostnameError.Certificate.

Fixes #13519.

Change-Id: Ifae9a09e063d642c09de3cdee8a728ff06d3a5df
Reviewed-on: https://go-review.googlesource.com/32644
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 17:26:23 +00:00
Russ Cox
b2290229c2 cmd/cgo: add #line directives to avoid printing bogus references to Go source files
A bit contrived to come up with an example, but it happened in #15836, somehow.

	$ cat /tmp/x.go
	package main

	/*
	#include <stddef.h>

	int foo(void);

	int foo(void) {
		return 2;
	}

	#define int asdf
	*/
	import "C"

	func main() {
		println(C.foo())
	}

	$ go run /tmp/x.go
	# command-line-arguments
	cgo-builtin-prolog:9:31: error: unknown type name 'asdf'   <<<<<
	_GoString_ GoStringN(char *p, int l);
	                              ^
	/tmp/x.go:12:13: note: expanded from macro 'int'
	#define int asdf
	            ^
	cgo-builtin-prolog:10:28: error: unknown type name 'asdf'  <<<<<
	_GoBytes_ GoBytes(void *p, int n);
	                           ^
	/tmp/x.go:12:13: note: expanded from macro 'int'
	#define int asdf
	            ^
	2 errors generated.

The two marked lines used to refer incorrectly to /tmp/x.go.

Fixes #15836.

Change-Id: I08ef60a53cfd148112fceb651eaf7b75d94a7a8d
Reviewed-on: https://go-review.googlesource.com/32613
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:35:25 +00:00
Russ Cox
a4a4d43028 cmd/cover: change covered block for switch/select case to exclude expression
Consider a switch like

	switch x {
	case foo:
		f()
		g()
	}

Before, the coverage annotation for the block calling f and g included
in its position span the text for 'case foo:'. This looks nice in the coverage
report, but it breaks the invariant that coverage blocks are disjoint if
you have a more complex expression like:

	switch x {
	case func() int { return foo }():
		f()
		g()
	}

Then the coverage analysis wants to annotate the func literal body,
which overlaps with the case body, because the case body is considered
to begin at the case token.

Change the annotation for a case body to start just after the colon of
the case clause, avoiding any potential conflict with complex case
expressions. Could have started at the colon instead, but it seemed
less weird to start just after it.

Fixes #16540.

Change-Id: I1fec4bc2a53c7092e649dc0d4be1680a697cb79b
Reviewed-on: https://go-review.googlesource.com/32612
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-11-03 16:13:06 +00:00
Russ Cox
95e809f0e5 cmd/go: clear GIT_ALLOW_PROTOCOL during tests
Clear it before any tests begin.
Clear it again after TestIsSecureGitAllowProtocol sets it.

Fixes #17700.

Change-Id: I6ea50d37f8222d8c7c9fee0b1eac3bbdfb5d133e
Reviewed-on: https://go-review.googlesource.com/32640
Reviewed-by: Quentin Smith <quentin@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-11-03 16:08:35 +00:00
Russ Cox
a35decf5a7 cmd/go: fix TestIssue11457
The goal of the test is to provoke a custom import path check error,
which will contain the current repo path, to see that it says ssh:// in it.

But the fix to #16471 made the test no longer provoke that error.
Provoke the error by checking out from rsc.io instead of github.com/rsc.

Fixes #17701.

Change-Id: I750ffda2ff59c2be8e111d26160997214a73fd9a
Reviewed-on: https://go-review.googlesource.com/32641
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:07:08 +00:00
Russ Cox
5f9fb1ce02 cmd/go: remove .o and .a files in builder.collect
This matches the removal of .so files and makes the processing
of '-L/path/to -lfoo' and plain '/path/to/foo.a' match.

Fixes #16463.

Change-Id: I1464c5390d7eb6a3a33b4b2c951f87ef392ec94a
Reviewed-on: https://go-review.googlesource.com/32642
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:06:37 +00:00
Russ Cox
23e6e11245 encoding/asn1: document that default:x tag only has meaning with optional tag
Fixes #16712.

Change-Id: Ib216059c6c0c952162c19e080dcf3799f0652a8d
Reviewed-on: https://go-review.googlesource.com/32171
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Quentin Smith <quentin@golang.org>
2016-11-03 16:04:55 +00:00
Russ Cox
ced137fad4 misc/cgo/testsanitizers: skip tests when vm.overcommit_memory=2
Fixes #17689.

Change-Id: I45a14e6bf4b2647431105f3e0b63b7076b6655d2
Reviewed-on: https://go-review.googlesource.com/32635
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:04:33 +00:00
Russ Cox
3345802e8a time: document that only Jan and January, Mon and Monday are recognized
Not "J", not "JAN", not "jan", etc.

Fixes #17523.

Change-Id: I16b5da97e73d88c6680c36401d30f8a195061527
Reviewed-on: https://go-review.googlesource.com/32636
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-11-03 16:04:14 +00:00
Russ Cox
1c08c728dc cmd/go: fix coverage in xtest of cgo package
Cover-annotated cgo-rebuilt package for xtest was
not linked into package graph and so not being rebuilt.
Link into package graph.

Fixes #13625.

Change-Id: I685f7276f92bbc85fbc4b389111c83d9fe517637
Reviewed-on: https://go-review.googlesource.com/32614
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:03:30 +00:00
Russ Cox
3ce46e3e9c cmd/go: fix TestGoGetDashTIssue8181
The test case was importing golang.org/x/build/cmd/cl,
which is a package main and cannot be imported.
The test case (stored in a separate repo) has been changed
to import golang.org/x/build/gerrit. Update the test accordingly.

Fixes #17702.

Change-Id: I80e150092111b5a04bb00c992b32edb271edb086
Reviewed-on: https://go-review.googlesource.com/32616
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 16:02:19 +00:00
Russ Cox
9efcdd4e69 cmd/go: use new HTTP-only server insecure.go-get-issue-15410.appspot.com instead of wh3rd.net
Fixes #15410.

Change-Id: I9964d0162a3cae690afeb889b1822cf79c80b89a
Reviewed-on: https://go-review.googlesource.com/32639
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-11-03 16:02:07 +00:00
Robert Griesemer
f4f6b64750 cmd/compile: update/remove outdated comments
Change-Id: I5a74be1593dca8ba5e0829f0bae35dc9ce702671
Reviewed-on: https://go-review.googlesource.com/32672
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-11-03 15:58:01 +00:00
Quentin Smith
21c114e930 runtime/testdata/testprog: increase GCFairness2 timeout to 1s
OpenBSD's scheduler causes preemption to take 20+ms, so 30ms is not
enough time for 3 goroutines to run. This change continues to sleep for
30ms, but if it finds that the 3 goroutines have not run, it sleeps for
an additional 1s before declaring failure.

Updates #17712

Change-Id: I3e886e40d05192b7cb71b4f242af195836ef62a8
Reviewed-on: https://go-review.googlesource.com/32634
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Quentin Smith <quentin@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-03 15:48:57 +00:00
Josh Bleecher Snyder
e83911d6fc cmd/vet/all: add s390x support
Some of these whitelist entries could be
eliminated, e.g. by the addition of Go
declarations, but this is a start.

Change-Id: I2fb3234cf05ebc6b161aacac2d4c15d810d50527
Reviewed-on: https://go-review.googlesource.com/32671
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 15:33:27 +00:00
Josh Bleecher Snyder
62dafbb4c6 runtime: fix s390x asm frame sizes
Found by vet.

Change-Id: I1d78454facdd3522509ecfe7c73b21c4602ced8a
Reviewed-on: https://go-review.googlesource.com/32670
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
2016-11-03 15:04:59 +00:00
Josh Bleecher Snyder
7f4c3e8710 all: update s390x assembly to use vet-friendly names
No functional changes.

Change-Id: Ibf592c04be506a76577d48574e84ab20c3238b49
Reviewed-on: https://go-review.googlesource.com/32589
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
2016-11-03 15:04:44 +00:00
Mohit Agarwal
a3aaa189a4 cmd/go: run mkalldocs.sh
Follow-up to CL 32114

Change-Id: I75247ed9c1c0a0e8a278eb75a60d4c5bee355409
Reviewed-on: https://go-review.googlesource.com/32690
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 14:55:53 +00:00
Russ Cox
fc2e282c04 cmd/go: add version of GOROOT to go bug details
Fixes #15877.

Change-Id: Ia1e327c0cea3be43e5f8ba637c97c223cee4bb5a
Reviewed-on: https://go-review.googlesource.com/32643
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 14:27:24 +00:00
Russ Cox
89ccd5795c cmd/pprof: use correct default handler for Go programs
The original go tool pprof (written in Perl) got this right.
The Go rewrite never has, but should.

Change-Id: Ie1fc571214c61b1b5654a0bc90e15eb889adf059
Reviewed-on: https://go-review.googlesource.com/32617
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 14:27:11 +00:00
David Crawshaw
8eb9fdaa01 cmd/compile: write type symbols referenced in ptabs
The exported symbol for a plugin can be the only reference to a
type in a program. In particular, "var F func()" will have
the type *func(), which is uncommon.

Fixes #17140

Change-Id: Ide2104edbf087565f5377374057ae54e0c00c57e
Reviewed-on: https://go-review.googlesource.com/29692
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 14:07:34 +00:00
David du Colombier
5ac3e7d6a7 net: disallow dialing and listening on port > 65535 on Plan 9
Since Dial(":80") was implemented on Plan 9 (CL 32593),
TestProtocolDialError is failing because dialing a port
superior to 65535 is supported on Plan 9.

This change disallows dialing and listening on ports
superior to 65535.

Fixes #17761.

Change-Id: I95e8a163eeacf1ccd8ece7b650f16a0531c59709
Reviewed-on: https://go-review.googlesource.com/32594
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 13:58:02 +00:00
David du Colombier
97b49f660c net: fix Dial(":80") on Plan 9
CL 32101 fixed Dial(":80") on Windows and added TestDialLocal,
which was failing on Plan 9, because it wasn't implemented
on Plan 9.

This change implements Dial(":80") by connecting to 127.0.0.1
or ::1 (depending on network), so it works as documented.

Fixes #17760.

Change-Id: If0ff769299e09bebce11fc3708639c1d8c96c280
Reviewed-on: https://go-review.googlesource.com/32593
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 13:57:39 +00:00
Josh Bleecher Snyder
aa8c8e770e cmd/vet: teach vet about ast.AliasSpec
Fixes #17755

Change-Id: I1ad1edc382b1312d992963054eb82648cb5112d2
Reviewed-on: https://go-review.googlesource.com/32588
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 13:32:05 +00:00
Ilya Tocar
10f757486e cmd/compile/internal/ssa: generate bswap on AMD64
Generate bswap+load/store for reading/writing big endian data.
Helps encoding/binary.

name                    old time/op    new time/op    delta
ReadSlice1000Int32s-8     5.06µs ± 8%    4.58µs ± 8%   -9.50%        (p=0.000 n=10+10)
ReadStruct-8              1.07µs ± 0%    1.05µs ± 0%   -1.51%         (p=0.000 n=9+10)
ReadInts-8                 367ns ± 0%     363ns ± 0%   -1.15%          (p=0.000 n=8+9)
WriteInts-8                475ns ± 1%     469ns ± 0%   -1.45%        (p=0.000 n=10+10)
WriteSlice1000Int32s-8    5.03µs ± 3%    4.50µs ± 3%  -10.45%          (p=0.000 n=9+9)
PutUvarint32-8            17.2ns ± 0%    17.2ns ± 0%     ~     (all samples are equal)
PutUvarint64-8            46.7ns ± 0%    46.7ns ± 0%     ~           (p=0.509 n=10+10)

name                    old speed      new speed      delta
ReadSlice1000Int32s-8    791MB/s ± 8%   875MB/s ± 8%  +10.53%        (p=0.000 n=10+10)
ReadStruct-8            70.0MB/s ± 0%  71.1MB/s ± 0%   +1.54%         (p=0.000 n=9+10)
ReadInts-8              81.6MB/s ± 0%  82.6MB/s ± 0%   +1.21%          (p=0.000 n=9+9)
WriteInts-8             63.0MB/s ± 1%  63.9MB/s ± 0%   +1.45%        (p=0.000 n=10+10)
WriteSlice1000Int32s-8   796MB/s ± 4%   888MB/s ± 3%  +11.65%          (p=0.000 n=9+9)
PutUvarint32-8           233MB/s ± 0%   233MB/s ± 0%     ~           (p=0.089 n=10+10)
PutUvarint64-8           171MB/s ± 0%   171MB/s ± 0%     ~            (p=0.137 n=10+9)

Change-Id: Ia2dbdef92198eaa7e2af5443a8ed586d4b401ffb
Reviewed-on: https://go-review.googlesource.com/32222
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-11-03 12:34:12 +00:00
Josh Bleecher Snyder
ca5cea9dca cmd/compile: add OMOD to list of ops that might panic
Follow-up to CL 32551.

Change-Id: If68f9581a7f13e04796aaff2007c09f8ea2c3611
Reviewed-on: https://go-review.googlesource.com/32586
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-11-03 06:09:52 +00:00
Hiroshi Ioka
154d013155 encoding/asn1: return error for unexported fields in Marshal, Unmarshal
The old code cannot handle unexported fields, it panics.
The new code returns error instead.

Fixes #17462

Change-Id: I927fc46b21d60e86cb52e84c65f2122f9159b21d
Reviewed-on: https://go-review.googlesource.com/31540
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-11-03 03:44:05 +00:00
Brad Fitzpatrick
be7c50a710 net/http: deflake TestServerSetKeepAlivesEnabledClosesConns
Fixes #17754
Updates #9478 (details in here)

Change-Id: Iae2c1ca05a18ed266b53b2594c22fc57fab33c5e
Reviewed-on: https://go-review.googlesource.com/32587
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-03 03:20:01 +00:00
Josh Bleecher Snyder
66504485eb cmd/compile/internal/gc: make tests run faster
TestAssembly takes 20s on my machine,
which is too slow for normal operation.
Marking as -short has its dangers (#17472),
but hopefully we'll soon have a builder for that.

All the SSA tests are hermetic and not time sensitive
and can thus be run in parallel.
Reduces the cmd/compile/internal/gc test time during
all.bash on my laptop from 42s to 7s.

Updates #17751

Change-Id: Idd876421db23b9fa3475e8a9b3355a5dc92a5a29
Reviewed-on: https://go-review.googlesource.com/32585
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-03 01:07:08 +00:00
Brad Fitzpatrick
827f2accc1 net/http: update bundled http2 to fix test flake
Updates http2 to x/net/http2 git rev 569280fa for:

   http2: fix over-aggressive ignoring of frames while in "go away" mode
   https://golang.org/cl/32583

Fixes #17733

Change-Id: I4008d2e14ce89782ce7e18b441b1181f98623b9d
Reviewed-on: https://go-review.googlesource.com/32584
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-11-03 00:53:52 +00:00
Robert Griesemer
627f4d85ba go/types: set up correct type with NewAlias
Change-Id: I4b035b3539c98e5b1442d1009d457cbc199b42ee
Reviewed-on: https://go-review.googlesource.com/32637
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-11-02 23:31:37 +00:00
Michael Munday
5513f855f6 cmd/vet: add test case for ppc64{,le}
Adapted from the mips64 test case.

Fixes #17745.

Change-Id: I46f0900028adb936dcab2cdc701ea11d0a3cb95e
Reviewed-on: https://go-review.googlesource.com/32611
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2016-11-02 22:40:34 +00:00
Keith Randall
cf28e5cc9d cmd/compile: compute faulting args before writing args to stack
when compiling f(a, b, c), we do something like:
  *(SP+0) = eval(a)
  *(SP+8) = eval(b)
  *(SP+16) = eval(c)
  call f

If one of those evaluations is later determined to unconditionally panic
(say eval(b) in this example), then the call is deadcode eliminated. But
any previous argument write (*(SP+0)=... here) is still around. Becuase
we only compute the size of the outarg area for calls which are still
around at the end of optimization, the space needed for *(SP+0)=v is not
accounted for and thus the outarg area may be too small.

The fix is to make sure that we evaluate any potentially panicing
operation before we write any of the args to the stack. It turns out
that fix is pretty easy, as we already have such a mechanism available
for function args. We just need to extend it to possibly panicing args
as well.

The resulting code (if b and c can panic, but a can't) is:
  tmpb = eval(b)
  *(SP+16) = eval(c)
  *(SP+0) = eval(a)
  *(SP+8) = tmpb
  call f

This change tickled a bug in how we find the arguments for intrinsic
calls, so that latent bug is fixed up as well.

Update #16760.

Change-Id: I0bf5edf370220f82bc036cf2085ecc24f356d166
Reviewed-on: https://go-review.googlesource.com/32551
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-11-02 21:34:12 +00:00
Keith Randall
688995d1e9 cmd/compile: do more type conversion inline
The code to do the conversion is smaller than the
call to the runtime.
The 1-result asserts need to call panic if they fail, but that
code is out of line.

The only conversions left in the runtime are those which
might allocate and those which might need to generate an itab.

Given the following types:
  type E interface{}
  type I interface { foo() }
  type I2 iterface { foo(); bar() }
  type Big [10]int
  func (b Big) foo() { ... }

This CL inlines the following conversions:

was assertE2T
  var e E = ...
  b := i.(Big)
was assertE2T2
  var e E = ...
  b, ok := i.(Big)
was assertI2T
  var i I = ...
  b := i.(Big)
was assertI2T2
  var i I = ...
  b, ok := i.(Big)
was assertI2E
  var i I = ...
  e := i.(E)
was assertI2E2
  var i I = ...
  e, ok := i.(E)

These are the remaining runtime calls:

convT2E:
  var b Big = ...
  var e E = b
convT2I:
  var b Big = ...
  var i I = b
convI2I:
  var i2 I2 = ...
  var i I = i2
assertE2I:
  var e E = ...
  i := e.(I)
assertE2I2:
  var e E = ...
  i, ok := e.(I)
assertI2I:
  var i I = ...
  i2 := i.(I2)
assertI2I2:
  var i I = ...
  i2, ok := i.(I2)

Fixes #17405
Fixes #8422

Change-Id: Ida2367bf8ce3cd2c6bb599a1814f1d275afabe21
Reviewed-on: https://go-review.googlesource.com/32313
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-11-02 21:33:03 +00:00
Keith Randall
761443edd5 cmd/compile: On a runtime.KeepAlive call, keep whole variable alive
We generate an OpKeepAlive for the idata portion of the interface
for a runtime.KeepAlive call.  But given such an op, we need to keep
the entire containing variable alive, not just the range that was
passed to the OpKeepAlive operation.

Fixes #17710

Change-Id: I90de66ec8065e22fb09bcf9722999ddda289ae6e
Reviewed-on: https://go-review.googlesource.com/32477
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-11-02 21:29:41 +00:00
Brad Fitzpatrick
09bb6434f9 net/http: update bundled http2
Update bundled x/net/http2 to x/net git rev 6c4ac8bd for:

   http2: fix Transport race sending RST_STREAM while reading DATA on cancels
   https://golang.org/cl/32571

   http2: remove h2-14 ALPN proto
   https://golang.org/cl/32576

Fixes #16974

Change-Id: I6ff8493a13d2641499fedf33e8005004735352ff
Reviewed-on: https://go-review.googlesource.com/32578
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-02 20:49:58 +00:00
Joe Tsai
2d3cd51dbe archive/tar: disable prefix field in Writer
The proper fix for the Writer is too involved to be done in time
for Go 1.8. Instead, we do a localized fix that simply disables the
prefix encoding logic. While this will prevent some legitimate uses
of prefix, it will ensure that we don't keep outputting invalid
GNU format files that have the prefix field populated.

For headers with long filenames that could have used the prefix field,
they will be promoted to use the PAX format, which ensures that we
will still be able to encode all headers that we were able to do before.

Updates #12594
Fixes #17630
Fixes #9683

Change-Id: Ia97b524ac69865390e2ae8bb0dfb664d40a05add
Reviewed-on: https://go-review.googlesource.com/32234
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-02 20:18:38 +00:00
Michael Munday
eed2bb71d2 cmd/vet: fix go vet on s390x assembly
Test adapted from the mips64 test.

Fixes #15454.

Change-Id: If890c2d18a4a03a08faaa2e674edd7223af60290
Reviewed-on: https://go-review.googlesource.com/22472
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-02 19:21:16 +00:00
Matthew Dempsky
bcc0247331 cmd/compile: avoid double export of aliased objects
Instead of writing out the original object for each alias, ensure we
export the original object before any aliases. This allows the aliases
to simply refer back to the original object by qualified name.

Fixes #17636.

Change-Id: If80fa8c66b8fee8344a00b55d25a8aef22abd859
Reviewed-on: https://go-review.googlesource.com/32575
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-11-02 19:19:36 +00:00
Russ Cox
1a0b1cca4c net: fix Dial(":80") on Windows
Windows sockets allow bind to 0.0.0.0:80 but not connect to it.
To make Listen(":80") / Dial(":80") work as documented on Windows,
connect to 127.0.0.1 or ::1 (depending on network) in place of 0.0.0.0.

Fixes #6290.

Change-Id: Ia27537067276871648546678fbe0f1b8478329fe
Reviewed-on: https://go-review.googlesource.com/32101
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-11-02 19:15:11 +00:00
Russ Cox
c56cc9b3b5 testing: introduce testing/internal/testdeps for holding testmain dependencies
Currently, we don't have package testing to import package regexp directly,
because then regexp can't have internal tests (or at least they become more
difficult to write), for fear of an import cycle. The solution we've been using
is for the generated test main package (pseudo-import path "testmain", package main)
to import regexp and pass in a matchString function for use by testing when
implementing the -run flags. This lets testing use regexp but without depending
on regexp and creating unnecessary cycles.

We want to add a few dependencies to runtime/pprof, notably regexp
but also compress/gzip, without causing those packages to have to work
hard to write internal tests.

Restructure the (dare I say it) dependency injection of regexp.MatchString
to be more general, and use it for the runtime/pprof functionality in addition
to the regexp functionality. The new package testing/internal/testdeps is
the root for the testing dependencies handled this way.

Code using testing.MainStart will have to change from passing in a matchString
implementation to passing in testdeps.TestDeps{}. Users of 'go test' don't do this,
but other build systems that have recreated 'go test' (for example, Blaze/Bazel)
may need to be updated. The new testdeps setup should make future updates
unnecessary, but even so we keep the comment about MainStart not being
subject to Go 1 compatibility.

Change-Id: Iec821d2afde10c79f95f3b23de5e71b219f47b92
Reviewed-on: https://go-review.googlesource.com/32455
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-02 19:14:39 +00:00
Russ Cox
5ad3bd99b5 api: sort except.txt
Make it easier to find lines and update the file.

Change-Id: I9db78ffd7316fbc17c5488e178e23777756d8f47
Reviewed-on: https://go-review.googlesource.com/32454
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-02 19:09:39 +00:00
Russ Cox
d5b97f614e cmd/pprof: move cmd/internal/pprof back to cmd/pprof/internal
CL 21870 moved the entire cmd/pprof/internal directory to cmd/internal/pprof
for use by cmd/trace, but really cmd/trace only needed cmd/pprof/internal/profile,
which became cmd/internal/pprof/profile, and then internal/pprof/profile.

Move the rest back under cmd/pprof so that it is clear that no other code
is reaching into the guts of cmd/pprof. Just like functions should not be
exported unless necessary, internals should not be made visible to more
code than necessary.

Raúl Silvera noted after the commit of CL 21870 that only the profile package
should have moved, but there was no followup fix (until now).

Change-Id: I603f4dcb0616df1e5d5eb7372e6fccda57e05079
Reviewed-on: https://go-review.googlesource.com/32453
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-02 19:09:21 +00:00
Russ Cox
682ffae6db internal/pprof/profile: new package, moved from cmd/internal/pprof/profile
This allows both the runtime and the cmd/pprof code to use the package,
just like we do for internal/trace.

Change-Id: I7606977284e1def36c9647354c58e7c1e93dba6b
Reviewed-on: https://go-review.googlesource.com/32452
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-02 19:09:11 +00:00