]> Cypherpunks repositories - gostls13.git/log
gostls13.git
12 years agonet, cmd/fix: add IPv6 scoped addressing zone to INET, INET6 address structs
Mikio Hara [Mon, 26 Nov 2012 15:45:42 +0000 (00:45 +0900)]
net, cmd/fix: add IPv6 scoped addressing zone to INET, INET6 address structs

This CL starts to introduce IPv6 scoped addressing capability
into the net package.

The Public API changes are:
+pkg net, type IPAddr struct, Zone string
+pkg net, type IPNet struct, Zone string
+pkg net, type TCPAddr struct, Zone string
+pkg net, type UDPAddr struct, Zone string

Update #4234.

R=rsc, bradfitz, iant
CC=golang-dev
https://golang.org/cl/6849045

12 years agoruntime: regenerate defs-files for freebsd
Mikio Hara [Mon, 26 Nov 2012 12:29:13 +0000 (21:29 +0900)]
runtime: regenerate defs-files for freebsd

R=minux.ma, jsing
CC=golang-dev
https://golang.org/cl/6855080

12 years agonet/http: clarify docs of ParseForm and mention ParseForm in docs for FormValue
Shenghou Ma [Mon, 26 Nov 2012 12:03:24 +0000 (20:03 +0800)]
net/http: clarify docs of ParseForm and mention ParseForm in docs for FormValue
while we're at it, also fix a return value stutter in ParseForm.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6847074

12 years agoruntime: implement SysUnused for netbsd
Joel Sing [Mon, 26 Nov 2012 11:34:01 +0000 (22:34 +1100)]
runtime: implement SysUnused for netbsd

R=golang-dev, bradfitz, minux.ma, dave
CC=golang-dev
https://golang.org/cl/6842081

12 years agoruntime: implement SysUnused for openbsd
Joel Sing [Mon, 26 Nov 2012 11:32:59 +0000 (22:32 +1100)]
runtime: implement SysUnused for openbsd

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6854079

12 years agocmd/gc: check malloc return value
Joel Sing [Mon, 26 Nov 2012 11:03:31 +0000 (22:03 +1100)]
cmd/gc: check malloc return value

Check the return value from malloc - do not assume that we were
allocated memory just because we asked for it.

Update #4415.

R=minux.ma, daniel.morsing, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6782100

12 years agonet: never return -1 bytes read from netFD.Read
Dave Cheney [Sun, 25 Nov 2012 23:59:43 +0000 (10:59 +1100)]
net: never return -1 bytes read from netFD.Read

If the a network read would block, and a packet arrived just before the timeout expired, then the number of bytes from the previous (blocking) read, -1, would be returned.

This change restores the previous logic, where n would be unconditionally set to 0 if err != nil, but was skipped due to a change in CL 6851096.

The test for this change is CL 6851061.

R=bradfitz, mikioh.mikioh, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852085

12 years agonet/http/httptest: protect against port reuse
Brad Fitzpatrick [Sun, 25 Nov 2012 23:23:20 +0000 (15:23 -0800)]
net/http/httptest: protect against port reuse

Should make BSDs more reliable. (they seem to reuse ports
quicker than Linux)

Tested by hand with local modifications to force reuse on
Linux. (net/http tests failed before, pass now) Details in the
issue.

Fixes #4436

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6847101

12 years agobytes, strings: fix Reader WriteTo return value on 0 bytes copied
Brad Fitzpatrick [Sun, 25 Nov 2012 17:04:13 +0000 (09:04 -0800)]
bytes, strings: fix Reader WriteTo return value on 0 bytes copied

Fixes #4421

R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083

12 years agoruntime: fix madvise for freebsd/amd64
Mikio Hara [Sun, 25 Nov 2012 09:46:41 +0000 (18:46 +0900)]
runtime: fix madvise for freebsd/amd64

Make use of carry clear condition instead of low or same.

R=minux.ma, jsing, dave
CC=golang-dev
https://golang.org/cl/6844080

12 years agonet: add unit tests for read/write deadlines
Dmitriy Vyukov [Sun, 25 Nov 2012 09:27:32 +0000 (13:27 +0400)]
net: add unit tests for read/write deadlines
The tests verify that deadlines are "persistent",
read/write deadlines do not interfere, can be reset,
read deadline can be set with both SetDeadline()
and SetReadDeadline(), etc.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6850070

12 years agotest: add bug469, a case where gccgo gaves an incorrect error
Ian Lance Taylor [Sun, 25 Nov 2012 00:53:08 +0000 (16:53 -0800)]
test: add bug469, a case where gccgo gaves an incorrect error

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6856084

12 years agotime: add Now()/UnixNano() malloc tests
Dave Cheney [Sun, 25 Nov 2012 00:29:06 +0000 (11:29 +1100)]
time: add Now()/UnixNano() malloc tests

The fix for issue 4403 may include more calls to time.Now().UnixNano(). I was concerned that if this function allocated it would cause additional garbage on the heap. It turns out that it doesn't, which is a nice surprise.

Also add benchmark for Now().UnixNano()

R=bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/6849097

12 years agonet: do not start io if deadline has passed
Alex Brainman [Sat, 24 Nov 2012 23:02:57 +0000 (10:02 +1100)]
net: do not start io if deadline has passed

R=golang-dev, mikioh.mikioh, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6851098

12 years agohttp/transport.go: trivial comment error.
Caine Tighe [Sat, 24 Nov 2012 21:08:17 +0000 (05:08 +0800)]
http/transport.go: trivial comment error.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6856078

12 years agocmd/go: fix typo in comment
Ian Lance Taylor [Sat, 24 Nov 2012 19:25:17 +0000 (11:25 -0800)]
cmd/go: fix typo in comment

Fixes #4432.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6858064

12 years agonet: check read and write deadlines before doing syscalls
Brad Fitzpatrick [Sat, 24 Nov 2012 06:15:26 +0000 (22:15 -0800)]
net: check read and write deadlines before doing syscalls

Otherwise a fast sender or receiver can make sockets always
readable or writable, preventing deadline checks from ever
occuring.

Update #4191 (fixes it with other CL, coming separately)
Fixes #4403

R=golang-dev, alex.brainman, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6851096

12 years agoruntime: implement runtime.SysUnused on FreeBSD
John Graham-Cumming [Sat, 24 Nov 2012 04:55:19 +0000 (15:55 +1100)]
runtime: implement runtime.SysUnused on FreeBSD

madvise was missing so implement it in assembler. This change
needs to be extended to the other BSD variantes (Net and Open)

Without this change the scavenger will attempt to pass memory back
to the operating system when it has become idle, but the memory is
not returned and for long running Go processes the total memory used
can grow until OOM occurs.

I have only been able to test the code on FreeBSD AMD64. The ARM
platforms needs testing.

R=golang-dev, mikioh.mikioh, dave, jgc, minux.ma
CC=golang-dev
https://golang.org/cl/6850081

12 years agonet/http/httptest: fix possible race on historyListener.history
Dave Cheney [Sat, 24 Nov 2012 04:50:43 +0000 (15:50 +1100)]
net/http/httptest: fix possible race on historyListener.history

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6845077

12 years agoA+C: Add John Graham-Cumming (Individual CLA)
Brad Fitzpatrick [Sat, 24 Nov 2012 04:30:03 +0000 (20:30 -0800)]
A+C: Add John Graham-Cumming (Individual CLA)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846095

12 years agocmd/go: fix data race on cgoLibGccFile
Shenghou Ma [Fri, 23 Nov 2012 11:58:46 +0000 (19:58 +0800)]
cmd/go: fix data race on cgoLibGccFile
Fixes #4426.

R=dvyukov
CC=golang-dev
https://golang.org/cl/6851099

12 years agocmd/go: show -race if necessary when giving "go test -i" hint
Shenghou Ma [Fri, 23 Nov 2012 11:29:22 +0000 (19:29 +0800)]
cmd/go: show -race if necessary when giving "go test -i" hint

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6851100

12 years agospec: be clearer about the scope of a package name
Robert Griesemer [Wed, 21 Nov 2012 22:40:50 +0000 (14:40 -0800)]
spec: be clearer about the scope of a package name

We have the notion of a PackageName, not package identifier.
As is, it could construed that imports that rename a package
don't have an "imported package identifier" but a local one.

R=r, rsc, iant, ken, dsymonds
CC=golang-dev
https://golang.org/cl/6858049

12 years agodashboard/builder: pass $CC to builder if set
Dave Cheney [Wed, 21 Nov 2012 21:41:02 +0000 (08:41 +1100)]
dashboard/builder: pass $CC to builder if set

R=adg, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6843068

12 years agonet/http: use runtime.Stack instead of runtime/debug.Stack
Dave Cheney [Wed, 21 Nov 2012 21:18:45 +0000 (08:18 +1100)]
net/http: use runtime.Stack instead of runtime/debug.Stack

Fixes #4060.

2012/11/21 19:51:34 http: panic serving 127.0.0.1:47139: Kaaarn!
goroutine 7 [running]:
net/http.func·004(0x7f330807ffb0, 0x7f330807f100)
/home/dfc/go/src/pkg/net/http/server.go:615 +0xa7
----- stack segment boundary -----
main.(*httpHandler).ServeHTTP()
/home/dfc/src/httppanic.go:16 +0x53
net/http.(*conn).serve(0xc200090240, 0x0)
/home/dfc/go/src/pkg/net/http/server.go:695 +0x55d
created by net/http.(*Server).Serve
/home/dfc/go/src/pkg/net/http/server.go:1119 +0x36d

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846085

12 years agocmd/cgo: fix alignment of bool.
Vladimir Nikishenko [Wed, 21 Nov 2012 21:04:38 +0000 (13:04 -0800)]
cmd/cgo: fix alignment of bool.
Fixes #4417.

R=golang-dev, iant, minux.ma, bradfitz
CC=golang-dev, vova616
https://golang.org/cl/6782097

12 years agoall: fix the the typos
Shenghou Ma [Wed, 21 Nov 2012 18:58:24 +0000 (02:58 +0800)]
all: fix the the typos
Fixes #4420.

R=golang-dev, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854080

12 years agoA+C: Add Vladimir Nikishenko (Individual CLA)
Brad Fitzpatrick [Wed, 21 Nov 2012 18:40:14 +0000 (10:40 -0800)]
A+C: Add Vladimir Nikishenko (Individual CLA)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6845073

12 years agoruntime: update openbsd runtime to use new tfork syscall
Joel Sing [Wed, 21 Nov 2012 14:25:53 +0000 (01:25 +1100)]
runtime: update openbsd runtime to use new tfork syscall

Update OpenBSD runtime to use the new version of the sys___tfork
syscall and switch TLS initialisation from sys_arch to sys___set_tcb
(note that both of these syscalls are available in OpenBSD 5.2).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6843058

12 years agocmd/8g: fix erroneous LEAL nil.
Rémy Oudompheng [Wed, 21 Nov 2012 07:39:45 +0000 (08:39 +0100)]
cmd/8g: fix erroneous LEAL nil.

Fixes #4399.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6845053

12 years agonet: remove another unguarded sysfile == nil check
Dave Cheney [Wed, 21 Nov 2012 04:04:22 +0000 (15:04 +1100)]
net: remove another unguarded sysfile == nil check

Putting aside the unguarded access to fd.sysfile, the condition will never be true as fd.incref above handles the closed condition.

R=mikioh.mikioh, dvyukov
CC=golang-dev
https://golang.org/cl/6845062

12 years agonet/http, net/http/httputil: fix TestChunkReaderAllocs failure when GOMAXPROCS > 1
Shenghou Ma [Tue, 20 Nov 2012 18:18:34 +0000 (02:18 +0800)]
net/http, net/http/httputil: fix TestChunkReaderAllocs failure when GOMAXPROCS > 1

R=fullung, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6846081

12 years agoexp/types: don't test importing types if using gccgo
Ian Lance Taylor [Tue, 20 Nov 2012 05:56:24 +0000 (21:56 -0800)]
exp/types: don't test importing types if using gccgo

The exp/types packages does not support the gccgo export data
format.  At some point it should, but not yet.

R=gri, bradfitz, r, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6854068

12 years agonet/http/cgi: another attempt to fix windows tests
Alex Brainman [Tue, 20 Nov 2012 05:24:12 +0000 (16:24 +1100)]
net/http/cgi: another attempt to fix windows tests

Also enables TestDirWindows test on windows.

Fixes #4401.

R=golang-dev, bradfitz
CC=golang-dev, krautz
https://golang.org/cl/6847072

12 years agonet/http: remove more garbage from chunk reading
Brad Fitzpatrick [Tue, 20 Nov 2012 03:50:42 +0000 (19:50 -0800)]
net/http: remove more garbage from chunk reading

Noticed this while closing tabs. Yesterday I thought I could
ignore this garbage and hope that a fix for issue 2205 handled
it, but I just realized that's the opposite case,
string->[]byte, whereas this is []byte->string.  I'm having a
hard time convincing myself that an Issue 2205-style fix with
static analysis and faking a string header would be safe in
all cases without violating the memory model (callee assumes
frozen memory; are there non-racy ways it could keep being
modified?)

R=dsymonds
CC=dave, gobot, golang-dev
https://golang.org/cl/6850067

12 years agomime/multipart: transparently decode quoted-printable transfer encoding
Brad Fitzpatrick [Tue, 20 Nov 2012 03:50:19 +0000 (19:50 -0800)]
mime/multipart: transparently decode quoted-printable transfer encoding

Fixes #4411

R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/6854067

12 years agocmd/api: speed up API check by 2x, caching parser.ParseFile calls
Brad Fitzpatrick [Mon, 19 Nov 2012 21:50:20 +0000 (13:50 -0800)]
cmd/api: speed up API check by 2x, caching parser.ParseFile calls

Saves 5 seconds on my machine. If Issue 4380 is fixed this
clone can be removed.

Update #4380

R=golang-dev, remyoudompheng, minux.ma, gri
CC=golang-dev
https://golang.org/cl/6845058

12 years agogo/printer: simply ignore filename changes in position information
Robert Griesemer [Mon, 19 Nov 2012 21:23:32 +0000 (13:23 -0800)]
go/printer: simply ignore filename changes in position information

There's no good reason to make any printer state adjustments
simply because the file name in node position information has
changed. Eliminate the relevant code.

R=r
CC=golang-dev
https://golang.org/cl/6856054

12 years agodoc/articles/wiki: fix racy test
Brad Fitzpatrick [Mon, 19 Nov 2012 20:36:15 +0000 (12:36 -0800)]
doc/articles/wiki: fix racy test

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6853069

12 years agonet/http/cgi: more windows perl test work
Brad Fitzpatrick [Mon, 19 Nov 2012 18:40:13 +0000 (10:40 -0800)]
net/http/cgi: more windows perl test work

Don't rely on finding cmd.exe in a particular spot.

Fixes #4401

R=golang-dev, krautz
CC=golang-dev
https://golang.org/cl/6842066

12 years agoruntime: gdb support: use parse_and_eval to get the goroutine id
Christian Himpel [Mon, 19 Nov 2012 18:22:47 +0000 (10:22 -0800)]
runtime: gdb support: use parse_and_eval to get the goroutine id

This enables to loop over some goroutines, e.g. to print the
backtrace of goroutines 1 to 9:

        set $i = 1
        while $i < 10
        printf "backtrace of goroutine %d:\n", $i
        goroutine $i++ bt
        end

R=lvd, lvd
CC=golang-dev
https://golang.org/cl/6843071

12 years agocmd/gc: complain about invalid whitespace chars
Robert Griesemer [Mon, 19 Nov 2012 17:09:04 +0000 (09:09 -0800)]
cmd/gc: complain about invalid whitespace chars

Fixes #4405.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6855060

12 years agonet/http/cgi: make test more robust for Windows perl
Brad Fitzpatrick [Mon, 19 Nov 2012 16:25:51 +0000 (08:25 -0800)]
net/http/cgi: make test more robust for Windows perl

Update #4401

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/6853067

12 years agonet: fix data race on fd.sysfd
Dave Cheney [Sun, 18 Nov 2012 19:53:58 +0000 (06:53 +1100)]
net: fix data race on fd.sysfd

Fixes #4369.

Remove the check for fd.sysfd < 0, the first line of fd.accept() tests if the fd is open correctly and will handle the fd being closed during accept.

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6843076

12 years agonet: remove unused nil check
Dave Cheney [Sun, 18 Nov 2012 04:31:26 +0000 (15:31 +1100)]
net: remove unused nil check

This is part 1 of a series of proposals to fix issue 4369.

In resolving issue 3507 it was decided not to nil out the inner conn.fd field to avoid a race. This implies the checks for fd == nil inside incref/decref are never true.

Removing this logic removes one source of errClosing error values, which affects issue 4373 and moves towards bradfitz's request that fd.accept() return io.EOF when closed concurrently.

Update #4369.
Update #4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852057

12 years agoruntime/cgo: enable warnings and treat as errors
Dave Cheney [Sat, 17 Nov 2012 21:58:54 +0000 (08:58 +1100)]
runtime/cgo: enable warnings and treat as errors

Enable warnings as errors during the cgo portion of runtime/cgo. iant requested that the list of flags match cmd/dist/build.c, but I would like to avoid the set of disabled warnings if possible.

ref: https://groups.google.com/d/topic/golang-nuts/TrCoVzIIG4M/discussion

requires: 6843061

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/6852055

12 years agospec: fix constant expression example
Robert Griesemer [Sat, 17 Nov 2012 19:16:07 +0000 (11:16 -0800)]
spec: fix constant expression example

Fixes #4400.

R=r, mirtchovski
CC=golang-dev
https://golang.org/cl/6782084

12 years agoruntime: don't assume AT_RANDOM provide 4-byte aligned ptr
Shenghou Ma [Sat, 17 Nov 2012 18:47:17 +0000 (02:47 +0800)]
runtime: don't assume AT_RANDOM provide 4-byte aligned ptr

R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056

12 years agogo/doc: fix identifier blank import handling for examples
Robert Griesemer [Sat, 17 Nov 2012 18:40:11 +0000 (10:40 -0800)]
go/doc: fix identifier blank import handling for examples

Replacement CL for 6813061; thanks to minux for prototyping.

Fixes #4300.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6782082

12 years agolib/godoc/codewalk.html: remove duplicate jquery inclusion
Shenghou Ma [Sat, 17 Nov 2012 18:28:54 +0000 (02:28 +0800)]
lib/godoc/codewalk.html: remove duplicate jquery inclusion
now we load jquery in its parent--godoc.html.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6814112

12 years agocrypto/md5: speed up aligned writes and test/bench unaligned writes
Shenghou Ma [Sat, 17 Nov 2012 18:23:34 +0000 (02:23 +0800)]
crypto/md5: speed up aligned writes and test/bench unaligned writes
Write() can safely use uint32 loads when input is aligned.
Also add test and benchmarks for unaligned writes.

Benchmark result obtained by Dave Cheney on ARMv5TE @ 1.2GHz:
benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                  4104         3417  -16.74%
BenchmarkHash1K                     22061        11208  -49.20%
BenchmarkHash8K                    146630        65148  -55.57%
BenchmarkHash8BytesUnaligned         4128         3436  -16.76%
BenchmarkHash1KUnaligned            22054        21473   -2.63%
BenchmarkHash8KUnaligned           146658       146909   +0.17%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                  1.95         2.34    1.20x
BenchmarkHash1K                     46.42        91.36    1.97x
BenchmarkHash8K                     55.87       125.74    2.25x
BenchmarkHash8BytesUnaligned         1.94         2.33    1.20x
BenchmarkHash1KUnaligned            46.43        47.69    1.03x
BenchmarkHash8KUnaligned            55.86        55.76    1.00x

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/6782072

12 years agoruntime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
Shenghou Ma [Sat, 17 Nov 2012 18:06:08 +0000 (02:06 +0800)]
runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061

12 years agoarchive/zip: handle extra data headers with no body
Dave Cheney [Sat, 17 Nov 2012 13:45:47 +0000 (00:45 +1100)]
archive/zip: handle extra data headers with no body

Fixes #4393.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854058

12 years agoarchive/zip, crypto/tls, net/http: Fix print format errors.
Robin Eklind [Sat, 17 Nov 2012 01:24:43 +0000 (17:24 -0800)]
archive/zip, crypto/tls, net/http: Fix print format errors.

All of the errors were located using "go vet ./..." in "src/pkg".

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6856056

12 years agonet/http: reduce allocations in chunk reading & writing
Brad Fitzpatrick [Fri, 16 Nov 2012 21:25:01 +0000 (13:25 -0800)]
net/http: reduce allocations in chunk reading & writing

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6847063

12 years agogo/printer: leave indentation alone when printing nodes from different files
Robert Griesemer [Fri, 16 Nov 2012 21:17:12 +0000 (13:17 -0800)]
go/printer: leave indentation alone when printing nodes from different files

ASTs may be created by various tools and built from nodes of
different files. An incorrectly constructed AST will likely
not print at all, but a (structurally) correct AST with bad
position information should still print structurally correct.

One heuristic used was to reset indentation when the filename
in the position information of nodes changed. However, this
can lead to wrong indentation for structurally correct ASTs.

Fix: Don't change the indentation in this case.

Related to issue 4300.

R=r
CC=golang-dev
https://golang.org/cl/6849066

12 years agogo/ast: FuncType.Params may be nil (per AST documentation)
Robert Griesemer [Fri, 16 Nov 2012 19:53:26 +0000 (11:53 -0800)]
go/ast: FuncType.Params may be nil (per AST documentation)

ast.Walk needs to check for it or it will crash.

R=r
CC=golang-dev
https://golang.org/cl/6852062

12 years agoruntime: hide mheap from race detector
Dmitriy Vyukov [Fri, 16 Nov 2012 16:06:11 +0000 (20:06 +0400)]
runtime: hide mheap from race detector
This significantly decreases amount of shadow memory
mapped by race detector.
I haven't tested on Windows, but on Linux it reduces
virtual memory size from 1351m to 330m for fmt.test.
Fixes #4379.

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057

12 years agoruntime: remove extra parentheses.
Oling Cat [Fri, 16 Nov 2012 12:09:37 +0000 (23:09 +1100)]
runtime: remove extra parentheses.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6843069

12 years agocrypto/tls: add support for loading EC X.509 key pairs
Joel Sing [Fri, 16 Nov 2012 08:33:59 +0000 (19:33 +1100)]
crypto/tls: add support for loading EC X.509 key pairs

Add support for loading X.509 key pairs that consist of a certificate
with an EC public key and its corresponding EC private key.

R=agl
CC=golang-dev
https://golang.org/cl/6776043

12 years agosyscall: fix data races in LazyDLL/LazyProc
Dmitriy Vyukov [Fri, 16 Nov 2012 08:06:48 +0000 (12:06 +0400)]
syscall: fix data races in LazyDLL/LazyProc
Reincarnation of https://golang.org/cl/6817086 (sent from another account).
It is ugly because sync.Once will cause allocation of a closure.
Fixes #4343.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6856046

12 years agoexp/locale/collate: changed implementation of Compare and CompareString to
Marcel van Lohuizen [Thu, 15 Nov 2012 21:23:56 +0000 (22:23 +0100)]
exp/locale/collate: changed implementation of Compare and CompareString to
compare incrementally. Also modified collation API to be more high-level
by removing the need for an explicit buffer to be passed as an argument.
This considerably speeds up Compare and CompareString.  This change also eliminates
the need to reinitialize the normalization buffer for each use of an iter. This
also significantly improves performance for Key and KeyString.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6842050

12 years agoos: add FileMode.IsRegular
Brad Fitzpatrick [Thu, 15 Nov 2012 19:46:00 +0000 (11:46 -0800)]
os: add FileMode.IsRegular

API change.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6844048

12 years agomisc/git: add gofmt git pre-commit hook
Andrew Gerrand [Thu, 15 Nov 2012 18:58:49 +0000 (19:58 +0100)]
misc/git: add gofmt git pre-commit hook

R=golang-dev, bradfitz, ftrvxmtrx, franciscossouza, r, minux.ma
CC=golang-dev
https://golang.org/cl/6843044

12 years agosudo.bash: diagnose when the go tool is not in $PATH
Rob Pike [Thu, 15 Nov 2012 18:42:39 +0000 (10:42 -0800)]
sudo.bash: diagnose when the go tool is not in $PATH
Fixes #4386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6854050

12 years agosync/atomic: fix race instrumentation
Dmitriy Vyukov [Thu, 15 Nov 2012 17:30:24 +0000 (21:30 +0400)]
sync/atomic: fix race instrumentation

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6782075

12 years agoruntime/cgo: include <string.h> as needed so that strerror is declared
Ian Lance Taylor [Thu, 15 Nov 2012 06:04:03 +0000 (22:04 -0800)]
runtime/cgo: include <string.h> as needed so that strerror is declared

R=golang-dev, dave, jsing
CC=golang-dev
https://golang.org/cl/6847051

12 years agorun.bash: fix linux/arm build
Dave Cheney [Thu, 15 Nov 2012 02:59:46 +0000 (13:59 +1100)]
run.bash: fix linux/arm build

Revert to the shell builtin to avoid hosts that do not have /usr/bin/time.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6848054

12 years agorun.{bash,bat,rc}: unset GOMAXPROCS before ../test
Dave Cheney [Thu, 15 Nov 2012 00:40:10 +0000 (11:40 +1100)]
run.{bash,bat,rc}: unset GOMAXPROCS before ../test

test/run.go already executes tests in parallel where
possible. An unknown GOMAXPROCS value during the tests
is known to cause failures with tests that measure
allocations.

ref: https://groups.google.com/d/topic/golang-nuts/tgMhFJ3F5WY/discussion

R=fullung, minux.ma, r
CC=golang-dev
https://golang.org/cl/6847050

12 years agostrconv: Removed unnecessary use of goto. Made code easier to read.
Robin Eklind [Wed, 14 Nov 2012 17:42:48 +0000 (09:42 -0800)]
strconv: Removed unnecessary use of goto. Made code easier to read.

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6855048

12 years agocrypto/x509: add support for SEC1/EC private keys.
Joel Sing [Wed, 14 Nov 2012 16:39:00 +0000 (03:39 +1100)]
crypto/x509: add support for SEC1/EC private keys.

Add support for parsing SEC1 EC private keys and PKCS8 encapsulated
EC private key structures.

R=agl
CC=golang-dev
https://golang.org/cl/6767045

12 years agodebug/elf: fix offset for GNU version symbols
Joel Sing [Wed, 14 Nov 2012 16:36:19 +0000 (03:36 +1100)]
debug/elf: fix offset for GNU version symbols

Since we no longer skip the first entry when reading a symbol table,
we no longer need to allow for the offset difference when processing
the GNU version symbols.

Unbreaks builds on Linux.

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6843057

12 years agodebug/elf: do not skip first symbol in the symbol table
Joel Sing [Wed, 14 Nov 2012 15:24:14 +0000 (02:24 +1100)]
debug/elf: do not skip first symbol in the symbol table

Do not skip the first symbol in the symbol table. Any other indexes
into the symbol table (for example, indexes in relocation entries)
will now refer to the symbol following the one that was intended.

Add an object that contains debug relocations, which debug/dwarf
failed to decode correctly. Extend the relocation tests to cover
this case.

Note that the existing tests passed since the symbol following the
symbol that required relocation is also of type STT_SECTION.

Fixes #4107.

R=golang-dev, mikioh.mikioh, iant, iant
CC=golang-dev
https://golang.org/cl/6848044

12 years agoruntime/race: more precise handling of finalizers
Dmitriy Vyukov [Wed, 14 Nov 2012 12:58:10 +0000 (16:58 +0400)]
runtime/race: more precise handling of finalizers
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6810095

12 years agoruntime: add RaceRead/RaceWrite functions
Dmitriy Vyukov [Wed, 14 Nov 2012 12:51:23 +0000 (16:51 +0400)]
runtime: add RaceRead/RaceWrite functions
It allows to catch e.g. a data race between atomic write and non-atomic write,
or Mutex.Lock() and mutex overwrite (e.g. mu = Mutex{}).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6817103

12 years agocmd/gc: racewalk: handle OEFACE/OCONVIFACE
Dmitriy Vyukov [Wed, 14 Nov 2012 12:30:53 +0000 (16:30 +0400)]
cmd/gc: racewalk: handle OEFACE/OCONVIFACE

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821096

12 years agocmd/gc: racewalk: fix instrumentation of structs
Dmitriy Vyukov [Wed, 14 Nov 2012 12:26:00 +0000 (16:26 +0400)]
cmd/gc: racewalk: fix instrumentation of structs
+ do not instrument go.itab.*

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6819106

12 years agoregexp: add simple package-level example
Andrew Gerrand [Wed, 14 Nov 2012 09:43:21 +0000 (10:43 +0100)]
regexp: add simple package-level example

Update #4125

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6846045

12 years agosyscall: regenerate z-files for openbsd/386
Joel Sing [Wed, 14 Nov 2012 08:06:12 +0000 (19:06 +1100)]
syscall: regenerate z-files for openbsd/386

Regenerate z-files for OpenBSD/386 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6844044

12 years agonet/http: add missing error checking reading trailers
Brad Fitzpatrick [Wed, 14 Nov 2012 06:38:25 +0000 (22:38 -0800)]
net/http: add missing error checking reading trailers

This is a simplified version of earlier versions of this CL
and now only fixes obviously incorrect things, without
changing the locking on bodyEOFReader.

I'd like to see if this is sufficient before changing the
locking.

Update #4191

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6739055

12 years agoreflect: fix FieldByNameFunc
Robert Griesemer [Tue, 13 Nov 2012 18:45:30 +0000 (10:45 -0800)]
reflect: fix FieldByNameFunc

The existing algorithm did not properly propagate the type
count from one level to the next, and as a consequence it
missed collisions.

Properly propagate multiplicity (count) information to the
next level.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1          182          180   -1.10%
BenchmarkFieldByName2         6273         6183   -1.43%
BenchmarkFieldByName3        49267        46784   -5.04%

Fixes #4355.

R=rsc
CC=golang-dev
https://golang.org/cl/6821094

12 years agocmd/ld: fix build on elf systems
Russ Cox [Tue, 13 Nov 2012 18:12:11 +0000 (13:12 -0500)]
cmd/ld: fix build on elf systems

TBR=iant
CC=golang-dev
https://golang.org/cl/6843050

12 years agoreflect: add ArrayOf, ChanOf, MapOf, SliceOf
Russ Cox [Tue, 13 Nov 2012 18:06:29 +0000 (13:06 -0500)]
reflect: add ArrayOf, ChanOf, MapOf, SliceOf

In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043

12 years agocmd/api: use one token.FileSet for all contexts
Brad Fitzpatrick [Tue, 13 Nov 2012 17:59:46 +0000 (09:59 -0800)]
cmd/api: use one token.FileSet for all contexts

Prep for future CL.

R=gri
CC=golang-dev
https://golang.org/cl/6843048

12 years agoruntime: allow up to 128 GB of allocated memory
Russ Cox [Tue, 13 Nov 2012 17:45:08 +0000 (12:45 -0500)]
runtime: allow up to 128 GB of allocated memory

Incorporates code from CL 6828055.

Fixes #2142.

R=golang-dev, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6826088

12 years agosyscall: regenerate z-files for openbsd/amd64
Joel Sing [Tue, 13 Nov 2012 16:19:34 +0000 (03:19 +1100)]
syscall: regenerate z-files for openbsd/amd64

Regenerate z-files for OpenBSD/amd64 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6843045

12 years agodoc: link to Go coding screencast
Andrew Gerrand [Tue, 13 Nov 2012 15:50:44 +0000 (16:50 +0100)]
doc: link to Go coding screencast

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6849046

12 years agonet: consolidate common socket functions for Plan 9
Mikio Hara [Tue, 13 Nov 2012 07:18:37 +0000 (16:18 +0900)]
net: consolidate common socket functions for Plan 9

This CL extends changeset 13126:fc4a62e14aba to Plan 9.

R=ality, golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6820124

12 years agocmd/8g: eliminate obviously useless temps before regopt.
Rémy Oudompheng [Tue, 13 Nov 2012 06:39:18 +0000 (07:39 +0100)]
cmd/8g: eliminate obviously useless temps before regopt.

This patch introduces a sort of pre-regopt peephole optimization.
When a temporary is introduced that just holds a value for the
duration of the next instruction and is otherwise unused, we
elide it to make the job of regopt easier.

Since x86 has very few registers, this situation happens very
often. The result is large savings in stack variables for
arithmetic-heavy functions.

crypto/aes

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncrypt               1301          392  -69.87%
BenchmarkDecrypt               1309          368  -71.89%
BenchmarkExpand                2913         1036  -64.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkEncrypt              12.29        40.74    3.31x
BenchmarkDecrypt              12.21        43.37    3.55x

crypto/md5

benchmark                 old ns/op    new ns/op    delta
BenchmarkHash8Bytes            1761          914  -48.10%
BenchmarkHash1K               16912         5570  -67.06%
BenchmarkHash8K              123895        38286  -69.10%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkHash8Bytes            4.54         8.75    1.93x
BenchmarkHash1K               60.55       183.83    3.04x
BenchmarkHash8K               66.12       213.97    3.24x

bench/go1

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8364835000   8303154000   -0.74%
BenchmarkFannkuch11      7511723000   6381729000  -15.04%
BenchmarkGobDecode         27764090     27103270   -2.38%
BenchmarkGobEncode         11240880     11184370   -0.50%
BenchmarkGzip            1470224000    856668400  -41.73%
BenchmarkGunzip           240660800    201697300  -16.19%
BenchmarkJSONEncode       155225800    185571900  +19.55%
BenchmarkJSONDecode       243347900    282123000  +15.93%
BenchmarkMandelbrot200     12240970     12201880   -0.32%
BenchmarkParse              8837445      8765210   -0.82%
BenchmarkRevcomp         2556310000   1868566000  -26.90%
BenchmarkTemplate         389298000    379792000   -2.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            27.64        28.32    1.02x
BenchmarkGobEncode            68.28        68.63    1.01x
BenchmarkGzip                 13.20        22.65    1.72x
BenchmarkGunzip               80.63        96.21    1.19x
BenchmarkJSONEncode           12.50        10.46    0.84x
BenchmarkJSONDecode            7.97         6.88    0.86x
BenchmarkParse                 6.55         6.61    1.01x
BenchmarkRevcomp              99.43       136.02    1.37x
BenchmarkTemplate              4.98         5.11    1.03x

Fixes #4035.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6828056

12 years agocmd/gc: fix typos in clearslim.
Rémy Oudompheng [Tue, 13 Nov 2012 06:08:29 +0000 (07:08 +0100)]
cmd/gc: fix typos in clearslim.

Fixes build failure.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6847043

12 years agonet: protocol specific listen functions return a proper local socket address
Mikio Hara [Tue, 13 Nov 2012 03:56:28 +0000 (12:56 +0900)]
net: protocol specific listen functions return a proper local socket address

When a nil listener address is passed to some protocol specific
listen function, it will create an unnamed, unbound socket because
of the nil listener address. Other listener functions may return
invalid address error.

This CL allows to pass a nil listener address to all protocol
specific listen functions to fix above inconsistency. Also make it
possible to return a proper local socket address in case of a nil
listner address.

Fixes #4190.
Fixes #3847.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6525048

12 years agonet: make LocalAddr on multicast UDPConn return a listening address
Mikio Hara [Tue, 13 Nov 2012 03:26:20 +0000 (12:26 +0900)]
net: make LocalAddr on multicast UDPConn return a listening address

The package go.net/ipv4 allows to exist a single UDP listener
that join multiple different group addresses. That means that
LocalAddr on multicast UDPConn returns a first joined group
address is not desirable.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822108

12 years agonet/textproto: faster header canonicalization with fewer allocations
Jeff R. Allen [Mon, 12 Nov 2012 23:31:42 +0000 (15:31 -0800)]
net/textproto: faster header canonicalization with fewer allocations

By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader        19590        10824  -44.75%
BenchmarkUncommon               3168         1861  -41.26%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           32           25  -21.88%
BenchmarkUncommon                  5            5    0.00%

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055

12 years agonet/http: handle 413 responses more robustly
Brad Fitzpatrick [Mon, 12 Nov 2012 23:20:18 +0000 (15:20 -0800)]
net/http: handle 413 responses more robustly

When HTTP bodies were too large and we didn't want to finish
reading them for DoS reasons, we previously found it necessary
to send a FIN and then pause before closing the connection
(which might send a RST) if we wanted the client to have a
better chance at receiving our error response. That was Issue 3595.

This issue adds the same fix to request headers which
are too large, which might fix the Windows flakiness
we observed on TestRequestLimit at:
http://build.golang.org/log/146a2a7d9b24441dc14602a1293918191d4e75f1

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6826084

12 years agocmd/6g: extend componentgen to small arrays and structs.
Rémy Oudompheng [Mon, 12 Nov 2012 23:08:04 +0000 (00:08 +0100)]
cmd/6g: extend componentgen to small arrays and structs.

Fixes #4092.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6819083

12 years agocmd/5g, cmd/6g: pass the full torture test.
Rémy Oudompheng [Mon, 12 Nov 2012 22:56:11 +0000 (23:56 +0100)]
cmd/5g, cmd/6g: pass the full torture test.

The patch adds more cases to agenr to allocate registers later,
and makes 6g generate addresses for sgen in something else than
SI and DI. It avoids a complex save/restore sequence that
amounts to allocate a register before descending in subtrees.

Fixes #4207.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6817080

12 years agoexp/types: avoid init race in check_test.go.
David Symonds [Mon, 12 Nov 2012 22:08:33 +0000 (09:08 +1100)]
exp/types: avoid init race in check_test.go.

There was an init race between
check_test.go:init
        universe.go:def
        use of Universe
and
universe.go:init
        creation of Universe

The order in which init funcs are executed in a package is unspecified.
The test is not currently broken in the golang.org environment
because the go tool compiles the test with non-test sources before test sources,
but other environments may, say, sort the source files before compiling,
and thus trigger this race, causing a nil pointer panic.

R=gri
CC=golang-dev
https://golang.org/cl/6827076

12 years agoencoding/json: skip unexpected null values
Rick Arnold [Mon, 12 Nov 2012 20:35:11 +0000 (15:35 -0500)]
encoding/json: skip unexpected null values

As discussed in issue 2540, nulls are allowed for any type in JSON so they should not result in an error during Unmarshal.
Fixes #2540.

R=rsc
CC=golang-dev
https://golang.org/cl/6759043

12 years agoA+C: Rick Arnold (individual CLA)
Russ Cox [Mon, 12 Nov 2012 20:34:09 +0000 (15:34 -0500)]
A+C: Rick Arnold (individual CLA)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6821110

12 years agocrypto/x509: implement EncryptPEMBlock
Roger Peppe [Mon, 12 Nov 2012 15:31:23 +0000 (15:31 +0000)]
crypto/x509: implement EncryptPEMBlock

Arbitrary decisions: order of the arguments and the
fact it takes a block-type argument (rather than
leaving to user to fill it in later); I'm happy whatever
colour we want to paint it.

We also change DecryptPEMBlock so that it won't
panic when the IV has the wrong size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6820114