]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agomisc/pprof: always use go tool objdump on windows
Alex Brainman [Thu, 15 May 2014 05:54:42 +0000 (15:54 +1000)]
misc/pprof: always use go tool objdump on windows

Fixes #7406.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/97440043

10 years agocmd/addr2line, cmd/objdump: fix pe text section starting address
Alex Brainman [Thu, 15 May 2014 02:44:29 +0000 (12:44 +1000)]
cmd/addr2line, cmd/objdump: fix pe text section starting address

fixes windows build

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97500043

10 years agocmd/nm, cmd/objdump: fix elf symbol types
Russ Cox [Thu, 15 May 2014 00:45:13 +0000 (17:45 -0700)]
cmd/nm, cmd/objdump: fix elf symbol types

Turns out elf.File.Sections is indexed by the actual
section number, not the number minus one.
I don't know why I thought the -1 was necessary.

Fixes objdump test (and therefore build) on ELF systems.

While we're here, fix bounds on gnuDump so that we
don't crash when asked to disassemble outside
the text segment. May fix Windows build or at least
make the failure more interesting.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/92390043

10 years agonet: detect changes to /etc/resolv.conf.
Guillaume J. Charmes [Thu, 15 May 2014 00:11:00 +0000 (17:11 -0700)]
net: detect changes to /etc/resolv.conf.

Implement the changes as suggested by rsc.
Fixes #6670.

LGTM=josharian, iant
R=golang-codereviews, iant, josharian, mikioh.mikioh, alex, gobot
CC=golang-codereviews, rsc
https://golang.org/cl/83690045

10 years agoobjdump: implement disassembly
Russ Cox [Wed, 14 May 2014 23:51:15 +0000 (19:51 -0400)]
objdump: implement disassembly

There is some duplication here with cmd/nm.
There is a TODO to address that after 1.3 is out.

Update #7452

x86 disassembly works and is tested.

The arm disassembler does not exist yet
and is therefore not yet hooked up.

LGTM=crawshaw, iant
R=crawshaw, iant
CC=golang-codereviews
https://golang.org/cl/91360046

10 years agocmd/objdump: import x86 disassembler
Russ Cox [Wed, 14 May 2014 23:46:53 +0000 (19:46 -0400)]
cmd/objdump: import x86 disassembler

The x86 disassembler lives in rsc.io/x86/x86asm for now.
We need to figure out what should live where in the long term,
but not before the 1.3 release.

The completed code reviews for the disassembler are at:
https://golang.org/cl/95350044
https://golang.org/cl/95300044
https://golang.org/cl/97100047
https://golang.org/cl/93110044
https://golang.org/cl/99000043
https://golang.org/cl/98990043

LGTM=crawshaw
R=crawshaw, jacek.masiulaniec
CC=golang-codereviews
https://golang.org/cl/92360043

10 years agoA+C: Cezar Sá Espinola (individual CLA)
Andrew Gerrand [Wed, 14 May 2014 23:10:32 +0000 (09:10 +1000)]
A+C: Cezar Sá Espinola (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/92380043

10 years agotest: fix flakey test case for issue 4388
Mikio Hara [Wed, 14 May 2014 21:39:15 +0000 (06:39 +0900)]
test: fix flakey test case for issue 4388

Seems like we need to drag the stack for <autogenerated>:1 on Plan 9.

See http://build.golang.org/log/283b996102b833dd81c58301d78aceaa4fe9838b.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/95390043

10 years agodoc/effective_go.html: a little more about errors
Rob Pike [Wed, 14 May 2014 20:46:58 +0000 (13:46 -0700)]
doc/effective_go.html: a little more about errors
Make it a little clearer how they are used, in particular that
it is not enough just to return a nil pointer on error, but also
to return an error value explaining the problem.

Fixes #1963.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97360045

10 years agospec: more precise description of select statement
Robert Griesemer [Wed, 14 May 2014 18:47:19 +0000 (11:47 -0700)]
spec: more precise description of select statement

- use previously defined terms (with links) throughout
- specify evaluation order more precisely (in particular,
  the evaluation time of rhs expressions in receive cases
  was not specified)
- added extra example case

Not a language change.

Description matches observed behavior of code compiled
with gc and gccgo.

Fixes #7669.

LGTM=iant, r, rsc
R=r, rsc, iant, ken, josharian
CC=golang-codereviews
https://golang.org/cl/91230043

10 years agoarchive/tar: Fix bug preventing untar
Guillaume J. Charmes [Wed, 14 May 2014 17:15:43 +0000 (10:15 -0700)]
archive/tar: Fix bug preventing untar

Do not use ustar format if we need the GNU one.
Change \000 to \x00 for consistency
Check for "ustar\x00" instead of "ustar\x00\x00" for conistency with tar
and compatiblity with archive generated with older code (which was ustar\x00\x20\x00)
Add test for long name + big file.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/99050043

10 years agocmd/gc: fix out of bounds access
Dmitriy Vyukov [Wed, 14 May 2014 15:24:00 +0000 (19:24 +0400)]
cmd/gc: fix out of bounds access
AddressSanitizer says:

AddressSanitizer: heap-buffer-overflow on address 0x60200001b6f3
READ of size 6 at 0x60200001b6f3 thread T0
    #0 0x46741b in __interceptor_memcmp asan_interceptors.cc:337
    #1 0x4b5794 in compile src/cmd/6g/../gc/pgen.c:177
    #2 0x509b81 in funccompile src/cmd/gc/dcl.c:1457
    #3 0x520fe2 in p9main src/cmd/gc/lex.c:489
    #4 0x5e2e01 in main src/lib9/main.c:57
    #5 0x7fab81f7976c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
    #6 0x4b16dc in _start (pkg/tool/linux_amd64/6g+0x4b16dc)

0x60200001b6f3 is located 0 bytes to the right of 3-byte region [0x60200001b6f0,0x60200001b6f3)
allocated by thread T0 here:
    #0 0x493ec8 in __interceptor_malloc asan_malloc_linux.cc:75
    #1 0x54d64e in mal src/cmd/gc/subr.c:459
    #2 0x5260d5 in yylex src/cmd/gc/lex.c:1605
    #3 0x52078f in p9main src/cmd/gc/lex.c:402
    #4 0x5e2e01 in main src/lib9/main.c:57

If the memory block happens to be at the end of hunk and page bounadry,
this out-of-bounds can lead to a crash.

LGTM=dave, iant
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/93370043

10 years agonet: fix documentation for SetLinger
Mikio Hara [Wed, 14 May 2014 03:12:01 +0000 (12:12 +0900)]
net: fix documentation for SetLinger

Fixes #7974.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95320043

10 years agoregexp/syntax: don't waste time checking for one pass algorithm
Rob Pike [Tue, 13 May 2014 19:17:49 +0000 (12:17 -0700)]
regexp/syntax: don't waste time checking for one pass algorithm
The code recurs very deeply in cases like (?:x{1,1000}){1,1000}
Since if much time is spent checking whether one pass is possible, it's not
worth doing at all, a simple fix is proposed: Stop if the check takes too long.
To do this, we simply avoid machines with >1000 instructions.

Benchmarks show a percent or less change either way, effectively zero.

Fixes #7608.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/92290043

10 years agoreflect: fix map type generation
Dmitriy Vyukov [Tue, 13 May 2014 05:53:47 +0000 (09:53 +0400)]
reflect: fix map type generation
If a map variable is created with reflect.New it has incorrect type (map[unsafe.Pointer]unsafe.Pointer).
If GC follows such pointer, it scans Hmap and buckets with incorrect type.
This can lead to overscan of up to 120 bytes for map[int8]struct{}.
Which in turn can lead to crash if the memory after a bucket object is unaddressable
or false retention (buckets are scanned as arrays of unsafe.Pointer).
I don't see how it can lead to heap corruptions, though.

LGTM=khr
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/96270044

10 years agoruntime: fix triggering of forced GC
Dmitriy Vyukov [Tue, 13 May 2014 05:53:03 +0000 (09:53 +0400)]
runtime: fix triggering of forced GC
mstats.last_gc is unix time now, it is compared with abstract monotonic time.
On my machine GC is forced every 5 mins regardless of last_gc.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, iant, rsc
https://golang.org/cl/91350045

10 years agocmd/go: fix go test again
Russ Cox [Tue, 13 May 2014 05:38:10 +0000 (01:38 -0400)]
cmd/go: fix go test again

Fixes subrepo builds.

LGTM=iant, mikioh.mikioh
R=golang-codereviews, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/96310043

10 years agoruntime: handle decommit failure gracefully on Windows
Russ Cox [Tue, 13 May 2014 05:09:38 +0000 (01:09 -0400)]
runtime: handle decommit failure gracefully on Windows

I have no test case for this at tip.
The original report included a program crashing at revision 88ac7297d2fa.
I tested this code at that revision and it does fix the crash.
However, at tip the reported code no longer crashes, presumably
because some allocation patterns have changed. I believe the
bug is still present at tip and that this code still fixes it.

Fixes #7143.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=dvyukov, golang-codereviews
https://golang.org/cl/96300046

10 years agocmd/cgo: omit misaligned struct fields, like we omit bitfields
Russ Cox [Tue, 13 May 2014 03:48:20 +0000 (23:48 -0400)]
cmd/cgo: omit misaligned struct fields, like we omit bitfields

Fixes #7560.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96300045

10 years agoio: copy slice argument in MultiReader and MultiWriter
Russ Cox [Tue, 13 May 2014 03:38:35 +0000 (23:38 -0400)]
io: copy slice argument in MultiReader and MultiWriter

Replaces CL 91240045.
Fixes #7809.

LGTM=bradfitz
R=golang-codereviews, minux.ma
CC=adg, bradfitz, golang-codereviews, iant, r
https://golang.org/cl/94380043

10 years agoencoding/json: document what unmarshal of `null` into non-reference type does
Russ Cox [Tue, 13 May 2014 03:38:26 +0000 (23:38 -0400)]
encoding/json: document what unmarshal of `null` into non-reference type does

Originally it was an error, which made perfect sense, but in issue 2540
I got talked out of this sensible behavior. I'm not thrilled with the "new"
behavior but it's been there since Go 1.1 so we're stuck with it now.

Fixes #6724.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/100430043

10 years agoencoding/xml: fix to allow xml declaration with EncodeToken
Jason Del Ponte [Tue, 13 May 2014 03:35:56 +0000 (23:35 -0400)]
encoding/xml: fix to allow xml declaration with EncodeToken

This changes allows the first token encoded to be a xml declaration. A ProcInst with target of xml. Any other ProcInst after that with a target of xml will fail

Fixes #7380.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/72410043

10 years agoA+C: Jason Del Ponte (individual CLA)
Russ Cox [Tue, 13 May 2014 03:34:27 +0000 (23:34 -0400)]
A+C: Jason Del Ponte (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/100410045

10 years agomime/multipart: add NewReader example
Brad Fitzpatrick [Tue, 13 May 2014 03:26:27 +0000 (20:26 -0700)]
mime/multipart: add NewReader example

Fixes #7888

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/100420043

10 years agocmd/go: fix 'go test foo_test.go'
Russ Cox [Tue, 13 May 2014 00:45:31 +0000 (20:45 -0400)]
cmd/go: fix 'go test foo_test.go'

Fixes race build.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/100410044

10 years agocmd/gc: fix liveness vs regopt mismatch for input variables
Russ Cox [Mon, 12 May 2014 21:19:02 +0000 (17:19 -0400)]
cmd/gc: fix liveness vs regopt mismatch for input variables

The inputs to a function are marked live at all times in the
liveness bitmaps, so that the garbage collector will not free
the things they point at and reuse the pointers, so that the
pointers shown in stack traces are guaranteed not to have
been recycled.

Unfortunately, no one told the register optimizer that the
inputs need to be preserved at all call sites. If a function
is done with a particular input value, the optimizer will stop
preserving it across calls. For single-word values this just
means that the value recorded might be stale. For multi-word
values like slices, the value recorded could be only partially stale:
it can happen that, say, the cap was updated but not the len,
or that the len was updated but not the base pointer.
Either of these possibilities (and others) would make the
garbage collector misinterpret memory, leading to memory
corruption.

This came up in a real program, in which the garbage collector's
'slice len ≤ slice cap' check caught the inconsistency.

Fixes #7944.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr
https://golang.org/cl/100370045

10 years agocmd/gc: alias more variables during register allocation
Josh Bleecher Snyder [Mon, 12 May 2014 21:10:36 +0000 (17:10 -0400)]
cmd/gc: alias more variables during register allocation

This is joint work with Daniel Morsing.

In order for the register allocator to alias two variables, they must have the same width, stack offset, and etype. Code generation was altering a variable's etype in a few places. This prevented the variable from being moved to a register, which in turn prevented peephole optimization. This failure to alias was very common, with almost 23,000 instances just running make.bash.

This phenomenon was not visible in the register allocation debug output because the variables that failed to alias had the same name. The debugging-only change to bits.c fixes this by printing the variable number with its name.

This CL fixes the source of all etype mismatches for 6g, all but one case for 8g, and depressingly few cases for 5g. (I believe that extending CL 6819083 to 5g is a prerequisite.) Fixing the remaining cases in 8g and 5g is work for the future.

The etype mismatch fixes are:

* [gc] Slicing changed the type of the base pointer into a uintptr in order to perform arithmetic on it. Instead, support addition directly on pointers.

* [*g] OSPTR was giving type uintptr to slice base pointers; undo that. This arose, for example, while compiling copy(dst, src).

* [8g] 64 bit float conversion was assigning int64 type during codegen, overwriting the existing uint64 type.

Note that some etype mismatches are appropriate, such as a struct with a single field or an array with a single element.

With these fixes, the number of registerizations that occur while running make.bash for 6g increases ~10%. Hello world binary size shrinks ~1.5%. Running all benchmarks in the standard library show performance improvements ranging from nominal to substantive (>10%); a full comparison using 6g on my laptop is available at https://gist.github.com/josharian/8f9b5beb46667c272064. The microbenchmarks must be taken with a grain of salt; see issue 7920. The few benchmarks that show real regressions are likely due to issue 7920. I manually examined the generated code for the top few regressions and none had any assembly output changes. The few benchmarks that show extraordinary improvements are likely also due to issue 7920.

Performance results from 8g appear similar to 6g.

5g shows no performance improvements. This is not surprising, given the discussion above.

Update #7316

LGTM=rsc
R=rsc, daniel.morsing, bradfitz
CC=dave, golang-codereviews
https://golang.org/cl/91850043

10 years agocmd/go: detect import cycle caused by test code
Russ Cox [Mon, 12 May 2014 20:52:55 +0000 (16:52 -0400)]
cmd/go: detect import cycle caused by test code

The runtime was detecting the cycle already,
but we can give a better error without even
building the binary.

Fixes #7789.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96290043

10 years agocmd/go: link SWIG objects directly rather than using a shared library
Ian Lance Taylor [Mon, 12 May 2014 19:43:51 +0000 (12:43 -0700)]
cmd/go: link SWIG objects directly rather than using a shared library

This change requires using SWIG version 3.0 or later.  Earlier
versions of SWIG do not generate the pragmas required to use
the external linker.

Fixes #7155.
Fixes #7156.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/97120046

10 years agocmd/gc: fix escape analysis for slice of array
Russ Cox [Mon, 12 May 2014 18:45:05 +0000 (14:45 -0400)]
cmd/gc: fix escape analysis for slice of array

Fixes #7931.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100390044

10 years agonet/http: fix flaky test
Fabrizio Milo [Mon, 12 May 2014 16:37:36 +0000 (09:37 -0700)]
net/http: fix flaky test

Prevent idle transport on race condition.

Fixes #7847

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96230044

10 years agoA+C: Fabrizio Milo (individual CLA)
Brad Fitzpatrick [Mon, 12 May 2014 16:33:48 +0000 (09:33 -0700)]
A+C: Fabrizio Milo (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/100390045

10 years agocmd/gc: record line number for auto-generated wrappers as <autogenerated>:1
Russ Cox [Mon, 12 May 2014 15:59:55 +0000 (11:59 -0400)]
cmd/gc: record line number for auto-generated wrappers as <autogenerated>:1

Before we used line 1 of the first source file.
This should be clearer.

Fixes #4388.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92250044

10 years agoundo CL 92210044 / 5cb21eee2d35
Brad Fitzpatrick [Mon, 12 May 2014 15:48:19 +0000 (08:48 -0700)]
undo CL 92210044 / 5cb21eee2d35

<enter reason for undo>

««« original CL description
net: make use of SO_LINGER_SEC on darwin

Fixes #7971.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92210044
»»»

TBR=iant
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/96220049

10 years agonet: make use of SO_LINGER_SEC on darwin
Mikio Hara [Mon, 12 May 2014 15:38:36 +0000 (00:38 +0900)]
net: make use of SO_LINGER_SEC on darwin

Fixes #7971.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92210044

10 years agocmd/go: better error for install of 'test-only' package
Russ Cox [Mon, 12 May 2014 15:04:28 +0000 (11:04 -0400)]
cmd/go: better error for install of 'test-only' package

Fixes #7915.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96210044

10 years agoruntime: add copy of math.sqrt for use by arm softfloat
Russ Cox [Mon, 12 May 2014 14:55:33 +0000 (10:55 -0400)]
runtime: add copy of math.sqrt for use by arm softfloat

If it's not used (such as on other systems or if softfloat
is disabled) the linker will discard it.

The alternative is to teach cmd/go that every binary
depends on math implicitly on arm. I started down that
path but it's too scary. If we're going to get dependencies
right we should get dependencies right.

Fixes #6994.

LGTM=bradfitz, dave
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/95290043

10 years agocmd/objdump: works with windows pe executables now
Alex Brainman [Mon, 12 May 2014 07:00:57 +0000 (17:00 +1000)]
cmd/objdump: works with windows pe executables now

Most code is copy from addr2line change 01dd67e5827f

Update #7406
Fixes #7937

LGTM=iant
R=golang-codereviews, iant, 0intro
CC=golang-codereviews
https://golang.org/cl/95090044

10 years agounicode: fix doc typo
Péter Surányi [Mon, 12 May 2014 05:06:00 +0000 (22:06 -0700)]
unicode: fix doc typo

LGTM=robert.hencke, iant
R=golang-codereviews, robert.hencke, iant
CC=golang-codereviews
https://golang.org/cl/96230043

10 years agocmd/nm: do not write to GOROOT testdata directories during TestNM
Alex Brainman [Sun, 11 May 2014 23:26:05 +0000 (09:26 +1000)]
cmd/nm: do not write to GOROOT testdata directories during TestNM

LGTM=bradfitz
R=bradfitz, 0intro
CC=golang-codereviews
https://golang.org/cl/95280043

10 years agonet/rpc: do not leak client socket on closed connection
David Crawshaw [Sun, 11 May 2014 21:46:44 +0000 (14:46 -0700)]
net/rpc: do not leak client socket on closed connection

Fixes #6897.

LGTM=bradfitz
R=golang-codereviews, bradfitz, r, rsc
CC=golang-codereviews
https://golang.org/cl/91230045

10 years agoC: add another email address for David Crawshaw
Brad Fitzpatrick [Sun, 11 May 2014 21:46:29 +0000 (14:46 -0700)]
C: add another email address for David Crawshaw

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/99180043

10 years agocmd/go: simplify code, reduce allocations.
Dmitri Shuralyov [Sun, 11 May 2014 01:06:58 +0000 (18:06 -0700)]
cmd/go: simplify code, reduce allocations.

This is a trivial change to make use of an existing `nl` byte slice
containing a single '\n' character. It's already declared and
used in another place in this file, so it might as well be used
in the other location instead of
a new slice literal. There should be no change in behavior,
aside from potentially less allocations.

This is my first CL, so I wanted to use a simple, hopefully non-controversial,
minor improvement to get more comfortable with golang contribution process.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97280043

10 years agocmd/go: remove merge markers
Robert Hencke [Sat, 10 May 2014 17:41:05 +0000 (13:41 -0400)]
cmd/go: remove merge markers

LGTM=minux.ma
R=cespare, rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/96210043

10 years agocmd/addr2line: accept optional "0x" prefix for addresses.
Shenghou Ma [Sat, 10 May 2014 17:35:40 +0000 (13:35 -0400)]
cmd/addr2line: accept optional "0x" prefix for addresses.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/91250043

10 years agoundo CL 100330043 / e4248ed0037c
Brad Fitzpatrick [Sat, 10 May 2014 00:31:35 +0000 (17:31 -0700)]
undo CL 100330043 / e4248ed0037c

<enter reason for undo>

««« original CL description
runtime/race: fix the link for the race detector.

LGTM=bradfitz
R=golang-dev, bradfitz
CC=golang-codereviews
https://golang.org/cl/100330043

»»»

TBR=minux
R=minux.ma
CC=golang-codereviews
https://golang.org/cl/96200044

10 years agoruntime/race: fix the link for the race detector.
Bill Neubauer [Fri, 9 May 2014 23:33:23 +0000 (16:33 -0700)]
runtime/race: fix the link for the race detector.

LGTM=bradfitz
R=golang-dev, bradfitz
CC=golang-codereviews
https://golang.org/cl/100330043

10 years agoruntime: be a lot more lenient on smhasher avalanche test.
Keith Randall [Fri, 9 May 2014 22:50:57 +0000 (15:50 -0700)]
runtime: be a lot more lenient on smhasher avalanche test.

Fixes #7943

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98170043

10 years agonet/url: correct documentation of Values.Add
Ian Lance Taylor [Fri, 9 May 2014 22:49:21 +0000 (15:49 -0700)]
net/url: correct documentation of Values.Add

Fixes #7816.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98160043

10 years agobytes: fix typos
Rui Ueyama [Fri, 9 May 2014 22:13:42 +0000 (07:13 +0900)]
bytes: fix typos

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/94240045

10 years agotest/bench/shootout: support windows
ChaiShushan [Fri, 9 May 2014 21:34:50 +0000 (14:34 -0700)]
test/bench/shootout: support windows

1. fix executable extension (a.out -> a.exe).
2. fix pthread build error on mingw
3. if depends lib messing, skip the test

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100210043

10 years agoencoding/binary: document that Read requires exported struct fields
Ian Lance Taylor [Fri, 9 May 2014 21:19:21 +0000 (14:19 -0700)]
encoding/binary: document that Read requires exported struct fields

Add a test for the current behaviour.

Fixes #7482.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/95160043

10 years agocmd/go: accept build flags in clean and list
Russ Cox [Fri, 9 May 2014 20:32:38 +0000 (16:32 -0400)]
cmd/go: accept build flags in clean and list

list has been adding them one at a time haphazardly
(race and tags were there and documented; compiler
was there and undocumented).

clean -i needs -compiler in order to clean the
installed targets for alternate compilers.

Fixes #7302.

While we're here, tweak the language in the 'go get' docs
about build flags.

Fixes #7807.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/99130043

10 years agomath/cmplx: specify which square root Sqrt returns
Russ Cox [Fri, 9 May 2014 20:04:03 +0000 (16:04 -0400)]
math/cmplx: specify which square root Sqrt returns

Fixes #7851.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93200043

10 years agocmd/gc: disable link-time copying of un-Go-initialized globals
Russ Cox [Fri, 9 May 2014 20:03:44 +0000 (16:03 -0400)]
cmd/gc: disable link-time copying of un-Go-initialized globals

If you write:

        var x = 3

then the compiler arranges for x to be initialized in the linker
with an actual 3 from the data segment, rather than putting
x in the bss and emitting init-time "x = 3" assignment code.

If you write:

        var y = x
        var x = 3

then the compiler is clever and treats this the same as if
the code said 'y = 3': they both end up in the data segment
with no init-time assignments.

If you write

        var y = x
        var x int

then the compiler was treating this the same as if the
code said 'x = 0', making both x and y zero and avoiding
any init-time assignment.

This copying optimization to avoid init-time assignment of y
is incorrect if 'var x int' doesn't mean 'x = 0' but instead means
'x is initialized in C or assembly code'. The program ends up
with 'y = 0' instead of 'y = the value specified for x in that other code'.

Disable the propagation if there is no initializer for x.

This comes up in some uses of cgo, because cgo generates
Go globals that are initialized in accompanying C files.

Fixes #7665.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93200044

10 years agocrypto/aes: fix overrun in assembly encrypt/decrypt
Russ Cox [Fri, 9 May 2014 19:40:55 +0000 (15:40 -0400)]
crypto/aes: fix overrun in assembly encrypt/decrypt

Fixes #7928.

LGTM=bradfitz
R=golang-codereviews
CC=agl, bradfitz, golang-codereviews
https://golang.org/cl/91320043

10 years agocmd/gc: fix ... escape analysis bug
Russ Cox [Fri, 9 May 2014 19:40:45 +0000 (15:40 -0400)]
cmd/gc: fix ... escape analysis bug

If the ... element type contained no pointers,
then the escape analysis did not track the ... itself.
This manifested in an escaping ...byte being treated
as non-escaping.

Fixes #7934.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100310043

11 years agocmd/gc: don't give credit for NOPs during register allocation
Josh Bleecher Snyder [Fri, 9 May 2014 16:55:17 +0000 (09:55 -0700)]
cmd/gc: don't give credit for NOPs during register allocation

The register allocator decides which variables should be placed into registers by charging for each load/store and crediting for each use, and then selecting an allocation with minimal cost. NOPs will be eliminated, however, so using a variable in a NOP should not generate credit.

Issue 7867 arises from attempted registerization of multi-word variables because they are used in NOPs. By not crediting for that use, they will no longer be considered for registerization.

This fix could theoretically lead to better register allocation, but NOPs are rare relative to other instructions.

Fixes #7867.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/94810044

11 years agocmd/go: mark regexp as dependency of testmain
Robert Hencke [Fri, 9 May 2014 16:19:00 +0000 (12:19 -0400)]
cmd/go: mark regexp as dependency of testmain

Fixes #6844.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/97840043

11 years agotesting: write profiles on failure
Russ Cox [Fri, 9 May 2014 16:18:50 +0000 (12:18 -0400)]
testing: write profiles on failure

Fixes #7901.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/90930044

11 years agonet: drop flakey TestDialFailPDLeak
Mikio Hara [Fri, 9 May 2014 00:38:29 +0000 (09:38 +0900)]
net: drop flakey TestDialFailPDLeak

TestDialFailPDLeak was created for testing runtime-integrated netwrok
poller stuff and used during Go 1.2 development cycle. Unfortunately
it's still flakey because it depends on MemStats of runtime, not
pollcache directly, and MemStats accounts and revises its own stats
occasionally.

For now the codepaths related to runtime-intergrated network poller
are pretty stable, so removing this test case never suffers us.

Fixes #6553.

LGTM=josharian, iant
R=iant, josharian
CC=golang-codereviews
https://golang.org/cl/98080043

11 years agoruntime: write memory profile statistics to the heap dump.
Keith Randall [Thu, 8 May 2014 15:35:49 +0000 (08:35 -0700)]
runtime: write memory profile statistics to the heap dump.

LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/97010043

11 years agoencoding/json: add example for Indent, clarify the docs.
Stephen McQuay [Thu, 8 May 2014 06:52:36 +0000 (16:52 +1000)]
encoding/json: add example for Indent, clarify the docs.

There was confusion in the behavior of json.Indent; This change
attempts to clarify the behavior by providing a bit more verbiage
to the documentation as well as provide an example function.

Fixes #7821.

LGTM=robert.hencke, adg
R=golang-codereviews, minux.ma, bradfitz, aram, robert.hencke, r, adg
CC=golang-codereviews
https://golang.org/cl/97840044

11 years agocmd/objdump: actually accept hex address without "0x" prefix.
Shenghou Ma [Thu, 8 May 2014 05:25:56 +0000 (01:25 -0400)]
cmd/objdump: actually accept hex address without "0x" prefix.
Fixes #7936.

LGTM=alex.brainman, bradfitz, iant
R=golang-codereviews, alex.brainman, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/100060043

11 years agodoc/install.html: update wrt to OS and compiler support.
Shenghou Ma [Thu, 8 May 2014 05:25:28 +0000 (01:25 -0400)]
doc/install.html: update wrt to OS and compiler support.
Update #7188
Fixes #7894.

LGTM=alex.brainman, bradfitz, r
R=golang-codereviews, alex.brainman, mikioh.mikioh, gobot, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/95870043

11 years agoruntime: use duff zero and copy to initialize memory
Keith Randall [Wed, 7 May 2014 20:17:10 +0000 (13:17 -0700)]
runtime: use duff zero and copy to initialize memory

benchmark                 old ns/op     new ns/op     delta
BenchmarkCopyFat512       1307          329           -74.83%
BenchmarkCopyFat256       666           169           -74.62%
BenchmarkCopyFat1024      2617          671           -74.36%
BenchmarkCopyFat128       343           89.0          -74.05%
BenchmarkCopyFat64        182           48.9          -73.13%
BenchmarkCopyFat32        103           28.8          -72.04%
BenchmarkClearFat128      102           46.6          -54.31%
BenchmarkClearFat512      344           167           -51.45%
BenchmarkClearFat64       50.5          26.5          -47.52%
BenchmarkClearFat256      147           87.2          -40.68%
BenchmarkClearFat32       22.7          16.4          -27.75%
BenchmarkClearFat1024     511           662           +29.55%

Fixes #7624

LGTM=rsc
R=golang-codereviews, khr, bradfitz, josharian, dave, rsc
CC=golang-codereviews
https://golang.org/cl/92760044

11 years agodatabase/sql: fix accounting of open connections
Brad Fitzpatrick [Wed, 7 May 2014 18:54:29 +0000 (11:54 -0700)]
database/sql: fix accounting of open connections

Existing test TestMaxOpenConns was failing occasionally, especially
with higher values of GOMAXPROCS.

Fixes #7532

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95130043

11 years agospec: several clarifications to language on channels
Robert Griesemer [Wed, 7 May 2014 17:40:39 +0000 (10:40 -0700)]
spec: several clarifications to language on channels

- A channel may be used between any number of goroutines,
  not just two.
- Replace "passing a value" (which is not further defined)
  by "sending and receiving a value".
- Made syntax production more symmetric.
- Talk about unbuffered channels before buffered channels.
- Clarify what the comma,ok receive values mean (issue 7785).

Not a language change.

Fixes #7785.

LGTM=rsc, r, iant
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/94030045

11 years agospec: remove evaluation order inconsistency
Robert Griesemer [Wed, 7 May 2014 15:50:52 +0000 (08:50 -0700)]
spec: remove evaluation order inconsistency

This is a clarification of what happens already.
Not a language change.

Fixes #7137.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/96000044

11 years agospec: clarify type properties
Robert Griesemer [Wed, 7 May 2014 15:42:08 +0000 (08:42 -0700)]
spec: clarify type properties

If the underlying type of a type T is a boolean, numeric,
or string type, then T is also a boolean, numeric, or
string type, respectively.

Not a language change.

Fixes #7551.

LGTM=iant, rsc, robert.hencke, r
R=r, rsc, iant, ken, robert.hencke
CC=golang-codereviews
https://golang.org/cl/100130044

11 years agoruntime: optimize markspan
Dmitriy Vyukov [Wed, 7 May 2014 15:32:34 +0000 (19:32 +0400)]
runtime: optimize markspan
Increases throughput by 2x on a memory hungry program on 8-node NUMA machine.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100230043

11 years agodoc: replace absolute links to golang.org with relative links
Dmitriy Vyukov [Wed, 7 May 2014 14:49:13 +0000 (18:49 +0400)]
doc: replace absolute links to golang.org with relative links
Currently tip.golang.org leads to golang.org and
local godoc also leads to golang.org (when you don't have internet connectivity).

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/100200043

11 years agoruntime: fix bug in cpu profiler
Dmitriy Vyukov [Wed, 7 May 2014 14:48:14 +0000 (18:48 +0400)]
runtime: fix bug in cpu profiler
Number of lost samples was overcounted (never reset).
Also remove unused variable (it's trivial to restore it for debugging if needed).

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, rsc
https://golang.org/cl/96060043

11 years agonet/mail: propagate unsupported charset error
David Crawshaw [Wed, 7 May 2014 09:58:36 +0000 (05:58 -0400)]
net/mail: propagate unsupported charset error

Fixes #6807.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95060043

11 years agorace.bash,race.bat: unset GOROOT_FINAL during tests
Alex Brainman [Wed, 7 May 2014 06:34:21 +0000 (16:34 +1000)]
race.bash,race.bat: unset GOROOT_FINAL during tests

Just like run.* scripts do.
Fixes race build.

LGTM=dave, dvyukov
R=dvyukov, dave
CC=golang-codereviews
https://golang.org/cl/98980043

11 years agoC: Patrick Riley (Google CLA)
Nigel Tao [Wed, 7 May 2014 02:08:46 +0000 (22:08 -0400)]
C: Patrick Riley (Google CLA)

LGTM=iant
R=dsymonds, iant
CC=golang-codereviews, pfr
https://golang.org/cl/98970045

11 years agocmd/addr2line: skip broken TestAddr2Line on plan9 (fixes build)
Alex Brainman [Wed, 7 May 2014 01:58:25 +0000 (11:58 +1000)]
cmd/addr2line: skip broken TestAddr2Line on plan9 (fixes build)

Update #7947

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/100180043

11 years agodoc/go1.3.html: mention go build -i
David Crawshaw [Wed, 7 May 2014 01:10:36 +0000 (21:10 -0400)]
doc/go1.3.html: mention go build -i

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/95010049

11 years agocmd/addr2line: works with windows pe executables now
Alex Brainman [Wed, 7 May 2014 00:16:55 +0000 (10:16 +1000)]
cmd/addr2line: works with windows pe executables now

Update #7406
Fixes #7899

LGTM=bradfitz
R=golang-codereviews, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/96960043

11 years agocmd/go: add go build -i
David Crawshaw [Tue, 6 May 2014 13:12:15 +0000 (09:12 -0400)]
cmd/go: add go build -i

Fixes #7071.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93770044

11 years agotest: add test that gccgo compiled incorrectly
Ian Lance Taylor [Tue, 6 May 2014 13:01:38 +0000 (09:01 -0400)]
test: add test that gccgo compiled incorrectly

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/94100045

11 years agocmd/ld: correct pe section number in symbol table
Alex Brainman [Tue, 6 May 2014 01:40:43 +0000 (11:40 +1000)]
cmd/ld: correct pe section number in symbol table

Update #7899

LGTM=iant
R=golang-codereviews, rsc, iant
CC=golang-codereviews
https://golang.org/cl/97920044

11 years agosyscall: add missing TIOCGSID for openbsd/386
Mikio Hara [Mon, 5 May 2014 22:22:10 +0000 (07:22 +0900)]
syscall: add missing TIOCGSID for openbsd/386

The previous syscall constants regeneration on openbsd was conducted
with OpenBSD current 3 months ago and it missed updating openbsd/386.
This CL adds TIOCGSID for fixing the inconsistency between opensbd/amd64
and openbsd/386.

Update #7049

LGTM=iant
R=jsing, rsc, iant
CC=golang-codereviews
https://golang.org/cl/96960044

11 years agodoc: refer to wiki page for downloads
Andrew Gerrand [Mon, 5 May 2014 21:31:26 +0000 (14:31 -0700)]
doc: refer to wiki page for downloads

We will serve downloads from here until we work out a better plan.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/95980044

11 years agoC: Sean Burford (Google CLA)
Adam Langley [Mon, 5 May 2014 18:34:03 +0000 (11:34 -0700)]
C: Sean Burford (Google CLA)

R=gobot
CC=golang-codereviews
https://golang.org/cl/97070043

11 years agotag go1.2.2
Andrew Gerrand [Mon, 5 May 2014 17:45:56 +0000 (10:45 -0700)]
tag go1.2.2

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96000043

11 years agodoc: document go1.2.2
Andrew Gerrand [Mon, 5 May 2014 16:56:26 +0000 (09:56 -0700)]
doc: document go1.2.2

R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/100110043

11 years ago archive/zip: Document ModTime is always UTC
Tyler Bunnell [Mon, 5 May 2014 03:00:47 +0000 (23:00 -0400)]
  archive/zip: Document ModTime is always UTC

Fixes #7592

LGTM=robert.hencke, adg
R=golang-codereviews, robert.hencke, gobot, adg
CC=golang-codereviews
https://golang.org/cl/90810043

11 years agostd lib: fix various typos in comments
Robert Griesemer [Fri, 2 May 2014 20:17:55 +0000 (13:17 -0700)]
std lib: fix various typos in comments

Where the spelling changed from British to
US norm (e.g., optimise -> optimize) it follows
the style in that file.

LGTM=adonovan
R=golang-codereviews, adonovan
CC=golang-codereviews
https://golang.org/cl/96980043

11 years agoA+C: David Calavera (individual CLA)
Adam Langley [Fri, 2 May 2014 17:54:50 +0000 (10:54 -0700)]
A+C: David Calavera (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/90970048

11 years agoruntime: fix bug in GOTRACEBACK=crash causing suppression of core dumps.
Alan Donovan [Fri, 2 May 2014 17:06:58 +0000 (13:06 -0400)]
runtime: fix bug in GOTRACEBACK=crash causing suppression of core dumps.

Because gotraceback is called early and often, its cache commits to the value of getenv("GOTRACEBACK") before getenv is even ready.  So now we reset its cache once getenv becomes ready.  Panicking programs now dump core again.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/97800045

11 years agoruntime: do not set m->locks around memory allocation
Dmitriy Vyukov [Fri, 2 May 2014 16:39:25 +0000 (17:39 +0100)]
runtime: do not set m->locks around memory allocation
If slice append is the only place where a program allocates,
then it will consume all available memory w/o triggering GC.
This was demonstrated in the issue.
Fixes #7922.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, iant, khr
https://golang.org/cl/91010048

11 years agoruntime: make MemStats.LastGC Unix time again
Dmitriy Vyukov [Fri, 2 May 2014 16:32:42 +0000 (17:32 +0100)]
runtime: make MemStats.LastGC Unix time again
The monotonic clock patch changed all runtime times
to abstract monotonic time. As the result user-visible
MemStats.LastGC become monotonic time as well.
Restore Unix time for LastGC.

This is the simplest way to expose time.now to runtime that I found.
Another option would be to change time.now to C called
int64 runtime.unixnanotime() and then express time.now in terms of it.
But this would require to introduce 2 64-bit divisions into time.now.
Another option would be to change time.now to C called
void runtime.unixnanotime1(struct {int64 sec, int32 nsec} *now)
and then express both time.now and runtime.unixnanotime in terms of it.

Fixes #7852.

LGTM=minux.ma, iant
R=minux.ma, rsc, iant
CC=golang-codereviews
https://golang.org/cl/93720045

11 years agoos: cut limited read to 1 GB
Russ Cox [Fri, 2 May 2014 16:12:40 +0000 (12:12 -0400)]
os: cut limited read to 1 GB

If systems actually read that much, using 2GB-1 will
result in misaligned subsequent reads. Use 1GB instead,
which will certainly keep reads aligned and which is
plenty large enough.

Update #7812.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/94070044

11 years agohtml: fix small typo
Robert Hencke [Thu, 1 May 2014 20:29:34 +0000 (16:29 -0400)]
html: fix small typo

LGTM=dsymonds, adg, crawshaw, r, bradfitz, campoy, nigeltao, sameer, iant, robsc, djd, michael.j.fromberger, gmlewis, adonovan, rsc
R=golang-codereviews, dsymonds, adg, crawshaw, r, nigeltao, sameer, iant, robsc, djd, michael.j.fromberger, gmlewis, adonovan, rsc
CC=golang-codereviews
https://golang.org/cl/98880043

11 years agogo/build: add go1.3 release tag
Brad Fitzpatrick [Thu, 1 May 2014 16:16:03 +0000 (12:16 -0400)]
go/build: add go1.3 release tag

Fixes #7918

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/91980043

11 years agocmd/dist: permit go* tag in main branch when it includes "beta"
Andrew Gerrand [Thu, 1 May 2014 16:13:32 +0000 (12:13 -0400)]
cmd/dist: permit go* tag in main branch when it includes "beta"

This change allows us to give an hg tag such as "go1.3beta1" to
revisions in the main branch without breaking the build.

This is helpful for community members who want to build the beta
from source.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/90190044

11 years agoruntime: correctly type interface data.
Keith Randall [Thu, 1 May 2014 13:37:55 +0000 (09:37 -0400)]
runtime: correctly type interface data.

The backing memory for >1 word interfaces was being scanned
conservatively.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/94000043

11 years agocmd/go: test: clean up all temporary directories
Michael Fraenkel [Wed, 30 Apr 2014 17:03:38 +0000 (13:03 -0400)]
cmd/go: test: clean up all temporary directories

go test may call builder.init() multiple times which will create a new work directory.  The cleanup needs to hoist the current work directory.
Fixes #7904.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95900044

11 years agoA+C: Michael Fraenkel (individual CLA)
Ian Lance Taylor [Wed, 30 Apr 2014 16:59:33 +0000 (09:59 -0700)]
A+C: Michael Fraenkel (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/90950044