1
0
mirror of https://github.com/golang/go synced 2024-10-05 01:31:22 -06:00
Commit Graph

19086 Commits

Author SHA1 Message Date
Russ Cox
023047d14b cmd/go: diagnose trivial test import cycle
Was detecting only non-trivial ones.

Fixes #9690.

Change-Id: I662d81dd4818ddf29592057c090805772c84287b
Reviewed-on: https://go-review.googlesource.com/12147
Reviewed-by: Rob Pike <r@golang.org>
2015-07-15 04:13:55 +00:00
Russ Cox
ea918ef535 Revert "cmd/compile: define func value symbols at declaration"
This reverts commit 3b411bf1a1bb08d6868083981cecba8088dc7aea.

Change-Id: I321a43fa378a43b3e4d7aa97e0222775640af64b
Reviewed-on: https://go-review.googlesource.com/12205
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15 04:11:54 +00:00
Russ Cox
fa1ea497d5 cmd/compile: define func value symbols at declaration
These used to be defined at use, but that breaks when shared libraries
are involved.

For #11480.

Change-Id: I416a848754fb615c0d75f9f0ccc00723d07f7f01
Reviewed-on: https://go-review.googlesource.com/12145
Reviewed-by: Rob Pike <r@golang.org>
2015-07-15 04:11:01 +00:00
Russ Cox
0a3c991fd3 cmd/internal/obj: fix pc/sp information for prologue
When the prologue call to morestack was moved down to the
bottom of the function, the pc/sp tables were not updated.
If a traceback through a call to morestack is needed, it would
get confused at and stop at morestack.

Confirmed the fix by adding //go:systemstack (which calls
morestackc, but same issue) where it did not belong
and inspecting the crash.

Change-Id: Id0294bb9dba51ef1a49154637228fb57f1086a94
Reviewed-on: https://go-review.googlesource.com/12144
Reviewed-by: Rob Pike <r@golang.org>
2015-07-15 04:09:35 +00:00
Jeff R. Allen
0c72eeb121 net/http: do not allow space or slash in Host headers
A malformed Host header can result in a malformed HTTP request.
Clean them to avoid this.

Updates #11206. We may come back and make this stricter for 1.6.

Change-Id: I23c7d821cd9dbf66c3c15d26750f305e3672d984
Reviewed-on: https://go-review.googlesource.com/11241
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15 03:15:59 +00:00
David du Colombier
e6a0c21e7d net: fix setKeepAlivePeriod on Plan 9
The interface to set TCP keepalive on Plan 9 is
writing the "keepalive n" string to the TCP ctl file,
where n is the milliseconds between keepalives.

Fixes #11266.

Change-Id: Ic96f6c584063665a1ddf921a9a4ddfa13cc7501b
Reviewed-on: https://go-review.googlesource.com/11860
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15 02:53:34 +00:00
Robert Griesemer
e7a10a9614 go/types: fix internal inInteger operand predicate
When testing if a value is an integer, if the value is a constant,
don't ignore the type if it has one.

Fixes #11594.

Change-Id: I2ff387e4f9e8ab7cae35c4838350e0a1fce2e625
Reviewed-on: https://go-review.googlesource.com/12045
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-07-15 02:25:47 +00:00
Didier Spezia
8b6527b70e encoding/xml: improve marshaller sanity checks of directives
When building a directive, the current sanity check prevents
a '>' to be used, which makes a DOCTYPE directive with an
internal subset be rejected. It is accepted by the parser
though, so what can be parsed cannot be encoded.

Improved the corresponding sanity check to mirror the behavior
of the parser (in the way it handles angle brackets, quotes,
and comments).

Fixes #10158

Change-Id: Ieffea9f870f2694548e12897f8f47babc0ea4414
Reviewed-on: https://go-review.googlesource.com/11630
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15 01:56:14 +00:00
Larz Conwell
1a4e1770f6 encoding/json: Only allow string option for valid types
The "string" option only applies for strings, floats, integers, and
booleans as per the documentation. So when decoding ignore the "string"
option if the value is not of one of the types mentioned. This matches
the Marshal step which also ignores the "string" option for invalid
types.

Fixes #9812

Change-Id: I0fb2b43d0668bc0e2985886d989abbf2252070e2
Reviewed-on: https://go-review.googlesource.com/10183
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-15 01:35:56 +00:00
Nevins Bartolomeo
1fff4bb156 crypto: add SHA-512/224 and SHA-512/256 as described in FIPS 180-4
Change-Id: Ifbab8203dea1eb0df4c834df22e12cb7c37c14fd
Reviewed-on: https://go-review.googlesource.com/10683
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-07-14 19:45:21 +00:00
David Crawshaw
e3c67dda0a cmd/go: do not create subdirs of $GOBIN
Fixes #9769.

Change-Id: I2959906c71d0ce62cdb750dab78eab631a26f229
Reviewed-on: https://go-review.googlesource.com/12080
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-14 19:25:40 +00:00
Ian Lance Taylor
a6dc541436 cmd/go: warn on get from code.google.com that it is shutting down
Fixes #10193.

Change-Id: Ibbb747babb697a66b943e5da76b0ada41f1fb14f
Reviewed-on: https://go-review.googlesource.com/12070
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-14 18:18:12 +00:00
Nigel Tao
60b7d27c82 image/jpeg: don't unread a byte if we've already taken bits from it.
This rolls back most of golang.org/cl/8841, aka 2f98bac310, and makes a
different fix. It keeps the TestTruncatedSOSDataDoesntPanic test
introduced by that other CL, which obviously still passes after this CL.

Fixes #11650, a regression (introduced by cl/8841) from Go 1.4.

The original cl/8841 changed the image/jpeg not to panic on an input
given in #10387. We still do not panic on that input, after this CL.

I have a corpus of over 160,000 JPEG images, a sample of a web crawl.
The image/jpeg code ran happily over that whole corpus both before and
after this CL, although that corpus clearly didn't catch the regression
in the first place.

This code was otherwise tested manually. I don't think that it's trivial
to synthesize a JPEG input that happens to run out of Huffman data at
just the right place. The test image attached to #11650 obviously has
that property, but I don't think we can simply add that test image to
the repository: it's 227KiB, and I don't know its copyright status.

I also looked back over the issue tracker for problematic JPEGs that
people have filed. The Go code, after this CL, is still happy on these
files in my directory:
issue2362a.jpeg
issue3916.jpeg
issue3976.jpeg
issue4084.jpeg
issue4259.jpeg
issue4291.jpeg
issue4337.jpeg
issue4500.jpeg
issue4705.jpeg
issue4975.jpeg
issue5112.jpeg
issue6767.jpeg
issue9888.jpeg
issue10133.jpeg
issue10357.jpeg
issue10447.jpeg
issue11648.jpeg
issue11650.jpeg

There were other images attached in the issue tracker that aren't
actually valid JPEGs. They failed both before and after this CL:
broken-issue2362b.jpeg
broken-issue6450.jpeg
broken-issue8693.jpeg
broken-issue10154.jpeg
broken-issue10387.jpeg
broken-issue10388.jpeg
broken-issue10389.jpeg
broken-issue10413.jpeg

In summary, this CL fixes #11650 and, after some automated and manual
testing, I don't think introduces new regressions.

Change-Id: I30b67036e9b087f3051d57dac7ea05fb4fa36f66
Reviewed-on: https://go-review.googlesource.com/12163
Reviewed-by: Rob Pike <r@golang.org>
2015-07-14 06:21:57 +00:00
Brad Fitzpatrick
a74d030557 os/exec: fix plan9 build
Fixes build from https://golang.org/cl/12152

Plan 9 lacks syscall.EPIPE. I was misled by api/go1.txt and also
forgot to use the trybots. :(

Change-Id: I4982fe969ad4a8724090cb03009bfb21780d8aa7
Reviewed-on: https://go-review.googlesource.com/12153
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-14 05:33:14 +00:00
Ross Light
c218a075be cmd/go: mark ssh:// URLs as secure
Add tests for isSecure function.

Change-Id: I49de9d2846b75d4c7be745484f85d351a6fd851d
Reviewed-on: https://go-review.googlesource.com/11514
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-14 05:27:57 +00:00
Russ Cox
3290e9c145 runtime: fix build on non-x86 machines
Fixes #11656 (again).

Change-Id: I170ff10bfbdb0f34e57c11de42b6ee5291837813
Reviewed-on: https://go-review.googlesource.com/12142
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-14 04:42:12 +00:00
Brad Fitzpatrick
73ca459a56 os/exec: ignore pipe write errors when command completes successfully
Fixes #9173

Change-Id: I83530533db84b07cb88dbf6ec690be48a06a9d7d
Reviewed-on: https://go-review.googlesource.com/12152
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-14 00:41:31 +00:00
Rob Pike
1bd1880906 cmd/internal/obj: rename *.out.go to a.out.go
The old numerical names like 6.out.go are a relic from the old tools.
Easier to rename than explain.

The anames.go files were modified by go generate; no changes
beyond the explanatory comment at the top.

Change-Id: I84742c75c60e47724baa9d49a91fef1f8581f021
Reviewed-on: https://go-review.googlesource.com/12069
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-13 23:47:38 +00:00
Austin Clements
777ab5ce1a runtime: fix MemStats.{PauseNS,PauseEnd,PauseTotalNS,LastGC}
These memstats are currently being computed by gcMark, which was
appropriate in Go 1.4, but gcMark is now just one part of a bigger
picture. In particular, it can't account for the sweep termination
pause time, it can't account for all of the mark termination pause
time, and the reported "pause end" and "last GC" times will be
slightly earlier than they really are.

Lift computing of these statistics into func gc, which has the
appropriate visibility into the process to compute them correctly.

Fixes one of the issues in #10323. This does not add new statistics
appropriate to the concurrent collector; it simply fixes existing
statistics that are being misreported.

Change-Id: I670cb16594a8641f6b27acf4472db15b6e8e086e
Reviewed-on: https://go-review.googlesource.com/11794
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-13 23:32:59 +00:00
Austin Clements
ad60cd8b92 runtime: report MemStats.PauseEnd in UNIX time
Currently we report MemStats.PauseEnd in nanoseconds, but with no
particular 0 time. On Linux, the 0 time is when the host started. On
Darwin, it's the UNIX epoch. This is also inconsistent with the other
absolute time in MemStats, LastGC, which is always reported in
nanoseconds since 1970.

Fix PauseEnd so it's always reported in nanoseconds since 1970, like
LastGC.

Fixes one of the issues raised in #10323.

Change-Id: Ie2fe3169d45113992363a03b764f4e6c47e5c6a8
Reviewed-on: https://go-review.googlesource.com/11801
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-13 23:32:02 +00:00
Russ Cox
0bcdffeea6 runtime: fix x86 stack trace for call to heap memory
Fixes #11656.

Change-Id: Ib81d583e4b004e67dc9d2f898fd798112434e7a9
Reviewed-on: https://go-review.googlesource.com/12026
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-07-13 19:42:35 +00:00
Russ Cox
683311175c runtime: fix race in TestChanSendBarrier
Fixes race detector build.

Change-Id: I8bdc78d57487580e6b5b8c415df4653a1ba69e37
Reviewed-on: https://go-review.googlesource.com/12087
Reviewed-by: Austin Clements <austin@google.com>
2015-07-13 19:42:20 +00:00
Mikio Hara
7ef6a9f38b net: clean up builtin DNS stub resolver, fix tests
This change does clean up as preparation for fixing #11081.

- renames cfg to resolvConf for clarification
- adds a new type resolverConfig and its methods: init, update,
  tryAcquireSema, releaseSema for mutual exclusion of resolv.conf data
- deflakes, simplifies tests for resolv.conf data; previously the tests
  sometimes left some garbage in the data

Change-Id: I277ced853fddc3791dde40ab54dbd5c78114b78c
Reviewed-on: https://go-review.googlesource.com/10931
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-13 19:29:25 +00:00
Russ Cox
d7a8d3eb08 cmd/go: fix go get -u with internal
Fixes #11307.
Fixes #11055.

Change-Id: I8d6b04cb509e62e27d6935b91ffe35fdaea4ebcd
Reviewed-on: https://go-review.googlesource.com/12028
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-07-13 19:17:17 +00:00
Russ Cox
8c3533c89b runtime: add memory barrier for sync send in select
Missed select case when adding the barrier last time.
All the more reason to refactor this code in Go 1.6.

Fixes #11643.

Change-Id: Ib0d19d6e0939296c0a3e06dda5e9b76f813bbc7e
Reviewed-on: https://go-review.googlesource.com/12086
Reviewed-by: Austin Clements <austin@google.com>
2015-07-13 19:10:22 +00:00
Alan Donovan
242ec168c1 go/internal/gcimporter: populate (*types.Package).Imports
This is a copy of an upstream change to the tools repo:
https://go-review.googlesource.com/#/c/8924/

This is a second attempt at CL 8954, with the necessary change to
go/build's deps test.

Change-Id: Ib798498cf85fea0baec5667e9324d11f6ae8ad64
Reviewed-on: https://go-review.googlesource.com/9173
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-13 17:51:09 +00:00
Nigel Tao
ca6ba49269 image/png: don't read filter bytes for empty interlace passes.
Fixes #11604

The gray-gradient.png image was created by a Go program:

----
package main

import (
	"image"
	"image/color"
	"image/png"
	"log"
	"os"
)

func main() {
	f, err := os.Create("a.png")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()
	m := image.NewGray(image.Rect(0, 0, 1, 16))
	for i := 0; i < 16; i++ {
		m.SetGray(0, i, color.Gray{uint8(i * 0x11)})
	}
	err = png.Encode(f, m)
	if err != nil {
		log.Fatal(err)
	}
}
----

The equivalent gray-gradient.interlaced.png image was created via ImageMagick:
$ convert -interlace PNG gray-gradient.png gray-gradient.interlaced.png

As a sanity check:
$ file gray-gradient.*
gray-gradient.interlaced.png: PNG image data, 1 x 16, 4-bit grayscale, interlaced
gray-gradient.png:            PNG image data, 1 x 16, 8-bit grayscale, non-interlaced

Change-Id: I7700284f74d1ea30073aede3bce4d7651787bdbc
Reviewed-on: https://go-review.googlesource.com/12064
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-13 06:40:00 +00:00
Michael Hudson-Doyle
616cb3c0ea cmd/dist: actually disable testso and testsovar on ppc64
This is clearly what was intended all along. ./all.bash passes with this
change.

Change-Id: I16996da11cf1e4d2dc2a4434b7611a724691e8dc
Reviewed-on: https://go-review.googlesource.com/12068
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-13 04:11:39 +00:00
Rob Pike
a3985e400f time: document that time.Tick creates an unrecoverable resource
Fixes #11662.

Change-Id: I8839b48a1cd3da4c29b6def03cb0c74c1c12942e
Reviewed-on: https://go-review.googlesource.com/12066
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-13 01:35:36 +00:00
Alex Brainman
4ef836faf6 cmd/dist: disable misc/scgo/testsovar on netbsd
Update #11654

Change-Id: Ia199b8dd349542ad8b92b463dd2f3734dd7e66a4
Reviewed-on: https://go-review.googlesource.com/12060
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-12 10:23:06 +00:00
Brad Fitzpatrick
783297ad6a all: link to https for golang subdomains too
The previous commit (git 2ae77376) just did golang.org.  This one
includes golang.org subdomains like blog, play, and build.

Change-Id: I4469f7b307ae2a12ea89323422044e604c5133ae
Reviewed-on: https://go-review.googlesource.com/12071
Reviewed-by: Rob Pike <r@golang.org>
2015-07-12 04:42:40 +00:00
Hariharan Srinath
4735002f58 flag: Clarifies docs for Arg(int) and FlagSet.Arg(int)
Adds the clarification that these functions return empty
string if the requested element is not available

Added fullstops

Fixes #11664

Change-Id: I84173862bc785240f7d3ee75a5023673264d172b
Reviewed-on: https://go-review.googlesource.com/12061
Reviewed-by: Rob Pike <r@golang.org>
2015-07-12 03:22:26 +00:00
Brad Fitzpatrick
2ae77376f7 all: link to https instead of http
The one in misc/makerelease/makerelease.go is particularly bad and
probably warrants rotating our keys.

I didn't update old weekly notes, and reverted some changes involving
test code for now, since we're late in the Go 1.5 freeze. Otherwise,
the rest are all auto-generated changes, and all manually reviewed.

Change-Id: Ia2753576ab5d64826a167d259f48a2f50508792d
Reviewed-on: https://go-review.googlesource.com/12048
Reviewed-by: Rob Pike <r@golang.org>
2015-07-11 14:36:33 +00:00
Brad Fitzpatrick
f96fa06d14 net/http/fcgi: fix race between serveRequest and cleanUp
Fixes #11552

Change-Id: I87904e9e3fb4bd1fb4c7075a4e2d0151e5bd37df
Reviewed-on: https://go-review.googlesource.com/11890
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-07-11 14:36:16 +00:00
Elias Naur
b3a8b0574a runtime: abort on fatal errors and panics in c-shared and c-archive modes
The default behaviour for fatal errors and runtime panics is to dump
the goroutine stack traces and exit with code 2. However, when the process is
owned by foreign code, it is suprising and inappropriate to suddenly exit
the whole process, even on fatal errors. Instead, re-use the crash behaviour
from GOTRACEBACK=crash and abort.

The motivating use case is issue #11382, where an Android crash reporter
is confused by an exiting process, but I believe the aborting behaviour
is appropriate for all cases where Go does not own the process.

The change is simple and contained and will enable reliable crash reporting
for Android apps in Go 1.5, but I'll leave it to others to judge whether it
is too late for Go 1.5.

Fixes #11382

Change-Id: I477328e1092f483591c99da1fbb8bc4411911785
Reviewed-on: https://go-review.googlesource.com/12032
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-11 11:39:05 +00:00
Alex Brainman
d5004ee69e runtime: use AddVectoredContinueHandler on Windows XP amd64
Recent change (CL 10370) unexpectedly broke TestRaiseException on
Windows XP amd64. I still do not know why. But reverting old
CL 8165 fixes the problem.

This effectively makes Windows XP amd64 use AddVectoredContinueHandler
instead of SetUnhandledExceptionFilter for exception handling. That is
what we do for all recent Windows versions too.

Fixes #11481

Change-Id: If2e8037711f05bf97e3c69f5a8d86af67c58f6fc
Reviewed-on: https://go-review.googlesource.com/11888
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-11 07:02:57 +00:00
Charlie Dorian
8b221092b9 math: Expm1 returns -1 with large negative argument.
Fixes #11442

Change-Id: I2053fe752c6a122924d28565f1338f73e00ed417
Reviewed-on: https://go-review.googlesource.com/11791
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-10 22:22:24 +00:00
Matthew Dempsky
1082e2390e cmd/link/internal/ld: stricter object file decoding
Instead of silently truncating integers to their expected range, check
that they're within range and emit errors if not.  Intended to help
narrow down the cause of issue #11617.

Change-Id: Ia7b577270f8438ca7479262702371e26277f1ea7
Reviewed-on: https://go-review.googlesource.com/12050
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-10 22:01:54 +00:00
Ian Lance Taylor
6a90b1d621 runtime, cmd/go: fix tests to work when GOROOT_FINAL is set
When GOROOT_FINAL is set when running all.bash, the tests are run
before the files are copied to GOROOT_FINAL.  The tests are run with
GOROOT set, so most work fine.  This fixes two cases that do not.

In cmd/go/go_test.go we were explicitly removing GOROOT from the
environment, causing tests that did not themselves explicitly set
GOROOT to fail.  There was no need to explicitly remove GOROOT, so
don't do it.  If people choose to run "go test cmd/go" with a bad
GOROOT, that is their own lookout.

In the runtime GDB test, the linker has told gdb to find the support
script in GOROOT_FINAL, which will fail.  Check for that case, and
skip the test when we see it.

Fixes #11652.

Change-Id: I4d3a32311e3973c30fd8a79551aaeab6789d0451
Reviewed-on: https://go-review.googlesource.com/12021
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-10 21:29:37 +00:00
Ian Lance Taylor
2de67e9974 runtime: clarify that NumCPU returns only available CPUs
Update #11609.

Change-Id: Ie363facf13f5e62f1af4a8bdc42a18fb36e16ebf
Reviewed-on: https://go-review.googlesource.com/12022
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-10 21:28:49 +00:00
Mikio Hara
91ba0abef1 net: fix misidentification of link-local, global unicast IP addresses
Don't treat IPv4-mapped link-local IP addresses as IPv6 link-local
addresses, an IPv4 broadcast address as a global unicast IP address.

Fixes #11585.

Change-Id: I6a7a0c0601f18638f5c624ab63e12ee40f77b182
Reviewed-on: https://go-review.googlesource.com/11883
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-10 07:30:33 +00:00
Mikio Hara
7b5d536786 net: ensure that ResolveIPAddr(addr.String()) reproduces addr
Updates #6465.

Change-Id: I5babbcf4c92dae47c823a41628b01e4ceb2332eb
Reviewed-on: https://go-review.googlesource.com/11951
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-10 06:51:55 +00:00
Rob Pike
a625b91916 cmd/doc: submit to the punched card tyranny
People use 80-column terminals because their grandparents used
punched cards. When I last used a punched card, in 1978, it seemed
antiquated even then. But today, people still set their terminal
widths to 80 to honor the struggles their fallen ancestors made to
endure this painful technology.

We must all stand and salute the 80 column flag, or risk the opprobium
of our peers.

For Pete's sake, I don't even use a fixed-width font. I don't even
believe in columns.

Fixes #11639 with extreme reluctance.

P.S. To avoid the horror of an automatically folded line of text, this commit message has been formatted to fit on an 80-column line, except for this postscript.

Change-Id: Ia2eb2dcf293dabe804c22ee5abb4bbb703f45c33
Reviewed-on: https://go-review.googlesource.com/12011
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-10 03:52:48 +00:00
Alex Brainman
315e5c99d8 debug/pe: truncate pe sections to their size in memory
Section.Data returns disk section data, but those are rounded up to
some predefined value. Processing these as is confuses dwarf parser
because of garbage at the end. Truncate Section.Data as per memory
section description.

Sometimes dwarf sections have memory section size of 0
(for pe object files). Keep those to their disk size.

Fixes #11608

Change-Id: I8de0a2271201a24aa9ac8dac44f1e9c8a9285183
Reviewed-on: https://go-review.googlesource.com/11950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-10 03:33:38 +00:00
Brad Fitzpatrick
b615ad8fd5 net: add mechanisms to force go or cgo lookup, and to debug default strategy
GODEBUG=netdns=1 prints a one-time strategy decision. (cgo or go DNS lookups)
GODEBUG=netdns=2 prints the per-lookup strategy as a function of the hostname.

The new "netcgo" build tag forces cgo DNS lookups.

GODEBUG=netdns=go (or existing build tag "netgo") forces Go DNS resolution.
GODEBUG=netdns=cgo (or new build tag "netcgo") forces libc DNS resolution.

Options can be combined with e.g. GODEBUG=netdns=go+1 or GODEBUG=netdns=2+cgo.

Fixes #11322
Fixes #11450

Change-Id: I7a67e9f759fd0a02320e7803f9ded1638b19e861
Reviewed-on: https://go-review.googlesource.com/11584
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-09 22:19:41 +00:00
Austin Clements
4b2774f5ea runtime: make sysmon-triggered GC concurrent
sysmon triggers a GC if there has been no GC for two minutes.
Currently, this is a STW GC. There is no reason for this to be STW, so
make it concurrent.

Fixes #10261.

Change-Id: I92f3ac37272d5c2a31480ff1fa897ebad08775a9
Reviewed-on: https://go-review.googlesource.com/11955
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-09 05:53:21 +00:00
Rob Pike
91976aa676 cmd/doc: suppress symbols for commands when showing package docs
Change the default behavior when showing the package docs
for a command to elide the symbols. This makes

	go doc somecommand

show the top-level package docs only and hide the symbols,
which are probably irrelevant to the user. This has no effect
on explicit requests for internals, such as

	go doc somecommand.sometype

The new -cmd flag restores the old behavior.

Fixes #10733.

Change-Id: I4d363081fe7dabf76ec8e5315770ac3609592f80
Reviewed-on: https://go-review.googlesource.com/11953
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-09 04:09:00 +00:00
Rob Pike
1b74c71da5 cmd/asm: add copyright notices to tests
They were missing from the inputs.
Unfortunately this means the .out files all have wrong line numbers,
but they are easy to update.

Change-Id: I254742f24ab803421f34d52d13b9afa93674edd6
Reviewed-on: https://go-review.googlesource.com/11958
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-09 03:27:48 +00:00
Russ Cox
b6ead9f171 cmd/go: disable vendoredImportPath for code outside $GOPATH
It was crashing.
This fixes the build for
GO15VENDOREXPERIMENT=1 go test -short runtime

Fixes #11416.

Change-Id: I74a9114cdd8ebafcc9d2a6f40bf500db19c6e825
Reviewed-on: https://go-review.googlesource.com/11964
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-07 21:53:11 +00:00
Russ Cox
9f90f31c3a cmd/compile: allow static init for unsafe.Pointer(&x) where x is global
This avoids both a write barrier and then dynamic initialization
globals of the form

	var x something
	var xp = unsafe.Pointer(&x)

Using static initialization avoids emitting a relocation for &x,
which helps cgo.

Fixes #9411.

Change-Id: I0dbf480859cce6ab57ab805d1b8609c45b48f156
Reviewed-on: https://go-review.googlesource.com/11693
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-07-07 21:51:57 +00:00
Brad Fitzpatrick
d6e6baa702 net/http: fix MaxBytesReader at EOF
Fixes #10884

Change-Id: I7cab3c96548867612f579d2cd4ec736309787443
Reviewed-on: https://go-review.googlesource.com/11961
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-07 21:33:14 +00:00
Brad Fitzpatrick
143822585e net/http: revert overly-strict part of earlier smuggling defense
The recent https://golang.org/cl/11810 is reportedly a bit too
aggressive.

Apparently some HTTP requests in the wild do contain both a
Transfer-Encoding along with a bogus Content-Length. Instead of
returning a 400 Bad Request error, we should just ignore the
Content-Length like we did before.

Change-Id: I0001be90d09f8293a34f04691f608342875ff5c4
Reviewed-on: https://go-review.googlesource.com/11962
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-07 21:33:06 +00:00
David Chase
7929a0ddfa cmd/compile: initialize line number properly for temporaries
The expansion of structure, array, slice, and map literals
does not use the right line number in its introduced assignments
to temporaries, which leads to incorrect line number attribution
for expressions in those literals.

Inlining also incorrectly replaced the line numbers of args to
inlined functions.

This was revealed in CL 9721 because a now-avoided temporary
assignment introduced the correct line number.
I.e. before CL 9721
  "tmp_wrongline := expr"
was transformed to
  "tmp_rightline := expr; tmp_wrongline := tmp_rightline"

Also includes a repair to CL 10334 involving line numbers
where a spurious -1 remained (should have been 0, now is 0).

Fixes #11400.

Change-Id: I3a4687efe463977fa1e2c996606f4d91aaf22722
Reviewed-on: https://go-review.googlesource.com/11730
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-07 21:30:59 +00:00
Russ Cox
2028077899 runtime: randomize scheduling in -race mode
Basic randomization of goroutine scheduling for -race mode.
It is probably possible to do much better (there's a paper linked
in the issue that I haven't read, for example), but this suffices
to introduce at least some unpredictability into the scheduling order.
The goal here is to have _something_ for Go 1.5, so that we don't
start hitting more of these scheduling order-dependent bugs
if we change the scheduler order again in Go 1.6.

For #11372.

Change-Id: Idf1154123fbd5b7a1ee4d339e93f97635cc2bacb
Reviewed-on: https://go-review.googlesource.com/11795
Reviewed-by: Austin Clements <austin@google.com>
2015-07-07 21:27:38 +00:00
Daniel Theophanes
0409158cd0 cmd/go: ignore volume name case when checking vendor path
Fixes #11409

Change-Id: Ic1610e124b2d8b2b12310fc9538d5078cc7302a0
Reviewed-on: https://go-review.googlesource.com/11316
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-07 21:02:17 +00:00
Ross Light
11a19ae8da cmd/go: create executable when installing to working directory
Fixes #11065.

Change-Id: Idd854facd5fa78c0334f86740f351d404f9a5b2d
Reviewed-on: https://go-review.googlesource.com/11511
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-07 21:00:44 +00:00
Daniel Theophanes
06b280214c cmd/go: do not panic on invalid import path containing "/vendor/"
Fixes #11414

Change-Id: I45a41b98554f00362d9222e9c68a441dbfc23cb8
Reviewed-on: https://go-review.googlesource.com/11700
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-07 21:00:01 +00:00
Brad Fitzpatrick
72970f7f52 net/http/httputil: make ReverseProxy support Trailers
Go's continuous build system depends on HTTP trailers for the buildlet
interface.

Andrew rewrote the makerelease tool to work in terms of Go's builder
system (now at x/build/cmd/release), but it previously could only
create GCE-based buildlets, which meant x/build/cmd/release couldn't
build the release for Darwin.

https://golang.org/cl/11901 added support for proxying buildlet
connections via the coordinator, but that exposed the fact that
httputil.ReverseProxy couldn't proxy Trailers. A fork of that code
also wasn't possible because net/http needlessly deleted the "Trailer"
response header in the Transport code.  This mistake goes back to
"release-branch.r56" and earlier but was never noticed because nobody
ever uses Trailers, and servers via ResponseWriter never had the
ability to even set trailers before this Go 1.5. Note that setting
trailers requires pre-declaring (in the response header) which
trailers you'll set later (after the response body). Because you could
never set them, before this release you could also never proxy them.

Change-Id: I2410a099921790dcd391675ae8610300efa19108
Reviewed-on: https://go-review.googlesource.com/11940
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-07 14:30:49 +00:00
Rob Pike
173fa1d809 cmd/go: delete references to old tools (5a etc.) from cmd/go docs
Don't talk about commands that no longer exist.

There are still references throughout the tree, mostly in comments,
but they provide a charming historical backdrop for the idle tourist.

Change-Id: I637ebdce05bbc7df5addcc46cb772d2bb9f3e073
Reviewed-on: https://go-review.googlesource.com/11885
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-05 06:25:51 +00:00
Josh Bleecher Snyder
71832ff489 math/rand: improve NewZipf documentation
Change-Id: I78f0f9ac33db153c4a0d7f9866da20ebcd3d3639
Reviewed-on: https://go-review.googlesource.com/11872
Reviewed-by: Rob Pike <r@golang.org>
2015-07-03 21:39:04 +00:00
Nigel Tao
40a1516a09 image/draw: fix double-draw when the dst is paletted.
The second (fallback) draw is a no-op, but it's a non-trivial amount of work.

Fixes #11550.

benchmark               old ns/op     new ns/op     delta
BenchmarkPaletted-4     16301219      7309568       -55.16%

Change-Id: Ic88c537b2b0c710cf517888f3dd15cb702dd142f
Reviewed-on: https://go-review.googlesource.com/11858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-03 03:08:40 +00:00
Dmitry Vyukov
11f50f41ee cmd/trace: log errors to console in AJAX handler
Fixes #11508

Change-Id: I72e83893b76f75685d6edfe65ca6691d97539226
Reviewed-on: https://go-review.googlesource.com/11864
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-02 19:10:00 +00:00
Mikio Hara
2a0fc9e70e Revert "net, internal/syscall/unix: add SocketConn, SocketPacketConn"
This reverts commit 6f7961da28.

Russ suggests changing the frozon syscall package and obviously it's a
better solution. Perhaps he will also let me know the way how to get the
project owners to agree later.

Fixes #11492.

Change-Id: I98f9f366b72b85db54b4acfc3a604b62fb6d783c
Reviewed-on: https://go-review.googlesource.com/11854
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-02 16:11:03 +00:00
Brad Fitzpatrick
85938714e9 mime/multipart: fix bug when body contains prefix of the boundary
Fixes #10616

Change-Id: I4ef25eb0be6ccf474976fdb5087dd2c62c66c510
Reviewed-on: https://go-review.googlesource.com/11811
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-02 16:04:34 +00:00
Dmitry Vyukov
1b96091a05 internal/trace: add comment for stable sort
As per comments in cl/11834.

Change-Id: I285536b882fa9496e15d77d0d4c16ee913aca581
Reviewed-on: https://go-review.googlesource.com/11861
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-02 16:04:07 +00:00
Rob Pike
d16c7f8004 crypto: fix non-sentence in documentation for Decrypter
Comment change only.

Change-Id: I2e32c2b34d5a5659ead6d6082b06e1b039bf1147
Reviewed-on: https://go-review.googlesource.com/11852
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-02 03:43:34 +00:00
Dmitry Vyukov
64e48bbaba internal/trace: stable sort events
On some VMs two events can happen at the same time. For examples:
179827399 GoStart p=2 g=11 off=936359 g=11
179827399 GoUnblock p=2 g=0 off=936355 g=11
If we do non-stable sort, the events can be reordered making the trace inconsistent.
Do stable sort instead.

Batches are dumped in FIFO order, so if these same-time events are split into
separate batches, stable sort still works.

Events on different CPUs go into different batches and can be reordered.
But the intention is that causally-related events on different CPUs
will have larger (non-zero) time diff.

Update #11320

Change-Id: Id1df96af41dff68ea1782ab4b23d5afd63b890c9
Reviewed-on: https://go-review.googlesource.com/11834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-02 00:37:16 +00:00
Roger Peppe
5ae822ba69 encoding/xml: minor changes
Changes suggested by Nigel Tao in https://go-review.googlesource.com/#/c/11635
after that had been submitted.

Change-Id: I7b28e1c8488c8565399a8017453dc7ff1fd215e8
Reviewed-on: https://go-review.googlesource.com/11832
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-07-01 14:13:16 +00:00
Dmitry Vyukov
1cbbd7f545 cmd/trace: fix time scale
Integrate the latest trace-viewer changes.
It now handles nanoseconds without any issues (thanks to @egonelbre!).
So change timestamps from microseconds to nanoseconds.

Change-Id: I010f27effde7e80c9992e6f276f6912354d27df4
Reviewed-on: https://go-review.googlesource.com/11244
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Egon Elbre <egonelbre@gmail.com>
2015-07-01 10:37:10 +00:00
Brad Fitzpatrick
fc2eee87ed database/sql: make Register safe for concurrent use
Adding a mutex was easier than documenting it, and is consistent with
gob.

Fixes #9847

Change-Id: Ifa94c17e7c11643add81b35431ef840b794d78b1
Reviewed-on: https://go-review.googlesource.com/11682
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-30 23:15:03 +00:00
Brad Fitzpatrick
300d9a2158 net/http: harden Server against request smuggling
See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: Ic1779bc2180900430d4d7a4938cac04ed73c304c
Reviewed-on: https://go-review.googlesource.com/11810
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30 22:56:30 +00:00
Brad Fitzpatrick
2714005a24 internal/singleflight: deflake test
Fixes #11475

Change-Id: Ibaedbb732bb1b9f062bd5af7b866ec4758c724a7
Reviewed-on: https://go-review.googlesource.com/11770
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30 22:55:59 +00:00
Alan Donovan
f11109fbc9 go/types: change {Type,Object,Selection}String to accept a Qualifier function
The optional Qualifier function determines what prefix to attach to
package-level names, enabling clients to qualify packages in different
ways, for example, using only the package name instead of its complete
path, or using the locally appropriate name for package given a set of
(possibly renaming) imports.

Prior to this change, clients wanting this behavior had to copy
hundreds of lines of complex printing logic.

Fun fact: (*types.Package).Path and (*types.Package).Name are valid
Qualifier functions.

We provide the RelativeTo helper function to create Qualifiers so that
the old behavior remains a one-liner.

Fixes golang/go#11133

This CL is a copy of https://go-review.googlesource.com/#/c/11692/
to the golang.org/x/tools repository.

Change-Id: I26d0f3644d077a26bfe350989f9c545f018eefbf
Reviewed-on: https://go-review.googlesource.com/11790
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2015-06-30 21:44:42 +00:00
Russ Cox
6f80e5edf4 cmd/link: reject data size > 2 GB
We can't address more than this on amd64 anyway.

Fixes #9862.

Change-Id: Ifb1abae558e2e1ee2dc953a76995f3f08c60b1df
Reviewed-on: https://go-review.googlesource.com/11715
Reviewed-by: Austin Clements <austin@google.com>
2015-06-30 19:40:39 +00:00
Russ Cox
e8f2eb4349 cmd/compile: allow linker to drop string headers when not needed
Compiling a simple file containing a slice of 100,000 strings,
the size of the resulting binary dropped from 5,896,224 bytes
to 3,495,968 bytes, which is the expected 2,400,000 bytes,
give or take.

Fixes #7384.

Change-Id: I3e551b5a1395b523a41b33518d81a1bf28da0906
Reviewed-on: https://go-review.googlesource.com/11698
Reviewed-by: Austin Clements <austin@google.com>
2015-06-30 19:27:52 +00:00
Russ Cox
3b6e86f48a cmd/compile: fix race detector handling of OBLOCK nodes
Fixes #7561 correctly.
Fixes #9137.

Change-Id: I7f27e199d7101b785a7645f789e8fe41a405a86f
Reviewed-on: https://go-review.googlesource.com/11713
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-30 19:25:18 +00:00
Brad Fitzpatrick
117ddcb83d net/textproto: don't treat spaces as hyphens in header keys
This was originally done in https://codereview.appspot.com/5690059
(Feb 2012) to deal with bad response headers coming back from webcams,
but it presents a potential security problem with HTTP request
smuggling for request headers containing "Content Length" instead of
"Content-Length".

Part of overall HTTP hardening for request smuggling. See RFC 7230.

Thanks to Régis Leroy for the report.

Change-Id: I92b17fb637c9171c5774ea1437979ae2c17ca88a
Reviewed-on: https://go-review.googlesource.com/11772
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-30 17:59:02 +00:00
Dmitry Vyukov
8884fa7476 cmd/trace: sort procs
If you have more than 10 procs, then currently they are sorted alphabetically as
0, 10, 11, ..., 19, 2, 20, ...
Assign explicit order to procs so that they are sorted numerically.

Change-Id: I6d978d2cd439aa2fcbcf147842a643f9073eef75
Reviewed-on: https://go-review.googlesource.com/11750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-30 16:50:57 +00:00
Brad Fitzpatrick
9462bcedc6 net/http: harden, document func SetCookie and type Cookie
Fixes #9758

Change-Id: I3089ec06cddd74b547d8b10834d7478a04b02069
Reviewed-on: https://go-review.googlesource.com/11701
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-30 16:19:02 +00:00
Russ Cox
8e6dc76e1f net/url: only record RawPath when it is needed
RawPath is a hint to the desired encoding of Path.
It is ignored when it is not a valid encoding of Path,
such as when Path has been changed but RawPath has not.
It is not ignored but also not useful when it matches
the url package's natural choice of encoding.
In this latter case, set it to the empty string.
This should help drive home the point that clients
cannot in general depend on it being present and
that they should use the EncodedPath method instead.

This also reduces the impact of the change on tests,
especially tests that use reflect.DeepEqual on parsed URLs.

Change-Id: I437c51a33b85439a31c307caf1436118508ea196
Reviewed-on: https://go-review.googlesource.com/11760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30 15:54:27 +00:00
Dmitry Vyukov
19b8aa3b5d cmd/compile/internal/gc: give OASWB name
Change-Id: Iacb84421215ca80c7add2818118b2af1a650fd58
Reviewed-on: https://go-review.googlesource.com/11639
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30 15:51:59 +00:00
Roger Peppe
bb7e665687 encoding/xml: fix xmlns= behavior
When an xmlns="..." attribute was explicitly generated,
it was being ignored because the name space on the
attribute was assumed to have been explicitly set (to the empty
name space) and it's not possible to have an element in the
empty name space when there is a non-empty name space set.

We fix this by recording when a default name space has been
explicitly set and setting the name space of the element to that
so printer.defineNS can do its work correctly.

We do not attempt to add our own xmlns="..." attribute
when one is explicitly set.

We also add tests for EncodeElement, as that's the only way
to attain coverage of some of the changed behaviour.
Some other test coverage is also increased, although
more work remains to be done in this area.

This change was jointly developed with Martin Hilton (mhilton on github).

Fixes #11431.

Change-Id: I7b85e06eea5b18b2c15ec16dcbd92a8e1d6a9a4e
Reviewed-on: https://go-review.googlesource.com/11635
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-30 07:42:37 +00:00
Andrew Gerrand
ab9c25f2de cmd/go: use GOOS and GOARCH from build context for "go generate"
Fixes #11438

Change-Id: Iedd31918aa5187fc3fdaed71c8dad82075559084
Reviewed-on: https://go-review.googlesource.com/11667
Reviewed-by: Rob Pike <r@golang.org>
2015-06-30 06:52:47 +00:00
Nigel Tao
b8d2d6b9c0 image/gif: accept LZW encodings that do not have an explicit end marker.
The spec says this is invalid, but it matches giflib's behavior.

Fixes #9856 (together with https://go-review.googlesource.com/11661).

Change-Id: I05701f62a9e5e724a2d85c6b87ae4111e537146b
Reviewed-on: https://go-review.googlesource.com/11663
Reviewed-by: Rob Pike <r@golang.org>
2015-06-30 03:47:51 +00:00
Nigel Tao
fea18f5a34 compress/lzw: return the partial decoding for a truncated input.
This is needed by issue #9856.

Change-Id: Idad570a7e55ad903aab55372d390bc746c4e19cf
Reviewed-on: https://go-review.googlesource.com/11661
Reviewed-by: Rob Pike <r@golang.org>
2015-06-30 03:47:06 +00:00
Alex Brainman
53eb4783c2 archive/tar: move round-trip reading into common os file
Fixes #11426

Change-Id: I77368b0e852149ed4533e139cc43887508ac7f78
Reviewed-on: https://go-review.googlesource.com/11662
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-30 02:20:20 +00:00
Aaron Jacobs
8b4278ffb7 net/http: add a Request.Cancel channel.
This allows for "race free" cancellation, in the sense discussed in
issue #11013: in contrast to Transport.CancelRequest, the cancellation
will not be lost if the user cancels before the request is put into the
transport's internal map.

Fixes #11013.

Change-Id: I0b5e7181231bdd65d900e343f764b4d1d7c422cd
Reviewed-on: https://go-review.googlesource.com/11601
Run-TryBot: David Symonds <dsymonds@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-30 01:24:15 +00:00
Russ Cox
1122836b5f cmd/compile: reject large floating point exponents without math/big
For #11326 (but not a fix).

Change-Id: Ic51814f5cd7357427c3fd990a5522775d05e7987
Reviewed-on: https://go-review.googlesource.com/11673
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-29 21:18:01 +00:00
Russ Cox
643ef15b16 io: tweak Reader comment
I think this has the same meaning as before,
but the text is tighter, and it makes some people happy.

Fixes #10182.

Change-Id: I7ee1eae4bcd6ee4a5898ea948648939e6bde5f01
Reviewed-on: https://go-review.googlesource.com/11674
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-06-29 21:17:47 +00:00
Russ Cox
4df6b1ec2f path/filepath: document and test behavior of SkipDir on files
This behavior is not what we might have designed from the start,
but it has been present since Go 1. Rather than make a visible
behavioral change that might cause programs to work differently
in Go ≤1.4 vs Go ≥1.5, document what SkipDir on a non-directory
has always meant. If code doesn't want this meaning, it is easy
enough not to return SkipDir on non-directories.

Fixes #10533.

Change-Id: Ic0612f032044bc7c69bf62583a02037e4b47530b
Reviewed-on: https://go-review.googlesource.com/11690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-06-29 21:16:35 +00:00
Russ Cox
69f0d4c6be cmd/link: detect -X setting non-string variable
Fixes #9621.

Change-Id: Ib9c6001378364af899f57fd4b89fb23af2042923
Reviewed-on: https://go-review.googlesource.com/11694
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-06-29 20:28:36 +00:00
Alan Donovan
c77809e903 go/types: go/types: add an API test of the Scope type
Also: make (*Scope).Innermost work for Package scopes.

This change is identical to http://go-review.googlesource.com/#/c/11691/,
except for minor changes required by the use of testImporter.

Change-Id: Id07e66f78987f7242c2e642dfd6ee613676e10e5
Reviewed-on: https://go-review.googlesource.com/11714
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-29 20:16:18 +00:00
Russ Cox
34846aef78 cmd/link: fix -s with external linking
This code used to only be run for ELF, with the predictable
result that using -s with external linking broke on Windows and OS X.
Moving it here should fix Windows and does fix OS X.

CL 10835 also claims to fix the crash on Windows.
I don't know whether it does so correctly, but regardless,
this CL should make that one a no-op.

Fixes #10254.

Change-Id: I2e7b45ab0c28568ddbb1b50581dcc157ae0e7ffe
Reviewed-on: https://go-review.googlesource.com/11695
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 19:49:38 +00:00
Russ Cox
27edd7209e cmd/compile: enable PAUTO capture variables on arch != 6
Fixes #9865.

Change-Id: I8ce5b1708ed938910c59899706e470271c2e7e9d
Reviewed-on: https://go-review.googlesource.com/11699
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-29 19:49:18 +00:00
Adam Langley
2814906df0 crypto/rsa: check for primes ≤ 1 in Validate
Change 7c7126cfeb removed the primality
checking in Validate to save CPU time. That check happened to be
filtering out private keys with primes that were zero or one. Without
that filtering, such primes cause a panic when trying to use such a
private key.

This change specifically checks for and rejects primes ≤ 1 in Validate.

Fixes #11233.

Change-Id: Ie6537edb8250c07a45aaf50dab43227002ee7386
Reviewed-on: https://go-review.googlesource.com/11611
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 19:32:48 +00:00
Brad Fitzpatrick
9b2d84efc8 net/http/httptest: increase test Server's key size
Fixes #10725

Change-Id: Ic8685dc238a0ffc95fafb512a8587d2eb5fe9d5f
Reviewed-on: https://go-review.googlesource.com/11720
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-29 19:30:48 +00:00
Tom Heng
162d2c1608 cmd/go: 'go env' print GO15VENDOREXPERIMENT in Go1.5
Fixes #11410

Change-Id: I9d01be3e01f74f4b12a516aba8a5d20d9b277ec6
Reviewed-on: https://go-review.googlesource.com/11539
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 19:29:01 +00:00
Brad Fitzpatrick
7749a9ab56 sync: disable flaky WaitGroup misuse test in short mode
Update #11443

Change-Id: Icb7ea291a837dcf2799a791a2ba780fd2a5e712b
Reviewed-on: https://go-review.googlesource.com/11721
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-29 18:44:52 +00:00
Russ Cox
5267bf075b cmd/go: disable TestIssue10952 without external network
Should fix arm64 build failure.

Change-Id: Ib35e4a69a1082e461a1eddf3265544a1d2ff98e5
Reviewed-on: https://go-review.googlesource.com/11710
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-06-29 18:00:07 +00:00
Russ Cox
55203c7dd5 cmd/compile: allow unnamed constants to set line number
Fixes #8836.

Change-Id: Idda9f4a987e03b3bdf5e8fdb984fe56d6f84aa59
Reviewed-on: https://go-review.googlesource.com/11672
Reviewed-by: David Chase <drchase@google.com>
2015-06-29 17:35:55 +00:00
Russ Cox
8b99bb7b8c runtime: fix broken arm builds
Change-Id: I08de33aacb3fc932722286d69b1dd70ffe787c89
Reviewed-on: https://go-review.googlesource.com/11697
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 17:33:23 +00:00
Russ Cox
434e0bc0a0 cmd/link: record missing pcdata tables correctly
The old code was recording the current table output offset,
so the table from the next function would be used instead of
the runtime realizing that there was no table at all.

Add debug constant in runtime to check this for every function
at startup. It's too expensive to do that by default, but we can
do the last five functions. The end of the table is usually where
the C symbols end up, so that's where the problems typically are.

Fixes #10747.
Fixes #11396.

Change-Id: I13592e78017969fc22979fa902e19e1b151d41b1
Reviewed-on: https://go-review.googlesource.com/11657
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-06-29 16:07:14 +00:00
Austin Clements
1b917484a8 runtime: reset mark state before checkmark and gctrace=2 mark
Currently we fail to reset the live heap accounting state before the
checkmark mark and before the gctrace=2 extra mark. As a result, if
either are enabled, at the end of GC it thinks there are 0 bytes of
live heap, which causes the GC controller to initiate a new GC
immediately, regardless of the true heap size.

Fix this by factoring this state reset into a function and calling it
before all three possible marks.

This function should be merged with gcResetGState, but doing so
requires some additional cleanup, so it will wait for after the
freeze. Filed #11427 for this cleanup.

Fixes #10492.

Change-Id: Ibe46348916fc8368fac6f086e142815c970a6f4d
Reviewed-on: https://go-review.googlesource.com/11561
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:58:29 +00:00
Austin Clements
d57056ba26 runtime: don't free stack spans during GC
Memory for stacks is manually managed by the runtime and, currently
(with one exception) we free stack spans immediately when the last
stack on a span is freed. However, the garbage collector assumes that
spans can never transition from non-free to free during scan or mark.
This disagreement makes it possible for the garbage collector to mark
uninitialized objects and is blocking us from re-enabling the bad
pointer test in the garbage collector (issue #9880).

For example, the following sequence will result in marking an
uninitialized object:

1. scanobject loads a pointer slot out of the object it's scanning.
   This happens to be one of the special pointers from the heap into a
   stack. Call the pointer p and suppose it points into X's stack.

2. X, running on another thread, grows its stack and frees its old
   stack.

3. The old stack happens to be large or was the last stack in its
   span, so X frees this span, setting it to state _MSpanFree.

4. The span gets reused as a heap span.

5. scanobject calls heapBitsForObject, which loads the span containing
   p, which is now in state _MSpanInUse, but doesn't necessarily have
   an object at p. The not-object at p gets marked, and at this point
   all sorts of things can go wrong.

We already have a partial solution to this. When shrinking a stack, we
put the old stack on a queue to be freed at the end of garbage
collection. This was done to address exactly this problem, but wasn't
a complete solution.

This commit generalizes this solution to both shrinking and growing
stacks. For stacks that fit in the stack pool, we simply don't free
the span, even if its reference count reaches zero. It's fine to reuse
the span for other stacks, and this enables that. At the end of GC, we
sweep for cached stack spans with a zero reference count and free
them. For larger stacks, we simply queue the stack span to be freed at
the end of GC. Ideally, we would reuse these large stack spans the way
we can small stack spans, but that's a more invasive change that will
have to wait until after the freeze.

Fixes #11267.

Change-Id: Ib7f2c5da4845cc0268e8dc098b08465116972a71
Reviewed-on: https://go-review.googlesource.com/11502
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:33:40 +00:00
Austin Clements
f73b2fca84 runtime: remove unused _GCsweep state
We don't use this state. _GCoff means we're sweeping in the
background. This makes it clear in the next commit that _GCoff and
only _GCoff means sweeping.

Change-Id: I416324a829ba0be3794a6cf3cf1655114cb6e47c
Reviewed-on: https://go-review.googlesource.com/11501
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:33:31 +00:00
Russ Cox
4e61c516f4 cmd/cgo: fix a problem with 'go build -compiler gccgo'
Port of https://golang.org/cl/154360045 to Git.
Original author is Xia Bin <snyh@snyh.org> (already a contributor).

Fixes #8945.

Change-Id: I28bcaf3348794202ca59fbc3466bd7b9670030e4
Reviewed-on: https://go-review.googlesource.com/11658
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-29 15:15:59 +00:00
Austin Clements
840965f8d7 runtime: always clear stack barriers on G exit
Currently the runtime fails to clear a G's stack barriers in gfput if
the G's stack allocation is _FixedStack bytes. This causes the runtime
to panic if the following sequence of events happens:

1) The runtime installs stack barriers on a G.

2) The G exits by calling runtime.Goexit. Since this does not
   necessarily return through the stack barriers installed on the G,
   there may still be untriggered stack barriers left on the G's stack
   in recorded in g.stkbar.

3) The runtime calls gfput to add the exiting G to the free pool. If
   the G's stack allocation is _FixedStack bytes, we fail to clear
   g.stkbar.

4) A new G starts and allocates the G that was just added to the free
   pool.

5) The new G begins to execute and overwrites the stack slots that had
   stack barriers in them.

6) The garbage collector enters mark termination, attempts to remove
   stack barriers from the new G, and finds that they've been
   overwritten.

Fix this by clearing the stack barriers in gfput in the case where it
reuses the stack.

Fixes #11256.

Change-Id: I377c44258900e6bcc2d4b3451845814a8eeb2bcf
Reviewed-on: https://go-review.googlesource.com/11461
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 15:02:30 +00:00
Dmitry Savintsev
fac7b86a9b encoding/binary: update protobuf documentation link
Updated the protobuf documentation URL (code.google.com deprecated)
to avoid a redirect.

Change-Id: I134f6e4a2bf2bba699942883bf6347bc61700bcb
Reviewed-on: https://go-review.googlesource.com/11634
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 14:28:01 +00:00
Rob Pike
a76c1a5c7f fmt: restore padding for %x on byte slices and strings
Also improve the documentation. A prior fix in this release
changed the properties for empty strings and slices, incorrectly.
Previous behavior is now restored and better documented.

Add lots of tests.

The behavior is that when using a string-like format (%s %q %x %X)
a byte slice is equivalent to a string, and printed as a unit. The padding
applies to the entire object. (The space and sharp flags apply
elementwise.)

Fixes #11422.
Fixes #10430.

Change-Id: I758f0521caf71630437e43990ec6d6c9a92655e3
Reviewed-on: https://go-review.googlesource.com/11600
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 07:17:23 +00:00
Brad Fitzpatrick
1bab3a16db net/http: fix now-flaky TransportAndServerSharedBodyRace test
TestTransportAndServerSharedBodyRace got flaky after
issue #9662 was fixed by https://golang.org/cl/11412, which made
servers hang up on clients when a Handler stopped reading its body
early.

This test was affected by a race between the the two goroutines in the
test both only reading part of the request, which was an unnecessary
detail for what the test was trying to test (concurrent Read/Close
races on an *http.body)

Also remove an unused remnant from an old test from which this one was
derived. And make the test not deadlock when it fails. (which was why
the test was showing up as 2m timeouts on the dashboard)

Fixes #11418

Change-Id: Ic83d18aef7e09a9cd56ac15e22ebed75713026cb
Reviewed-on: https://go-review.googlesource.com/11610
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-29 05:19:36 +00:00
Alex Brainman
0bafe0e5b2 syscall: return error instead of panicking in windows StartProcess
Fixes #11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <r@golang.org>
2015-06-29 03:54:33 +00:00
Keith Randall
214c7a2c43 cmd/link/internal/ld: exclude only real container symbols from symtab
It looks like the test for whether symbols contain subsymbols is wrong.
In particular, symbols in C libraries are mistakenly considered container
symbols.

Fix the test so only symbols which actually have a subsymbol
are excluded from the symtab.  When linking cgo programs the list
of containers is small, something like:

container _/home/khr/sandbox/symtab/misc/cgo/test(.text)<74>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue8828(.text)<75>
container _/home/khr/sandbox/symtab/misc/cgo/test/issue9026(.text)<76>
container runtime/cgo(.text)<77>

I'm not sure this is the right fix.  In particular I can't reproduce
the original problem.  Anyone have a repro they can try and see if
this fix works?

Fixes #10747
Fixes #11396

Change-Id: Id8b016389d33348b4a791fdcba0f9db8ae71ebf3
Reviewed-on: https://go-review.googlesource.com/11652
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:54:09 +00:00
Adam Langley
0a6df4a87b encoding/asn1: don't parse invalid UTF-8.
Invalid UTF-8 triggers an error when marshaling but, previously, not
when unmarshaling. This means that ASN.1 structures were not
round-tripping.

This change makes invalid UTF-8 in a string marked as UTF-8 to be an
error when Unmarshaling.

Fixes #11126.

Change-Id: Ic37be84d21dc5c03983525e244d955a8b1e1ff14
Reviewed-on: https://go-review.googlesource.com/11056
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:50:49 +00:00
Adam Langley
fdd921c9f4 encoding/asn1: be stricter by reserialising parsed times.
The time package does normalisation of times: for example day zero is
converted to the last day of the previous month and the 31st of February
is moved into March etc. This makes the ASN.1 parsing a little
worryingly lax.

This change causes the parser to reserialise parsed times to ensure that
they round-trip correctly and thus were not normalised.

Fixes #11134.

Change-Id: I3988bb95153a7b33d64ab861fbe51b1a34a359e9
Reviewed-on: https://go-review.googlesource.com/11094
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:50:41 +00:00
Alex Brainman
85d4d46f3c runtime: store syscall parameters in m not on stack
Stack can move during callback, so libcall struct cannot be stored on stack.
asmstdcall updates return values and errno in libcall struct parameter, but
these could be at different location when callback returns.
Store these in m, so they are not affected by GC.

Fixes #10406

Change-Id: Id01c9d2b4b44530494e6d9e9e1c875261ce477cd
Reviewed-on: https://go-review.googlesource.com/10370
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-29 02:45:45 +00:00
Alex Brainman
3b7841b3af cmd/go: reset read-only flag during TestIssue10952
git sets read-only flag on all its repo files on Windows.
os.Remove cannot delete these files.

Fixes windows build

Change-Id: Icaf72470456b88a1c26295caecd4e0d3dc22a1b6
Reviewed-on: https://go-review.googlesource.com/11602
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-06-29 01:49:05 +00:00
Brad Fitzpatrick
d0ed87d15c builtin: remove errant space in hyphenated adjective phrase
Change-Id: I67947e0e3189093e830120941ee49f9f32086f0e
Reviewed-on: https://go-review.googlesource.com/11615
Reviewed-by: Rob Pike <r@golang.org>
2015-06-28 21:41:38 +00:00
Todd Neal
7511806ec2 net/http: fix race on postPendingDial test hook
The race occurs rarely, but by putting some delays and more reads/writes
of prePendingDial/postPendingDial in the handlePendingDial function I
could reproduce it.

Fixes #11136

Change-Id: I8da9e66c88fbda049eaaaaffa2717264ef327768
Reviewed-on: https://go-review.googlesource.com/11250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-28 16:14:07 +00:00
Didier Spezia
ca91de7ca0 html/template: prevent panic while escaping pipelines
AFAIK, the documentation does not explicitly state whether
variables can store a callable entity or not. I believe the
current implementation in text/template assumes they cannot
though. The call builtin function is supposed to be used for
this purpose.

Template "{{0|$}}" should generate an error at runtime,
instead of a panic.

Similarly, template "{{0|(nil)}}" should not generate
a panic.

This CL aborts the sanitization process for a given pipeline
when no identifier can be derived from the selected node.
It happens with malformed pipelines.

We now have the following errors:

{{ 0 | $ }}
template: foo:1:10: executing "foo" at <$>: can't give argument to non-function $

{{ 0 | (nil) }}
template: foo:1:11: executing "foo" at <nil>: nil is not a command

Fixes #11118
Fixes #11356

Change-Id: Idae52f806849f4c9ab7aca1b4bb4b59a74723d0e
Reviewed-on: https://go-review.googlesource.com/10823
Reviewed-by: Rob Pike <r@golang.org>
2015-06-27 22:44:33 +00:00
David Crawshaw
58578de0dc cmd/link: no dwarf on darwin/arm
Partial revert of cl/10284 to get -buildmode=c-archive working for
darwin/arm.

Manually tested with iostest.bash while builder is offline.

Change-Id: I98e4e209765666e320e680e11151fce59e2afde9
Reviewed-on: https://go-review.googlesource.com/11306
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-06-27 21:32:38 +00:00
Ross Light
64078bf3cf cmd/go: ignore custom import check when there is no import comment
Fixes #10952

Change-Id: I56ab6a806bd3741cffd9d2a53929a6d043626a26
Reviewed-on: https://go-review.googlesource.com/10693
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 19:06:56 +00:00
Tamir Duberstein
a444da033c cmd/go: fetch git submodules in go get
Change createCmd, downloadCmd, tagSyncCmd, tagSyncDefault to allow
multiple commands.

When using the vendoring experiment, fetch git submodules in `go get`,
and update them in `go get -u`.

This is a reincarnation of https://codereview.appspot.com/142180043.

For #7764.

Change-Id: I8248efb851130620ef762a765ab8716af430572a
Reviewed-on: https://go-review.googlesource.com/9815
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:52:53 +00:00
Alex Brainman
ebfc5be5b9 cmd/go: adjust TestFileLineInErrorMessages
cmd/go sometimes returns relative path in the error message
(see shortPath function). Account for that during
TestFileLineInErrorMessages.

Fixes #11355

Change-Id: Ica79359eab48d669d307449fdd458764895fab2c
Reviewed-on: https://go-review.googlesource.com/11475
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:43:45 +00:00
c9s
29ff86b05b cmd/go: handle error when git remote origin doesn't exist
- Let runOutput return the error message
- When `git config ...` returns empty buffer, it means the config key is
  correct, but there is no corresponding value.
- Return the correct error when the url of remote origin is not found.
- Update error message

Fixes: #10922

Change-Id: I3f8880f6717a4f079b840d1249174378d36bca1b
Reviewed-on: https://go-review.googlesource.com/10475
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 18:43:15 +00:00
Mikio Hara
258bf65d8b net: relax IP interface address determination on linux
Linux allows to have a peer IP address on IP interface over ethernet
link encapsulation, though it only installs a static route with the peer
address as an on-link nexthop.

Fixes #11338.

Change-Id: Ie2583737e4c7cec39baabb89dd732463d3f10a61
Reviewed-on: https://go-review.googlesource.com/11352
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-27 00:39:30 +00:00
Rob Pike
aea348a3af cmd/asm: add tests for erroneous expressions
Also add a couple more errors, such as modulo with a zero divisor.

Change-Id: If24c95477f7ae86cf4aef5b3460e9ec249ea5ae2
Reviewed-on: https://go-review.googlesource.com/11535
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 23:33:39 +00:00
Brad Fitzpatrick
2b3b7dc1a9 archive/tar: also skip header roundtrip test on nacl
Update #11426

Change-Id: I7abc4ed2241a7a3af6d57c934786f36de4f97b77
Reviewed-on: https://go-review.googlesource.com/11592
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-26 22:36:38 +00:00
Brad Fitzpatrick
603dc4171a sync: don't run known-racy tests under the race detector
Fixes the build from https://golang.org/cl/4117 (sync: simplify WaitGroup)

Change-Id: Icc2a7ba8acea26fd187d52cf1901bfebf8573f93
Reviewed-on: https://go-review.googlesource.com/11591
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 22:07:29 +00:00
Austin Clements
d231cb8249 runtime: repeat bitmap for slice of GCprog n-1 times, not n times
Currently, to write out the bitmap of a slice of a type with a GCprog,
we construct a new GCprog that executes the underlying type's GCprog
to write out the bitmap once and then repeats those bits n more times.
This results in n+1 repetitions of the bitmap, which is one more
repetition than it should be. This corrupts the bitmap of the heap
following the slice and may write past the mapped bitmap memory and
segfault.

Fix this by repeating the bitmap only n-1 more times.

Fixes #11430.

Change-Id: Ic24854363bffc5a755b66f257339f9309ada3aa5
Reviewed-on: https://go-review.googlesource.com/11570
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-26 21:52:51 +00:00
Brad Fitzpatrick
48025d2ce0 archive/tar: disable new failing test on windows and plan9
Update #11426

Change-Id: If406d2efcc81965825a63c76f5448d544ba2a740
Reviewed-on: https://go-review.googlesource.com/11590
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 21:43:51 +00:00
Dmitry Vyukov
77132c810d runtime/race: enable tests that now pass
These tests pass after cl/11417.

Change-Id: Id98088c52e564208ce432e9717eddd672c42c66d
Reviewed-on: https://go-review.googlesource.com/11551
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:54:11 +00:00
Dmitry Vyukov
03a48ebe1c sync: simplify WaitGroup
A comment in waitgroup.go describes the following scenario
as the reason to have dynamically created semaphores:

// G1: Add(1)
// G1: go G2()
// G1: Wait() // Context switch after Unlock() and before Semacquire().
// G2: Done() // Release semaphore: sema == 1, waiters == 0. G1 doesn't run yet.
// G3: Wait() // Finds counter == 0, waiters == 0, doesn't block.
// G3: Add(1) // Makes counter == 1, waiters == 0.
// G3: go G4()
// G3: Wait() // G1 still hasn't run, G3 finds sema == 1, unblocked! Bug.

However, the scenario is incorrect:
G3: Add(1) happens concurrently with G1: Wait(),
and so there is no reasonable behavior of the program
(G1: Wait() may or may not wait for G3: Add(1) which
can't be the intended behavior).

With this conclusion we can:
1. Remove dynamic allocation of semaphores.
2. Remove the mutex entirely and instead pack counter and waiters
   into single uint64.

This makes the logic significantly simpler, both Add and Wait
do only a single atomic RMW to update the state.

benchmark                            old ns/op     new ns/op     delta
BenchmarkWaitGroupUncontended        30.6          32.7          +6.86%
BenchmarkWaitGroupActuallyWait       722           595           -17.59%
BenchmarkWaitGroupActuallyWait-2     396           319           -19.44%
BenchmarkWaitGroupActuallyWait-4     224           183           -18.30%
BenchmarkWaitGroupActuallyWait-8     134           106           -20.90%

benchmark                          old allocs     new allocs     delta
BenchmarkWaitGroupActuallyWait     2              1              -50.00%

benchmark                          old bytes     new bytes     delta
BenchmarkWaitGroupActuallyWait     48            16            -66.67%

Change-Id: I28911f3243aa16544e99ac8f1f5af31944c7ea3a
Reviewed-on: https://go-review.googlesource.com/4117
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:48:29 +00:00
Mihai Borobocea
450988b5a2 net/http: escape path in implicit /tree→/tree/ ServeMux.Handle redirect
Fixes #10572

Change-Id: I764f3c226cf98ff39d9e553e4613d0ee108ef766
Reviewed-on: https://go-review.googlesource.com/9311
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:32:40 +00:00
Matt T. Proud
e6ad56c711 testing/quick: improve function signature error.
This commit fixes a cosmetic defect whereby quick.Check reports that
the provided function returns too many values when it may, in fact,
return too few:

  func f() {}

  func TestFoo(t *testing.T) {
    if err := quick.Check(f, nil); err != nil {
      t.Fatal(err)
    }
  }
  // yields
  // $ go test -v foo_test.go
  // === RUN TestFoo
  // --- FAIL: TestFoo (0.00s)
  // 	foo_test.go:76: function returns more than one value.

Change-Id: Ia209ff5b57375b30f8db425454e80798908e8ff4
Reviewed-on: https://go-review.googlesource.com/11281
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:03:32 +00:00
Marcel van Lohuizen
fe15da62f7 unicode: upgrade to 8.0.0
Not sure if I'm on time for 1.5; Unicode 8 just got released.

Straighforward upgrade. Only changed maketables.go to prevent it from adding
the Cherokee upper and lower case mappings. This change causes the caseOrbit
table to NOT change. Added tests to verify that the relevant functions still
produce the correct result, even for Cherokee.

Fixes #11309

Change-Id: I42850f5b3399bde125b002efc78eff96dbd86a08
Reviewed-on: https://go-review.googlesource.com/11286
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 18:01:29 +00:00
Shenghou Ma
21a4c93166 runtime: slightly clean up softfloat code
Removes the remains of the old C based stepflt implementation.
Also removed goto usage.

Change-Id: Ida4742c49000fae4fea4649f28afde630ce4c577
Reviewed-on: https://go-review.googlesource.com/9600
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:51:22 +00:00
Russ Cox
32fddadd98 runtime: reduce slice growth during append to 2x
The new inlined code for append assumed that it could pass the
desired new cap to growslice, not the number of new elements.
But growslice still interpreted the argument as the number of new elements,
making it always grow by >2x (more precisely, 2x+1 rounded up
to the next malloc block size). At the time, I had intended to change
the other callers to use the new cap as well, but it's too late for that.
Instead, introduce growslice_n for the old callers and keep growslice
for the inlined (common case) caller.

Fixes #11403.

Filed #11419 to merge them.

Change-Id: I1338b1e5b352f3be4e43641f44b652ef7195251b
Reviewed-on: https://go-review.googlesource.com/11541
Reviewed-by: Austin Clements <austin@google.com>
2015-06-26 17:49:33 +00:00
Brad Fitzpatrick
1284d7d403 net/url: don't escape star requests when writing requests
Includes a new net/http test too.

Fixes #11202

Change-Id: I61edc594f4de8eb6780b8dfa221269dd482e8f35
Reviewed-on: https://go-review.googlesource.com/11492
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:43:29 +00:00
Steve Streeting
379d8327cb net/http: don't overwrite Authorization headers when URL has username
Fixes #11399

Change-Id: I3be7fbc86c5f62761f47122632f3e11b56cb6be6
Reviewed-on: https://go-review.googlesource.com/11510
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:32:12 +00:00
Aamir Khan
0d1ceef945 net/http: change default user agent string
Default user agent in use - "Go 1.1 package http" doesn't conform to RFC 7231.
See http://tools.ietf.org/html/rfc7231#section-5.5.3

Use a valid user-agent string instead.

Fixes #9792

Change-Id: I80249709800dcdbf6f2e97a63fab05656898e6aa
Reviewed-on: https://go-review.googlesource.com/9385
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:29:35 +00:00
Matt Layher
9139089ee5 net/http: add comment to exported ErrNoCookie and ErrNoLocation values
All other exported errors in net/http are commented.  This change adds
documentation to ErrNoCookie and ErrNoLocation to explain where they are
returned, and why.

Change-Id: I21fa0d070dd35256681ad0714000f238477d4af1
Reviewed-on: https://go-review.googlesource.com/11044
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:28:07 +00:00
Austin Clements
e0e47e22ce reflect: test repeats with large scalar tails
This adds a GC bitmap test of a type with many pointer bits and a
large scalar tail, such as the one in issue #11286. This test would
have failed prior to the fix in a8ae93f. This test is a more direct
version of the test introduced in that commit (which was distilled
from the failing test in the issue).

Change-Id: I2e716cd1000b49bde237f5da6d857e8983fe7e7a
Reviewed-on: https://go-review.googlesource.com/11423
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:26:09 +00:00
Austin Clements
4b287553a4 reflect: test GC bits for slices
Currently we test bitmap repetitions constructed by the compiler (for
small arrays) and repetitions performed by GC programs (large arrays
and reflect-constructed arrays), but we don't test dynamic repetitions
performed by the runtime for slice backing stores. Add tests that
parallel the array tests using slices.

Change-Id: If4425941a33cc5b20178dd819a7371e347e47585
Reviewed-on: https://go-review.googlesource.com/11422
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:26:00 +00:00
Todd Neal
37469a7bcb net/http: Fix test that occasionally fails
The consecutive calls to Head would sometimes get different
connections depending on if the readLoop had finished executing
and placed its connection on the idle list or not.  This change
ensures that readLoop completes before we make our second connection.

Fixes #11250

Change-Id: Ibdbc4d3d0aba0162452f6dec5928355a37dda70a
Reviewed-on: https://go-review.googlesource.com/11170
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 17:22:53 +00:00
Ian Lance Taylor
61cd48b1ce debug/elf: change R_ARM_REL32 to R_ARM_ABS32 in applyRelocationsARM
The original version of applyRelocationsARM was added in
http://golang.org/cl/7266.  It was added to fix the ARM build, which
had been broken by http://golang.org/cl/6780.

Before CL 6780, there was no relocation processing for ARM.  CL 6780
changed the code to require relocation processing for every supported
target.  CL 7266 fixed the ARM build by adding a relocation processing
function, but in fact no actual processing was done.  The code only
looked for REL32 relocations, but ARM debug info has no such
relocations.  The test case added in CL 7266 doesn't have any either.

This didn't matter because no relocation processing was required on
ARM, at least not for GCC-generated debug info.  GCC generates ABS32
relocations, but only against section symbols which have the value 0.
Therefore, the addition done by correct handling of ABS32 doesn't
change anything.

Clang, however, generates ABS32 relocations against local symbols,
some of which have non-zero values.  For those, we need to handle
ABS32 relocations.

This patch corrects the CL 7266 to look for ABS32 relocations instead
of REL32 relocations.  The code was already written to correctly
handle ABS32 relocations, it just mistakenly said REL32.

This is the ARM equivalent of https://golang.org/cl/96680045, which
fixed the same problem in the same way for clang on 386.

With this patch, clang-3.5 can be used to build Go on ARM GNU/Linux.

Fixes #8980.

Change-Id: I0c2d72eadfe6373bde99cd03eee40de6a582dda1
Reviewed-on: https://go-review.googlesource.com/11222
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-06-26 16:17:54 +00:00
Adam Langley
4ec946ce95 crypto/x509: don't panic when decrypting invalid PEM data.
If an encrypted PEM block contained ciphertext that was not a multiple
of the block size then the code would panic. This change tests for that
case and returns an error.

Fixes #11215.

Change-Id: I7b700f99e20810c4f545519b1e9d766b4640e8a7
Reviewed-on: https://go-review.googlesource.com/11097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 16:16:51 +00:00
Dmitry Savintsev
c248aaef70 crypto/ecdsa, crypto/x509: update SEC1 ECC link in comments
Updated the document URL in comments to avoid dead link
Old: http://www.secg.org/download/aid-780/sec1-v2.pdf
New: http://www.secg.org/sec1-v2.pdf

Change-Id: If13d0da4c0e7831b2bd92c45116c2412a2a965f5
Reviewed-on: https://go-review.googlesource.com/11550
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 16:08:22 +00:00
Todd Neal
765c0f37ed cmd/compile: fix half multiply issue
In walkdiv, an OMUL node was created and passed to typecheck,
before the op was changed back to OHMUL.  In some instances,
the node that came back was an evaluated literal constant that
occurred with a full multiply.  The end result was a literal node
with a non-shifted value and an OHMUL op. This change causes code
to be generated for the OHMUL.

Fixes #11358
Fixes #11369

Change-Id: If42a98c6830d07fe065d5ca57717704fb8cfbd33
Reviewed-on: https://go-review.googlesource.com/11400
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:55:22 +00:00
Dmitry Vyukov
cd0a8ed48a cmd/compile: add instrumentation of OKEY
Instrument operands of OKEY.
Also instrument OSLICESTR. Previously it was not needed
because of preceeding bounds checks (which were instrumented).
But the preceeding bounds checks have disappeared.

Change-Id: I3b0de213e23cbcf5b8ef800abeded5eeeb3f8287
Reviewed-on: https://go-review.googlesource.com/11417
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:54:03 +00:00
Vincent Batts
f271f928d9 archive/tar: fix round-trip attributes
The issue was identified while
working with round trip FileInfo of the headers of hardlinks. Also,
additional test cases for hard link handling.
(review carried over from http://golang.org/cl/165860043)

Fixes #9027

Change-Id: I9e3a724c8de72eb1b0fbe0751a7b488894911b76
Reviewed-on: https://go-review.googlesource.com/6790
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-26 15:51:06 +00:00
Aaron Jacobs
8628688304 Fix several out of date references to 4g/5g/6g/8g/9g.
Change-Id: Ifb8e4e13c7778a7c0113190051415e096f5db94f
Reviewed-on: https://go-review.googlesource.com/11390
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-26 03:38:21 +00:00
Andrew Gerrand
895df143a2 math: explain OEIS link
Fixes #10236

Change-Id: Ife85513efda48af81c267b753da2ac7317cdfe75
Reviewed-on: https://go-review.googlesource.com/11479
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-06-26 01:25:58 +00:00
Brad Fitzpatrick
bf5e19fbaf net/http: tolerate old buggy user agents, per RFC 2616 section 4.1
Some old buggy browsers sent extra CRLF(s) after POST bodies. Skip
over them before reading subsequent requests.

Fixes #10876

Change-Id: I62eacf2b3e985caffa85aee3de39d8cd3548130b
Reviewed-on: https://go-review.googlesource.com/11491
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 22:31:26 +00:00
Dmitry Vyukov
055e1a3ae7 runtime/race: fix test driver
At some point it silently stopped recognizing test output.
Meanwhile two tests degraded...

Change-Id: I90a0325fc9aaa16c3ef16b9c4c642581da2bb10c
Reviewed-on: https://go-review.googlesource.com/11416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 11:36:07 +00:00
Brad Fitzpatrick
1045351cef net/http: bound the number of bytes read seeking EOF in Handler's Body.Close
If a client sent a POST with a huge request body, calling
req.Body.Close in the handler (which is implicit at the end of a
request) would end up consuming it all.

Put a cap on that, using the same threshold used elsewhere for similar
cases.

Fixes #9662

Change-Id: I26628413aa5f623a96ef7c2609a8d03c746669e5
Reviewed-on: https://go-review.googlesource.com/11412
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 07:05:07 +00:00
Todd Neal
4e834cff4f fmt: handle negative width/prec when supplied as an argument
Negative width arguments now left align the way a minus-width in the
format string aligns. The minus in the format string overrides the sign
of the argument as in C.

Precision behavior is modified to include an error if the argument is
negative.  This differs from a negative precision in a format string
which just terminates the format.

Additional checks for large magnitude widths and precisions are added to
make the runtime behavior (failure, but with different error messages),
more consistent between format string specified width/precision and
argument specified width/precision.

Fixes #11376

Change-Id: I8c7ed21088e9c18128a45d4c487c5ab9fafd13ef
Reviewed-on: https://go-review.googlesource.com/11405
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2015-06-25 05:34:02 +00:00
Matthew Dempsky
2bcdb5a5d9 net/http: sync Get and Head's documentation
Instead of ambiguously referring to "the Client's CheckRedirect
function" in Head, describe the default behavior like for Get as users
aren't expected to change DefaultClient.CheckRedirect.

While here, use consistent punctuation for the Get and Head Client
method documentation.

Change-Id: I9e7046c73b0d0bc4de002234924d9e7c59aceb41
Reviewed-on: https://go-review.googlesource.com/11362
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-25 05:07:40 +00:00
Brad Fitzpatrick
190313e696 net/http: document that Hijack's net.Conn might have left-over timeouts set
Fixes #8296

Change-Id: I71b330a0f961d46ae4ed81d5f3f5ce5bf708a29a
Reviewed-on: https://go-review.googlesource.com/11411
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 03:01:52 +00:00
Keith Randall
dbe9ab69d9 cmd/compile/internal/gc: make sure nonzero-sized objects have nonzero alignment
See issue #11354.

Change-Id: I6817d499e6c02e4a9c83f80bc66a2bee368a69ec
Reviewed-on: https://go-review.googlesource.com/11406
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-25 02:22:58 +00:00
Brad Fitzpatrick
f81f6d6ee8 net/http: don't always require certFile, keyFile in Server.ListenAndServerTLS
The ListenAndServerTLS function still requires the certFile and
keyFile, but the Server.ListenAndServerTLS method doesn't need to
require the certFile and keyFile if the Server.TLSConfig.Certificates
are already populated.

Fixes #8599

Change-Id: Id2e3433732f93e2619bfd78891f775d89f1d651e
Reviewed-on: https://go-review.googlesource.com/11413
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 01:44:47 +00:00
Brad Fitzpatrick
2917ab2049 net/http: document that FormValue returns the empty string
Fixes #8137

Change-Id: Icd94bbe430a3ef333248425449b5fc678edb0343
Reviewed-on: https://go-review.googlesource.com/11410
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-25 01:17:32 +00:00
Russ Cox
33ce9c19d7 text/template: make zero Template work again
Fixes #11379.

Change-Id: Idbb5c3faad472b77e9867dd2d4551fef5e4ac5f1
Reviewed-on: https://go-review.googlesource.com/11421
Reviewed-by: Rob Pike <r@golang.org>
2015-06-24 22:27:33 +00:00
Russ Cox
66130907d1 cmd/compile: handle copy in escape analysis
Somehow we missed this!
Fixes #11387.

Change-Id: Ida08fe52eff7da2ef7765b4cf35a39a301420c43
Reviewed-on: https://go-review.googlesource.com/11460
Reviewed-by: David Chase <drchase@google.com>
2015-06-24 22:22:55 +00:00
Russ Cox
a9e536442e runtime: set m.procid always on Linux
For debuggers and other program inspectors.

Fixes #9914.

Change-Id: I670728cea28c045e6eaba1808c550ee2f34d16ff
Reviewed-on: https://go-review.googlesource.com/11341
Reviewed-by: Austin Clements <austin@google.com>
2015-06-24 21:50:39 +00:00
Didier Spezia
c68f2f8996 go/format: fix //line corner case when formatting statements
The code formatting mechanism can be applied to partial Go code,
such as a list of statements. The statements are wrapped into a
function definition (to be parsed fine), and unwrapped after formatting.

When the statements contain //line annotations, it may fail,
because not all comments are flushed by the printer before the final '}'.
Formatting "\ta()\n//line :1" results in "\ta() }\n\n//line", which
is wrong.

Tweaked the wrapping/unwrapping code to make sure comments are flushed
before the '}'.

Fixes #11276

Change-Id: Id15c80279b0382ee9ed939cca1647f525c4929f5
Reviewed-on: https://go-review.googlesource.com/11282
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-06-24 21:45:49 +00:00
Dmitry Vyukov
77082481d4 runtime/race: make test more robust
The test is flaky on builders lately. I don't see any issues other than
usage of very small sleeps. So increase the sleeps. Also take opportunity
to refactor the code.
On my machine this change significantly reduces failure rate with GOMAXPROCS=2.
I can't reproduce the failure with GOMAXPROCS=1.

Fixes #10726

Change-Id: Iea6f10cf3ce1be5c112a2375d51c13687a8ab4c9
Reviewed-on: https://go-review.googlesource.com/9803
Reviewed-by: Austin Clements <austin@google.com>
2015-06-24 17:53:25 +00:00
Brad Fitzpatrick
703166ea14 net/url: validate ports in URLs and bytes after IPv6 literals
Fixes #11208

Change-Id: I35cc94129577b2a977fd35aafb0a5fb02c534a7c
Reviewed-on: https://go-review.googlesource.com/11414
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-24 16:20:45 +00:00
Russ Cox
222b23aae9 net: make LookupIP("1.2.3.4") behavior consistent
To date, the behavior has depended on whether we're using cgo and
in turn what the host resolver does. Most host resolvers will "resolve"
IP addresses, but the non-cgo pure Go path has not.
This CL makes resolution of IP addresses always work, even if we're not using cgo
and even if the host resolver does not "resolve" IP addresses.

Fixes #11335.

Change-Id: I19e82be968154d94904bb2f72e9c17893019a909
Reviewed-on: https://go-review.googlesource.com/11420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-24 15:16:36 +00:00
Carlos C
0dccee6061 text/scanner: add runnable example for package
Change-Id: I42a952b04a56fb888fa7d5d9c2b56cbdd3434034
Reviewed-on: https://go-review.googlesource.com/11246
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-24 07:22:28 +00:00
Andrew Gerrand
5bf1853e59 cmd/go: don't fetch from insecure repositories without -insecure
Fixes #9637
Fixes #10120

Change-Id: I3728239089efb94d04cd4115c9f840afd7badeaf
Reviewed-on: https://go-review.googlesource.com/9715
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-24 06:36:07 +00:00
Robert Griesemer
eb30fda83e go/types: in string(x) conversions, x must be of integer type
Port of https://go-review.googlesource.com/11365

Fixes #11357.

Change-Id: Icd20fa038696a8853d1d14477e1c1132938b3e2e
Reviewed-on: https://go-review.googlesource.com/11368
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 21:06:07 +00:00
Robert Griesemer
4ba1f25888 go/types: better error message for certain unary/binary expression errors
Port of https://go-review.googlesource.com/11363.

Fixes #11367.

Change-Id: Ie0a82bcfab782c514d1947e7a6b190e286afd159
Reviewed-on: https://go-review.googlesource.com/11367
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 21:05:46 +00:00
Austin Clements
a8ae93fd26 runtime: fix heap bitmap repeating with large scalar tails
When heapBitsSetType repeats a source bitmap with a scalar tail
(typ.ptrdata < typ.size), it lays out the tail upon reaching the end
of the source bitmap by simply increasing the number of bits claimed
to be in the incoming bit buffer. This causes later iterations to read
the appropriate number of zeros out of the bit buffer before starting
on the next repeat of the source bitmap.

Currently, however, later iterations of the loop continue to read bits
from the source bitmap *regardless of the number of bits currently in
the bit buffer*. The bit buffer can only hold 32 or 64 bits, so if the
scalar tail is large and the padding bits exceed the size of the bit
buffer, the read from the source bitmap on the next iteration will
shift the incoming bits into oblivion when it attempts to put them in
the bit buffer. When the buffer does eventually shift down to where
these bits were supposed to be, it will contain zeros. As a result,
words that should be marked as pointers on later repetitions are
marked as scalars, so the garbage collector does not trace them. If
this is the only reference to an object, it will be incorrectly freed.

Fix this by adding logic to drain the bit buffer down if it is large
instead of reading more bits from the source bitmap.

Fixes #11286.

Change-Id: I964432c4b9f1cec334fc8c3da0ff16460203feb6
Reviewed-on: https://go-review.googlesource.com/11360
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-23 18:37:17 +00:00
Austin Clements
eabdd05892 runtime: document memory ordering for h_spans
h_spans can be accessed concurrently without synchronization from
other threads, which means it needs the appropriate memory barriers on
weakly ordered machines. It happens to already have the necessary
memory barriers because all accesses to h_spans are currently
protected by the heap lock and the unlocks happen in exactly the
places where release barriers are needed, but it's easy to imagine
that this could change in the future. Document the fact that we're
depending on the barrier implied by the unlock.

Related to issue #9984.

Change-Id: I1bc3c95cd73361b041c8c95cd4bb92daf8c1f94a
Reviewed-on: https://go-review.googlesource.com/11361
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-23 18:28:46 +00:00
Robert Griesemer
ef4a17bc80 go/types: add missing test for constant shifts
Port of https://go-review.googlesource.com/11344 to std repo.

Fixes #11325.

Change-Id: I634beaf77cbaeb09de50aa1410e8c53fc37b19df
Reviewed-on: https://go-review.googlesource.com/11317
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-23 18:03:49 +00:00
Rob Pike
989b372a5c cmd/asm: fix shifts again, this time for sure
There are two conditions to worry about:

1) The shift count cannot be negative. Since the evaluator uses unsigned
arithmetic throughout, this means checking that the high bit of
the shift count is always off, which is done by converting to int64
and seeing if the result is negative.

2) For right shifts, the value cannot be negative. We don't want a
high bit in the value because right shifting a value depends on the
sign, and for clarity we always want unsigned shifts.

Next step is to build some testing infrastructure for the parser.

Change-Id: I4c46c79989d02c107fc64954403fc18613763f1d
Reviewed-on: https://go-review.googlesource.com/11326
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-23 06:44:54 +00:00
Andrew Bonventre
4bba6729f8 image/gif: set default loop count to 0 when app ext. is not present
It was otherwise not being preserved across
specific Decode->Encode->Decode calls.

Fixes #11287

Change-Id: I40602da7fa39ec67403bed52ff403f361c6171bb
Reviewed-on: https://go-review.googlesource.com/11256
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-23 05:50:50 +00:00
Rob Pike
f2662f2c93 text/template: explain better the semantics of ParseFiles
Documentation change only.

Fixes #11247.

Change-Id: Ib412de2d643292dbe42b56dee955bdb877aee81b
Reviewed-on: https://go-review.googlesource.com/11329
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-06-23 03:18:52 +00:00
Todd Neal
c8aea7b18f net/http: Remove unused code
This appears to be some legacy which is no longer used.

Change-Id: I469beb59a90853e8de910158f179b32f1aa14c7d
Reviewed-on: https://go-review.googlesource.com/11304
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Andrew Gerrand <adg@golang.org>
2015-06-22 22:54:35 +00:00
Rob Pike
cb3e2bf0ba cmd/doc: fix copy/paste error in test
Some of those consts were supposed to be vars.

Caught by Ingo Oeser.

Change-Id: Ifc12e4a8ee61ebf5174e4ad923956c546dc096e2
Reviewed-on: https://go-review.googlesource.com/11296
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 22:29:35 +00:00
Rob Pike
58d177c63e cmd/asm: fix handling of negative shifts.
The change that "fixed" LSH was incorrect, and the fix for RSH was poor.
Make both use a correct, simple test: if the 64-bit value as a signed
integer is negative, it's an error.

Really fixes #11278.

Change-Id: I72cca03d7ad0d64fd649fa33a9ead2f31bd2977b
Reviewed-on: https://go-review.googlesource.com/11325
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 20:42:22 +00:00
Rob Pike
98c9e9e74f cmd/vet: refer info about -printfuncs to the -printf flag
And vice versa.

The flags are tightly coupled so make the connection clear.

Change-Id: I505f76be631ffa6e489a441c2f3c717aa09ec802
Reviewed-on: https://go-review.googlesource.com/11324
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 20:42:01 +00:00
Rick Hudson
1ab9176e54 runtime: remove race and increase precision in pointer validation.
This CL removes the single and racy use of mheap.arena_end outside
of the bookkeeping done in mHeap_init and mHeap_Alloc.
There should be no way for heapBitsForSpan to see a pointer to
an invalid span. This CL makes the check for this more precise by
checking that the pointer is between mheap_.arena_start and
mheap_.arena_used instead of mheap_.arena_end.

Change-Id: I1200b54353ee1eda002d92645fd8d26048600ceb
Reviewed-on: https://go-review.googlesource.com/11342
Reviewed-by: Austin Clements <austin@google.com>
2015-06-22 20:37:23 +00:00
Russ Cox
ffbed5c22a net/http: fix tests for recent URL.RawPath addition
Change-Id: I35d20ed958c32d464b2c9d849403b6e3f99b6482
Reviewed-on: https://go-review.googlesource.com/11343
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-22 19:01:21 +00:00
Austin Clements
9a3112bcae runtime: one more Map{Bits,Spans} before arena_used update
In order to avoid a race with a concurrent write barrier or garbage
collector thread, any update to arena_used must be preceded by mapping
the corresponding heap bitmap and spans array memory. Otherwise, the
concurrent access may observe that a pointer falls within the heap
arena, but then attempt to access unmapped memory to look up its span
or heap bits.

Commit d57c889 fixed all of the places where we updated arena_used
immediately before mapping the heap bitmap and spans, but it missed
the one place where we update arena_used and depend on later code to
update it again and map the bitmap and spans. This creates a window
where the original race can still happen. This commit fixes this by
mapping the heap bitmap and spans before this arena_used update as
well. This code path is only taken when expanding the heap reservation
on 32-bit over a hole in the address space, so these extra mmap calls
should have negligible impact.

Fixes #10212, #11324.

Change-Id: Id67795e6c7563eb551873bc401e5cc997aaa2bd8
Reviewed-on: https://go-review.googlesource.com/11340
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-22 18:54:38 +00:00
Austin Clements
2a331ca8bb runtime: document relaxed access to arena_used
The unsynchronized accesses to mheap_.arena_used in the concurrent
part of the garbage collector look like a problem waiting to happen.
In fact, they are safe, but the reason is somewhat subtle and
undocumented. This commit documents this reasoning.

Related to issue #9984.

Change-Id: Icdbf2329c1aa11dbe2396a71eb5fc2a85bd4afd5
Reviewed-on: https://go-review.googlesource.com/11254
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-06-22 18:37:20 +00:00
Russ Cox
874a605af0 net/url: add RawPath field, a hint at the desired encoding of Path
Historically we have declined to try to provide real support for URLs
that contain %2F in the path, but they seem to be popping up more
often, especially in (arguably ill-considered) REST APIs that shoehorn
entire paths into individual path elements.

The obvious thing to do is to introduce a URL.RawPath field that
records the original encoding of Path and then consult it during
URL.String and URL.RequestURI. The problem with the obvious thing
is that it breaks backward compatibility: if someone parses a URL
into u, modifies u.Path, and calls u.String, they expect the result
to use the modified u.Path and not the original raw encoding.

Split the difference by treating u.RawPath as a hint: the observation
is that there are many valid encodings of u.Path. If u.RawPath is one
of them, use it. Otherwise compute the encoding of u.Path as before.

If a client does not use RawPath, the only change will be that String
selects a different valid encoding sometimes (the original passed
to Parse).

This ensures that, for example, HTTP requests use the exact
encoding passed to http.Get (or http.NewRequest, etc).

Also add new URL.EscapedPath method for access to the actual
escaped path. Clients should use EscapedPath instead of
reading RawPath directly.

All the old workarounds remain valid.

Fixes #5777.
Might help #9859.
Fixes #7356.
Fixes #8767.
Fixes #8292.
Fixes #8450.
Fixes #4860.
Fixes #10887.
Fixes #3659.
Fixes #8248.
Fixes #6658.
Reduces need for #2782.

Change-Id: I77b88f14631883a7d74b72d1cf19b0073d4f5473
Reviewed-on: https://go-review.googlesource.com/11302
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-22 16:45:18 +00:00
Russ Cox
794c01b8b4 cmd/go: fix test for issue 8181
The test was translated from shell incorrectly,
and it depended on having hg installed, which
may not be the case.

Moved repo to GitHub, updated code, and fixed
go list ... command to be expected to succeed.

Fixes test for #8181.

Change-Id: I7f3e8fb20cd16cac5ed24de6fd952003bc5e08d4
Reviewed-on: https://go-review.googlesource.com/11301
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-22 16:44:46 +00:00
Carlos C
1be335b608 encoding/csv: add examples for package
Change-Id: I3463826aa760aa5984dec4fc043b95fd2a5120ac
Reviewed-on: https://go-review.googlesource.com/11240
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 11:11:37 +00:00
Rob Pike
71859efceb cmd/asm: remove needless check for negative right shift
In the parser, the shift value is always a uint64.

Change-Id: I9b50295a9f7d174ed1f6f9baf78ec0ed43db417f
Reviewed-on: https://go-review.googlesource.com/11322
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-22 06:57:19 +00:00
Jeff R. Allen
626188dd31 net/textproto: skip zero-length keys
A header of ": value" results in an empty key. Do not add
it to the headers, because RFC7230 (section 3.2) says that
field-names are tokens, which are one or more characters.

Fixes #11205.

Change-Id: I883be89da1489dc84f98523786b019d1d0169d46
Reviewed-on: https://go-review.googlesource.com/11242
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-22 02:48:27 +00:00
Rob Pike
3cab4760d5 cmd/asm: remove pointless check for negative uint
Fixes #11278.

Change-Id: Ic46fda0f42cefedc3f6085c0e77e67616ce4955e
Reviewed-on: https://go-review.googlesource.com/11297
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-21 03:11:01 +00:00
Rob Pike
13c44d27b7 cmd/doc: add test for constructor, fix build
Most important: skip test on darwin/arm64 for unclear reasons.

First cut at the test missed this feature of go doc: when asking for
the docs for a type, include any function that looks like it constructs
a that type as a return value.

Change-Id: I124e7695e5d365e2b12524b541a9a4e6e0300fbc
Reviewed-on: https://go-review.googlesource.com/11295
Reviewed-by: Rob Pike <r@golang.org>
2015-06-20 10:35:38 +00:00
Ian Lance Taylor
79d4d6eca4 syscall: skip non-root user namespace test if kernel forbids
Some Linux kernels apparently have a sysctl that prohibits
nonprivileged processes from creating user namespaces.  If we see a
failure for that reason, skip the test.

Fixes #11261.

Change-Id: I82dfcaf475eea4eaa387941373ce7165df4848ad
Reviewed-on: https://go-review.googlesource.com/11269
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-06-20 00:52:38 +00:00
Rob Pike
2f2908bec3 cmd/doc: fix test on nacl
nacl is really giving a hard time. avoid all external dependencies in the test.
Worked with trybots, failed in the build. No explanation, but this should fix it.

TBR=rsc

Change-Id: Icb644286dbce88f17ee3d96ad90efba34a80a92d
Reviewed-on: https://go-review.googlesource.com/11291
Reviewed-by: Rob Pike <r@golang.org>
2015-06-19 22:13:20 +00:00
Rob Pike
d0652e7f82 cmd/doc: add test
Refactor main a bit to make it possible to run tests without an exec every time.
(Makes a huge difference in run time.)

Add a silver test. Not quite golden, since it looks for pieces rather than the
full output, and also includes tests for what should not appear.

Fixes #10920.

Change-Id: I6a4951cc14e61763379754a10b0cc3484d30c267
Reviewed-on: https://go-review.googlesource.com/11272
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2015-06-19 21:56:59 +00:00
Srdjan Petrovic
cc6554f750 cmd/link/internal/ld, cmd/go: -buildmode=c-shared support for darwin/amd64
All of the heavy-lifting was done by minux@, with his external-linking support
for darwin/arm64: golang.org/cl/8781

Change-Id: I7c9fbc19246f418c065c92fb2c13c00026ff0f82
Reviewed-on: https://go-review.googlesource.com/11127
Run-TryBot: Srdjan Petrovic <spetrovic@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-06-19 20:28:01 +00:00
Russ Cox
dc89350fed cmd/go: fix build
Change-Id: Ia13d1fa450e88e278b81048b99686395ca474c99
Reviewed-on: https://go-review.googlesource.com/11259
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-19 20:05:31 +00:00
Robert Griesemer
1eb8c4aa44 math/big: fix GCD in presence of aliasing
Fixes #11284.

Change-Id: I4ecc4e4cd3c1b3467b43e4ba9666ea6db5fb61a5
Reviewed-on: https://go-review.googlesource.com/11268
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-06-19 19:53:45 +00:00
Russ Cox
183cc0cd41 cmd/go: add preliminary support for vendor directories
When GO15VENDOREXPERIMENT=1 is in the environment,
this CL changes the resolution of import paths according to
the Go 1.5 vendor proposal:

	If there is a source directory d/vendor, then,
	when compiling a source file within the subtree rooted at d,
	import "p" is interpreted as import "d/vendor/p" if that exists.

	When there are multiple possible resolutions,
	the most specific (longest) path wins.

	The short form must always be used: no import path can
	contain “/vendor/” explicitly.

	Import comments are ignored in vendored packages.

The goal of these changes is to allow authors to vendor (copy) external
packages into their source trees without any modifications to the code.
This functionality has been achieved in tools like godep, nut, and gb by
requiring GOPATH manipulation. This alternate directory-based approach
eliminates the need for GOPATH manipulation and in keeping with the
go command's use of directory layout-based configuration.

The flag allows experimentation with these vendoring semantics once
Go 1.5 is released, without forcing them on by default. If the experiment
is deemed a success, the flag will default to true in Go 1.6 and then be
removed in Go 1.7.

For more details, see the original proposal by Keith Rarick at
https://groups.google.com/d/msg/golang-dev/74zjMON9glU/dGhnoi2IMzsJ.

Change-Id: I2c6527e777d14ac6dc43c53e4b3ff24f3279216e
Reviewed-on: https://go-review.googlesource.com/10923
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-19 19:05:01 +00:00