1
0
mirror of https://github.com/golang/go synced 2024-10-04 14:31:21 -06:00
Commit Graph

8939 Commits

Author SHA1 Message Date
Keith Randall
139cc96a57 runtime: markfreed's error reports should be prefixed with "markfreed", not "markallocated".
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14441055
2013-10-09 13:28:47 -07:00
Ian Lance Taylor
cb30917387 runtime/cgo: mark callback functions as NOSPLIT
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/14448044
2013-10-09 08:44:47 -07:00
Russ Cox
0965459bd9 debug/dwarf: handle surprising clang encoding
Fixes a bug in cgo on OS X using clang.
See golang.org/issue/6472 for details.

Fixes #6472.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14575043
2013-10-09 11:08:22 -04:00
Ian Lance Taylor
7bbe0163c7 net: fix typo in failure message in test
R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/14582043
2013-10-09 06:44:11 -07:00
Russ Cox
8ba6deb1ec compress/flate: fix infinite loop on malformed data
Test using compress/gzip, because that's how the
data arrived.

Fixes #6550.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14441051
2013-10-09 08:37:06 -04:00
Rob Pike
daa61d1eb3 encoding/gob: add examples
Also tweak the package document, putting in section headings and
adding a sentence about intended use.

Fixes #4925.

R=golang-dev, iant, adg, ugorji
CC=golang-dev
https://golang.org/cl/14519044
2013-10-08 13:13:40 -07:00
Carl Shapiro
254dc5fdbe cmd/go, runtime: express armv5t architecture constraint differently
Instead of adding an -march=armv5t flag to the gcc command
line, the same effect is obtained with an ".arch armv5t"
pseudo op in the assembly file that uses armv5t instructions.

R=golang-dev, iant, dave
CC=golang-dev
https://golang.org/cl/14511044
2013-10-08 10:40:51 -07:00
Rob Pike
9795882704 math: the trig functions work in radians; document that
Fixes #6543
6543 is also a fine NGC object.

R=golang-dev, dsymonds, kamil.kisiel, minux.ma
CC=golang-dev
https://golang.org/cl/14515044
2013-10-07 16:32:47 -07:00
Joel Sing
fc1bea321d os/user: fix user lookups on dragonfly
Like FreeBSD, DragonFly does not provide a sysconf value for
_SC_GETPW_R_SIZE_MAX.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14469043
2013-10-07 09:21:33 -07:00
Joel Sing
fba015ecb4 os/user: enable tests on all supported platforms
All of the currently supported platforms have a working user
implementation and do not use stubs. As a result, enable the tests
on all platforms rather than whitelisting.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/14454044
2013-10-07 09:12:17 -07:00
Joel Sing
932428a1ed os/signal: make test logs reflect reality
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14470043
2013-10-07 09:04:20 -07:00
Keith Randall
869368a528 runtime: fix bug in maps at the intersection of iterators, growing, and NaN keys
If an iterator is started while a map is in the middle of a grow,
and the map has NaN keys, then those keys might get returned by
the iterator more than once.  This fix makes the evacuation decision
deterministic and repeatable for NaN keys so each one gets returned
only once.

R=golang-dev, r, khr, iant
CC=golang-dev
https://golang.org/cl/14367043
2013-10-04 13:54:03 -07:00
Keith Randall
15baf6b4ac runtime: remove 3 unused declarations.
R=golang-dev, cshapiro, iant
CC=golang-dev
https://golang.org/cl/14405043
2013-10-04 13:22:20 -07:00
Ian Lance Taylor
ef4e12a4ba reflect: test using a MakeFunc value in a couple of different ways
The gccgo implementation mishandled calling Interface on a
value created by MakeFunc.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14401043
2013-10-04 13:12:50 -07:00
Alex Brainman
4207897dcc runtime: collect profiles even while on g0 stack
Fixes #6417

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14231047
2013-10-04 13:53:34 +10:00
Ian Lance Taylor
e59db90bfb reflect: add a test that gccgo mishandled
Failure occurred when using reflect.Call to pass a func value
following a non-pointer value.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14186043
2013-10-03 13:23:02 -07:00
Rob Pike
c4579635cf sync/atomic: explain how to subtract an unsigned constant
Explain for those unfamiliar with twos-complement arithmetic how to
implement negation of signed positive constant.
Fixes #6408.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14267044
2013-10-03 10:40:42 -07:00
Russ Cox
01479b6c4a go/doc: update ToHTML doc comment
Update #5429

R=golang-dev, r, dan.kortschak
CC=golang-dev
https://golang.org/cl/14293043
2013-10-03 09:49:12 -04:00
Russ Cox
408238e20b runtime: change default stack segment size to 8 kB
Changing from 4 kB to 8 kB brings significant improvement
on a variety of the Go 1 benchmarks, on both amd64
and 386 systems.

Significant runtime reductions:

          amd64  386
GoParse    -14%  -1%
GobDecode  -12% -20%
GobEncode  -64%  -1%
JSONDecode  -9%  -4%
JSONEncode -15%  -5%
Template   -17% -14%

In the longer term, khr's new stacks will avoid needing to
make this decision at all, but for Go 1.2 this is a reasonable
stopgap that makes performance significantly better.

Demand paging should mean that if the second 4 kB is not
used, it will not be brought into memory, so the change
should not adversely affect resident set size.
The same argument could justify bumping as high as 64 kB
on 64-bit machines, but there are diminishing returns
after 8 kB, and using 8 kB limits the possible unintended
memory overheads we are not aware of.

Benchmark graphs at
http://swtch.com/~rsc/gostackamd64.html
http://swtch.com/~rsc/gostack386.html

Full data at
http://swtch.com/~rsc/gostack.zip

R=golang-dev, khr, dave, bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/14317043
2013-10-03 09:19:10 -04:00
Russ Cox
94a6511b7f net: use original argument in lookup error
Fixes #6324.

R=golang-dev, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13280049
2013-10-02 22:09:54 -04:00
Russ Cox
95d85d90d8 crypto/tls: document ConnectionState fields
Fixes #6456.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14289043
2013-10-02 21:40:01 -04:00
Russ Cox
4216203bcf runtime: remove syscall.NewCallbackCDecl on Windows
It is not possible to use (there is no declaration in package syscall),
and no one seems to care.

Alex Brainman may bring this back properly for Go 1.3.

Fixes #6338.

R=golang-dev, r, alex.brainman
CC=golang-dev
https://golang.org/cl/14287043
2013-10-02 21:39:45 -04:00
Josh Bleecher Snyder
0857045818 encoding/json: add an example for RawMessage
RawMessage is useful and mildly non-obvious.
Given the frequency with which RawMessage questions
show up on golang-nuts, and get answered with an example,
I suspect adding an example to the docs might help.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14190044
2013-10-03 08:52:18 +10:00
Russ Cox
1b0bffa973 net/http: be clear that HTTPS is supported
Fixes #6443.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/14231045
2013-10-02 13:21:15 -04:00
Russ Cox
5f853d7d94 runtime: fix finalizer test on amd64
Not scanning the stack by frames means we are reintroducing
a few false positives into the collection. Run the finalizer registration
in its own goroutine so that stack is guaranteed to be out of
consideration in a later collection.

This is working around a regression from yesterday's tip, but
it's not a regression from Go 1.1.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/14290043
2013-10-02 12:30:49 -04:00
Frithjof Schulze
4d7c63558c crypto/tls: Update reference to the TLS 1.2 RFC.
Ticket 13740047 updated the documented TLS version to 1.2.
This also updates the RFC refered to.

R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/14029043
2013-10-02 12:09:13 -04:00
Russ Cox
c3dadca977 runtime: do not scan stack by frames during garbage collection
Walking the stack by frames is ~3x more expensive
than not, and since it didn't end up being precise,
there is not enough benefit to outweigh the cost.

This is the conservative choice: this CL makes the
stack scanning behavior the same as it was in Go 1.1.

Add benchmarks to package runtime so that we have
them when we re-enable this feature during the
Go 1.3 development.

benchmark                     old ns/op    new ns/op    delta
BenchmarkGoroutineSelect        3194909      1272092  -60.18%
BenchmarkGoroutineBlocking      3120282       866366  -72.23%
BenchmarkGoroutineForRange      3256179       939902  -71.13%
BenchmarkGoroutineIdle          2005571       482982  -75.92%

The Go 1 benchmarks, just to add more data.
As far as I can tell the changes are mainly noise.

benchmark                         old ns/op    new ns/op    delta
BenchmarkBinaryTree17            4409403046   4414734932   +0.12%
BenchmarkFannkuch11              3407708965   3378306120   -0.86%
BenchmarkFmtFprintfEmpty                100           99   -0.60%
BenchmarkFmtFprintfString               242          239   -1.24%
BenchmarkFmtFprintfInt                  204          206   +0.98%
BenchmarkFmtFprintfIntInt               320          316   -1.25%
BenchmarkFmtFprintfPrefixedInt          295          299   +1.36%
BenchmarkFmtFprintfFloat                442          435   -1.58%
BenchmarkFmtManyArgs                   1246         1216   -2.41%
BenchmarkGobDecode                 10186951     10051210   -1.33%
BenchmarkGobEncode                 16504381     16445650   -0.36%
BenchmarkGzip                     447030885    447056865   +0.01%
BenchmarkGunzip                   111056154    111696305   +0.58%
BenchmarkHTTPClientServer             89973        93040   +3.41%
BenchmarkJSONEncode                28174182     27933893   -0.85%
BenchmarkJSONDecode               106353777    110443817   +3.85%
BenchmarkMandelbrot200              4822289      4806083   -0.34%
BenchmarkGoParse                    6102436      6142734   +0.66%
BenchmarkRegexpMatchEasy0_32            133          132   -0.75%
BenchmarkRegexpMatchEasy0_1K            372          373   +0.27%
BenchmarkRegexpMatchEasy1_32            113          111   -1.77%
BenchmarkRegexpMatchEasy1_1K            964          940   -2.49%
BenchmarkRegexpMatchMedium_32           202          205   +1.49%
BenchmarkRegexpMatchMedium_1K         68862        68858   -0.01%
BenchmarkRegexpMatchHard_32            3480         3407   -2.10%
BenchmarkRegexpMatchHard_1K          108255       112614   +4.03%
BenchmarkRevcomp                  751393035    743929976   -0.99%
BenchmarkTemplate                 139637041    135402220   -3.03%
BenchmarkTimeParse                      479          475   -0.84%
BenchmarkTimeFormat                     460          466   +1.30%

benchmark                          old MB/s     new MB/s  speedup
BenchmarkGobDecode                    75.34        76.36    1.01x
BenchmarkGobEncode                    46.50        46.67    1.00x
BenchmarkGzip                         43.41        43.41    1.00x
BenchmarkGunzip                      174.73       173.73    0.99x
BenchmarkJSONEncode                   68.87        69.47    1.01x
BenchmarkJSONDecode                   18.25        17.57    0.96x
BenchmarkGoParse                       9.49         9.43    0.99x
BenchmarkRegexpMatchEasy0_32         239.58       241.74    1.01x
BenchmarkRegexpMatchEasy0_1K        2749.74      2738.00    1.00x
BenchmarkRegexpMatchEasy1_32         282.49       286.32    1.01x
BenchmarkRegexpMatchEasy1_1K        1062.00      1088.96    1.03x
BenchmarkRegexpMatchMedium_32          4.93         4.86    0.99x
BenchmarkRegexpMatchMedium_1K         14.87        14.87    1.00x
BenchmarkRegexpMatchHard_32            9.19         9.39    1.02x
BenchmarkRegexpMatchHard_1K            9.46         9.09    0.96x
BenchmarkRevcomp                     338.26       341.65    1.01x
BenchmarkTemplate                     13.90        14.33    1.03x

Fixes #6482.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/14257043
2013-10-02 11:59:53 -04:00
Carl Shapiro
7a480a8c9b undo CL 14154043 / 3e485428767e
««« original CL description
encoding/gob: do not hide pointer argument for the garbage collector

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

R=golang-dev
CC=golang-dev
https://golang.org/cl/14165043
2013-09-30 16:02:12 -07:00
Carl Shapiro
6ffd70e7f0 encoding/gob: do not hide pointer argument for the garbage collector
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14154043
2013-09-30 15:54:21 -07:00
Robin Eklind
9bd1f49e37 syscall: Fix one issue detected by vet.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/14038044
2013-09-28 11:06:50 +10:00
Kamil Kisiel
48da6754e2 encoding/json: Tweak documentation for Encoder.Encode.
The documentation for the Encoder type calls it a stream,
not a connection.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/14015044
2013-09-27 15:38:39 +10:00
Carl Shapiro
0ab8f2d287 reflect: expose reflect.call argument slice to the garbage collector
The argument slice was kept hidden from the garbage collector
by destroying its referent in an unsafe.Pointer to uintptr
conversion.  This change preserves the unsafe.Pointer referent
and only performs an unsafe.Pointer to uintptr conversions
within expressions that construct new unsafe.Pointer values.

R=golang-dev, khr, rsc
CC=golang-dev
https://golang.org/cl/14008043
2013-09-26 21:59:13 -07:00
Rob Pike
fa7791e922 all: fix some mistakes found by go tool vet .
R=golang-dev, iant, adg
CC=golang-dev
https://golang.org/cl/14000043
2013-09-27 10:09:15 +10:00
Adam Langley
f752484c74 crypto/tls: don't select TLS 1.2 cipher suites in prior versions.
AES-GCM cipher suites are only defined for TLS 1.2, although there's
nothing really version specific about them. However, development
versions of NSS (meaning Firefox and Chrome) have an issue where
they'll advertise TLS 1.2-only cipher suites in a TLS 1.1 ClientHello
but then balk when the server selects one.

This change causes Go clients not to advertise TLS 1.2 cipher suites
unless TLS 1.2 is being used, and prevents servers from selecting them
unless TLS 1.2 has been negotiated.

https://code.google.com/p/chromium/issues/detail?id=297151
https://bugzilla.mozilla.org/show_bug.cgi?id=919677

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13573047
2013-09-26 17:09:56 -04:00
Dave Cheney
649a2a9be5 runtime, syscall: update freebsd/arm calling convention to match EABI
Fixes #6451.

There is still some breakages unrelated to the syscall change.

[root@beaglebone ~/go/src]# /root/go/pkg/tool/freebsd_arm/go_bootstrap version
go version devel freebsd/arm
a std@beaglebone ~/go/src]# /root/go/pkg/tool/freebsd_arm/go_bootstrap install -
fatal error: mark - finalizer inconsistency

runtime stack:
runtime.throw(0x3e80ac)
        /root/go/src/pkg/runtime/panic.c:464 +0x5c
addfinroots(0x2)
        /root/go/src/pkg/runtime/mgc0.c:1501 +0x74
runtime.walkfintab(0x6c200)
        /root/go/src/pkg/runtime/mfinal.c:216 +0xa0
addroots()
        /root/go/src/pkg/runtime/mgc0.c:1561 +0x188
gc(0x50632f78)
        /root/go/src/pkg/runtime/mgc0.c:2098 +0x19c
mgc(0x306170a0)
        /root/go/src/pkg/runtime/mgc0.c:2049 +0x30
runtime.mcall(0x3e97b0)
        /root/go/src/pkg/runtime/asm_arm.s:165 +0x3c

goroutine 1 [garbage collection]:
runtime.gc(0x0)
        /root/go/src/pkg/runtime/mgc0.c:2020 +0x1a0 fp=0x50632f80
runtime.mallocgc(0x680, 0x1b1971, 0x1)
        /root/go/src/pkg/runtime/malloc.goc:143 +0x210 fp=0x50632fbc
----- stack segment boundary -----
cnew(0x1b1970, 0x640, 0x1)
        /root/go/src/pkg/runtime/malloc.goc:718 +0xc4 fp=0x50626110
runtime.cnewarray(0x1b1970, 0x640)
        /root/go/src/pkg/runtime/malloc.goc:731 +0x3c fp=0x50626120
makeslice1(0x1ac6d0, 0x500, 0x640, 0x50626190)
        /root/go/src/pkg/runtime/slice.c:57 +0x50 fp=0x5062612c
growslice1(0x1ac6d0, 0x30714a00, 0x500, 0x500, 0x501, ...)
        /root/go/src/pkg/runtime/slice.c:113 +0x8c fp=0x50626144
runtime.growslice(0x1ac6d0, 0x30714a00, 0x500, 0x500, 0x1, ...)
        /root/go/src/pkg/runtime/slice.c:80 +0x19c fp=0x50626174
go/build.(*importReader).readByte(0x3070d1b0, 0xb384e)
        /root/go/src/pkg/go/build/read.go:43 +0xbc fp=0x506261b4
go/build.(*importReader).peekByte(0x3070d1b0, 0x3070d101, 0x3070d180)
        /root/go/src/pkg/go/build/read.go:89 +0x210 fp=0x506261d0
go/build.readComments(0x203e2560, 0x306f79a8, 0x306f79a8, 0x203e2560, 0x306f79a8, ...)
        /root/go/src/pkg/go/build/read.go:194 +0x84 fp=0x506261f4
go/build.(*Context).matchFile(0x3e9730, 0x306209c0, 0x13, 0x306c42b4, 0x5, ...)
        /root/go/src/pkg/go/build/build.go:812 +0x74c fp=0x5062629c
go/build.(*Context).Import(0x3e9730, 0x1f95c8, 0x1, 0x30620960, 0x13, ...)
        /root/go/src/pkg/go/build/build.go:580 +0xd64 fp=0x506268dc
go/build.(*Context).ImportDir(0x3e9730, 0x30620960, 0x13, 0x0, 0x24d901, ...)
        /root/go/src/pkg/go/build/build.go:397 +0x5c fp=0x50626904
main.func·021(0x30620960, 0x13, 0x203e2200, 0x30680330, 0x0, ...)
        /root/go/src/cmd/go/main.go:521 +0x2cc fp=0x5062696c
path/filepath.walk(0x30620960, 0x13, 0x203e2200, 0x30680330, 0x50626ae8, ...)
        /root/go/src/pkg/path/filepath/path.go:341 +0x5c fp=0x506269d8
path/filepath.walk(0x3067e720, 0x11, 0x203e2200, 0x30680210, 0x50626ae8, ...)
        /root/go/src/pkg/path/filepath/path.go:359 +0x308 fp=0x50626a44
path/filepath.Walk(0x3067e720, 0x11, 0x50626ae8, 0x1f9728, 0x1)
        /root/go/src/pkg/path/filepath/path.go:380 +0xb4 fp=0x50626a68
main.matchPackages(0xbfffedea, 0x3, 0x1b1190, 0x3067e600, 0x10)
        /root/go/src/cmd/go/main.go:530 +0x2c0 fp=0x50626b1c
main.allPackages(0xbfffedea, 0x3, 0x1fadc8, 0x3, 0x1)
        /root/go/src/cmd/go/main.go:474 +0x34 fp=0x50626b70
main.importPathsNoDotExpansion(0x30620018, 0x1, 0x1, 0x0, 0xffffffff, ...)
        /root/go/src/cmd/go/main.go:305 +0x2f8 fp=0x50626c04
main.importPaths(0x30620018, 0x1, 0x1, 0x3, 0x0, ...)
        /root/go/src/cmd/go/main.go:315 +0x44 fp=0x50626c88
main.packagesAndErrors(0x30620018, 0x1, 0x1, 0x50626d60, 0x90f44, ...)
        /root/go/src/cmd/go/pkg.go:798 +0x1bc fp=0x50626d1c
main.packagesForBuild(0x30620018, 0x1, 0x1, 0x53490, 0x0, ...)
        /root/go/src/cmd/go/pkg.go:818 +0x44 fp=0x50626dac
main.runInstall(0x3e46e0, 0x30620018, 0x1, 0x1)
        /root/go/src/cmd/go/build.go:311 +0x48 fp=0x50626e60
main.main()
        /root/go/src/cmd/go/main.go:161 +0x518 fp=0x50626f8c
runtime.main()
        /root/go/src/pkg/runtime/proc.c:222 +0x100 fp=0x50626fc0
runtime.goexit()
        /root/go/src/pkg/runtime/proc.c:1396 fp=0x50626fc0

goroutine 3 [syscall]:
os/signal.loop()
        /root/go/src/pkg/os/signal/signal_unix.go:21 +0x24
created by os/signal.init·1
        /root/go/src/pkg/os/signal/signal_unix.go:27 +0x48

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/13824044
2013-09-26 21:35:49 +10:00
Rob Pike
e2e9d1d684 html/template: update the Tree field after parsing new templates
After text/template.Parse, all the templates may have changed, so
we need to set them all back to their unescaped state. The code
did this but (mea culpa) forgot to set the Tree field of the html/template
struct.

Since the Tree is reset during escaping, this only matters if an error
arises during escaping and we want to print a message.

Fixes #6459.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13877043
2013-09-25 10:00:09 +10:00
Robert Griesemer
20db0f428a go/ast: add Slice3 field to SliceExpr
If Slice3 is set, the expression is
a 3-index slice expression (2 colons).
Required for type-checking.

Backward-compatible API extension.

R=r, rsc
CC=golang-dev
https://golang.org/cl/13826050
2013-09-24 16:35:35 -07:00
Kamil Kisiel
b0ef6aeff9 math/big: Fix variable name in documentation for *Int.Bytes and BitLen.
R=golang-dev, iant, gri
CC=golang-dev
https://golang.org/cl/13869043
2013-09-24 16:32:23 -07:00
Russ Cox
828a4b9376 sync/atomic: adjust for new runtime.cas64 prototype
R=golang-dev, minux.ma, josharian
CC=golang-dev
https://golang.org/cl/13859043
2013-09-24 15:54:48 -04:00
Alex Brainman
b80ef1ab48 net: re-enable raw socket tests on windows
Since CL 38bf89161a72 raw socket tests are not executed
on windows builders. This change re-enable them again.
It will attempt to run raw socket tests only if user
is permitted to create raw socket by OS.

Fixes #6392

R=golang-dev
CC=golang-dev, mikioh.mikioh, rsc
https://golang.org/cl/13422044
2013-09-24 13:15:49 +10:00
Brad Fitzpatrick
0f3ea75020 encoding/json: don't cache value addressability when building first encoder
newTypeEncoder (called once per type and then cached) was
looking at the first value seen of that type's addressability
and caching the encoder decision.  If the first value seen was
addressable and a future one wasn't, it would panic.

Instead, introduce a new wrapper encoder type that checks
CanAddr at runtime.

Fixes #6458

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13839045
2013-09-23 19:57:19 -07:00
Russ Cox
e8bbbe0886 net: ensure that ResolveTCPAddr(addr.String()) reproduces addr
And same for UDP.

Fixes #6465.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13740048
2013-09-23 22:40:24 -04:00
Albert Strasheim
2be62360b2 net: fix Close of autobind unix listener
Fixes #6455.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/13457058
2013-09-23 22:33:42 -04:00
Andrew Gerrand
2d2ae53119 reflect: update docs; Interface can return a method value
Fixes #6460.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13761046
2013-09-24 10:49:54 +10:00
Russ Cox
d9f034dc9e net/http: accept Content-Range for entire file
Fixes a bug reported privately.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13846043
2013-09-23 17:16:59 -04:00
Russ Cox
05ff4d7a1a runtime/pprof: fix profile parser in test
Fixes #6417.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13843043
2013-09-23 16:05:36 -04:00
Russ Cox
bc2c3388f4 crypto/tls: document that the package supports TLS 1.2
Fixes #6456.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13740047
2013-09-23 16:05:23 -04:00
Russ Cox
0fc9db7944 undo CL 13321048 / 9567c5da6e25
Makes build unnecessarily slower. Will fix the parser instead.

««« original CL description
runtime/pprof: run TestGoroutineSwitch for longer

Short test now takes about 0.5 second here.

Fixes #6417.

The failure was also seen on our builders.

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

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13720048
2013-09-23 15:58:35 -04:00
Kamil Kisiel
e07b5baf4f reflect: add example for StructTag
Fix a few minor vet quibbles while I'm here.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13235059
2013-09-23 13:19:08 -04:00
Péter Surányi
3861cb4388 go/build: add go1.2 build tag
Fixes #6449.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13829044
2013-09-23 18:11:25 +10:00
Rob Pike
3e3ed5d978 fmt: one bad index shouldn't spoil them all
In an indexed verb such as %[3]d, if the index is out of range, don't
skip processing the rest of the verbs. The bug was that the bad
index set a bit for the whole format instead of just the verb.

Ok for 1.2 because this is a bug in a 1.2 feature.

Fixes #6434

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13632058
2013-09-23 16:03:57 +10:00
Dmitry Chestnykh
c2b7fb3902 net/http: send correct time in Date header.
Date header indicated that it contained GMT time,
however it actually sent local time. Fixed by
converting time to UTC.

Also fixes incorrect comment in appendTime().

Regression since CL 9432046.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13386047
2013-09-22 19:53:55 -07:00
Dmitriy Vyukov
3ec600d0ca runtime/race: update runtime to r191161.
Fixes #6305.

R=golang-dev, dave, alex.brainman, r
CC=golang-dev
https://golang.org/cl/13359046
2013-09-22 10:56:06 -07:00
Alex Brainman
521dbbfef3 runtime/pprof: run TestGoroutineSwitch for longer
Short test now takes about 0.5 second here.

Fixes #6417.

The failure was also seen on our builders.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/13321048
2013-09-22 17:31:08 +10:00
Russ Cox
551ada4742 runtime: avoid allocation of internal panic values
If a fault happens in malloc, inevitably the next thing that happens
is a deadlock trying to allocate the panic value that says the fault
happened. Stop doing that, two ways.

First, reject panic in malloc just as we reject panic in garbage collection.

Second, runtime.panicstring was using an error implementation
backed by a Go string, so the interface held an allocated *string.
Since the actual errors are C strings, define a new error
implementation backed by a C char*, which needs no indirection
and therefore no allocation.

This second fix will avoid allocation for errors like nil panic derefs
or division by zero, so it is worth doing even though the first fix
should take care of faults during malloc.

Update #6419

R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/13774043
2013-09-20 15:15:25 -04:00
David Symonds
318e165238 crypto/x509: update comment on system root cert locations.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13775045
2013-09-20 15:49:26 +10:00
Rémy Oudompheng
381b72a7a3 cmd/gc: cleanup SWITCH nodes after walk.
Keeping pointers from the pre-walk phase confuses
the race detection instrumentation.

Fixes #6418.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/13368057
2013-09-19 09:23:04 +02:00
Thomas Habets
fefa4f2b89 net/http/cgi: use 'https://' for urls if HTTPS is set.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13700044
2013-09-18 10:48:28 +10:00
Robert Griesemer
0d0c748930 encoding/xml: remove dead code
Avoid future 'declared and not used error'.
See also issue 6414.

R=r
CC=golang-dev
https://golang.org/cl/13242058
2013-09-17 15:24:40 -07:00
Ian Lance Taylor
c757020b55 reflect: test method calls on pointers to pointers
Gccgo got this wrong, and evidently nothing else tests it.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13709045
2013-09-17 15:22:42 -07:00
Adam Langley
eef7035ec8 crypto/tls: don't select ECDSA ciphersuites with only an RSA certificate.
47ec7a68b1a2 added support for ECDSA ciphersuites but didn't alter the
cipher suite selection to take that into account. Thus Go servers could
try and select an ECDSA cipher suite while only having an RSA
certificate, leading to connection failures.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13239053
2013-09-17 13:30:36 -04:00
Josh Bleecher Snyder
eeb758546e text/template/parse, html/template: copy Tree.text during html template clone
The root cause of the panic reported in https://code.google.com/p/go/issues/detail?id=5980
is that parse's Tree.Text wasn't being copied during the clone.

Fix this by adding and using a Copy method for parse.Tree.

Fixes #5980.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12420044
2013-09-17 14:19:44 +10:00
Carl Shapiro
16d6b6c771 runtime: export PCDATA value reader
This interface is required to use the PCDATA interface
implemented in Go 1.2.  While initially entirely private, the
FUNCDATA side of the interface has been made public.  This
change completes the FUNCDATA/PCDATA interface.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13735043
2013-09-16 19:03:19 -07:00
Rémy Oudompheng
045dbeaf05 cmd/gc, runtime: inline append in frontend.
A new transformation during walk turns append calls
into a combination of growslice and memmove.

benchmark                     old ns/op    new ns/op    delta
BenchmarkAppend                     141          141   +0.00%
BenchmarkAppend1Byte                 18           11  -39.56%
BenchmarkAppend4Bytes                19           10  -42.63%
BenchmarkAppend7Bytes                18           10  -42.16%
BenchmarkAppend8Bytes                18           10  -40.44%
BenchmarkAppend15Bytes               19           11  -41.67%
BenchmarkAppend16Bytes               19           11  -41.97%
BenchmarkAppend32Bytes               23           14  -38.82%
BenchmarkAppendStr1Byte              14           10  -23.78%
BenchmarkAppendStr4Bytes             14           11  -21.13%
BenchmarkAppendStr8Bytes             14           10  -25.17%
BenchmarkAppendStr16Bytes            19           11  -41.45%
BenchmarkAppendStr32Bytes            18           14  -19.44%
BenchmarkAppendSpecialCase           62           63   +1.77%

R=golang-dev, khr, cshapiro, rsc, dave
CC=golang-dev
https://golang.org/cl/12815046
2013-09-16 20:31:21 -04:00
Russ Cox
30ecb4cd05 build: disable precise collection of stack frames
The code for call site-specific pointer bitmaps was not ready in time,
but the zeroing required without it is too expensive to use by default.
We will have to wait for precise collection of stack frames until Go 1.3.

The precise collection can be re-enabled by

        GOEXPERIMENT=precisestack ./all.bash

but that will not be the default for a Go 1.2 build.

Fixes #6087.

R=golang-dev, jeremyjackins, dan.kortschak, r
CC=golang-dev
https://golang.org/cl/13677045
2013-09-16 20:26:10 -04:00
Adam Langley
6a1022a094 crypto/tls: fix TLS 1.2 client certificates.
With TLS 1.2, when sending client certificates the code was omitting
the new (in TLS 1.2) signature and hash fields.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13413050
2013-09-16 16:39:42 -04:00
Russ Cox
70138a2108 runtime: fix uint64 division on 386
The uint64 divide function calls _mul64x32 to do a 64x32-bit multiply
and then compares the result against the 64-bit numerator.
If the result is bigger than the numerator, must use the slow path.

Unfortunately, the 64x32 produces a 96-bit product, and only the
low 64 bits were being used in the comparison. Return all 96 bits,
the bottom 64 via the original uint64* pointer, and the top 32
as the function's return value.

Fixes 386 build (broken by ARM division tests).

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13722044
2013-09-16 15:11:32 -04:00
Russ Cox
a70cbf1329 runtime: fix freebsd build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13720044
2013-09-16 14:22:24 -04:00
Russ Cox
d9fdf88f34 net: make all.bat run for ordinary Windows users
This CL is required for all.bat to work out of the box on
my Windows 8 laptop.

These tests either require the firewall to be turned off
or require the user to be in the Administrators group.
I don't know which.

Alex may follow up with a refinement of the test to
allow them to run if the user is in the Administrators
group.

Fixes #6392.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13421049
2013-09-16 14:05:06 -04:00
Russ Cox
647eaed93b cmd/cgo: allow C.malloc(0) always
Because we can, and because it otherwise might crash
the program if we think we're out of memory.

Fixes #6390.

R=golang-dev, iant, minux.ma
CC=golang-dev
https://golang.org/cl/13345048
2013-09-16 14:04:55 -04:00
Russ Cox
b2794a1c2e runtime: make ARM integer div-by-zero traceback-friendly
The implementation of division in the 5 toolchain is a bit too magical.
Hide the magic from the traceback routines.

Also add a test for the results of the software divide routine.

Fixes #5805.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13239052
2013-09-16 14:04:45 -04:00
Russ Cox
555da73c56 runtime, syscall: work around FreeBSD/amd64 kernel bug
The kernel implementation of the fast system call path,
the one invoked by the SYSCALL instruction, is broken for
restarting system calls. A C program demonstrating this is below.

Change the system calls to use INT $0x80 instead, because
that (perhaps slightly slower) system call path actually works.

I filed http://www.freebsd.org/cgi/query-pr.cgi?pr=182161.

The C program demonstrating that it is FreeBSD's fault is below.
It reports the same "Bad address" failures from wait.

#include <sys/time.h>
#include <sys/signal.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

static void handler(int);
static void* looper(void*);

int
main(void)
{
        int i;
        struct sigaction sa;
        pthread_cond_t cond;
        pthread_mutex_t mu;

        memset(&sa, 0, sizeof sa);
        sa.sa_handler = handler;
        sa.sa_flags = SA_RESTART;
        memset(&sa.sa_mask, 0xff, sizeof sa.sa_mask);
        sigaction(SIGCHLD, &sa, 0);

        for(i=0; i<2; i++)
                pthread_create(0, 0, looper, 0);

        pthread_mutex_init(&mu, 0);
        pthread_mutex_lock(&mu);
        pthread_cond_init(&cond, 0);
        for(;;)
                pthread_cond_wait(&cond, &mu);

        return 0;
}

static void
handler(int sig)
{
}

int
mywait4(int pid, int *stat, int options, struct rusage *rusage)
{
        int result;

        asm("movq %%rcx, %%r10; syscall"
                : "=a" (result)
                : "a" (7),
                  "D" (pid),
                  "S" (stat),
                  "d" (options),
                  "c" (rusage));
}

static void*
looper(void *v)
{
        int pid, stat, out;
        struct rusage rusage;

        for(;;) {
                if((pid = fork()) == 0)
                        _exit(0);
                out = mywait4(pid, &stat, 0, &rusage);
                if(out != pid) {
                        printf("wait4 returned %d\n", out);
                }
        }
}

Fixes #6372.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13582047
2013-09-16 14:04:32 -04:00
Han-Wen Nienhuys
ab578e12ff net/rpc: log I/O and internal errors only if debugLog is set.
Fixes #6367.

R=rsc, r
CC=golang-dev
https://golang.org/cl/13395047
2013-09-16 16:29:04 +10:00
Andrew Gerrand
49eeef5927 sort: move example to package level and simplify further
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13634044
2013-09-16 13:02:01 +10:00
Rob Pike
1fba73de45 encoding/gob: ignore chan and func fields of structures
Previously, fields of type chan or func caused an error.
Now we just treat them like unexported fields and ignore them.
This makes it easier to guarantee long-term compatibilty since
a substructure from another package cannot break gob
encoding by adding a func or chan field.

Fixes #6071

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13693043
2013-09-16 10:26:23 +10:00
Russ Cox
6d68fc8eea runtime: fix CPU profiling on Windows
The test 'gp == m->curg' is not valid on Windows,
because the goroutine being profiled is not from the
current m.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/13718043
2013-09-15 12:05:24 -04:00
Russ Cox
aa53b37fa6 go/build: add ctxt.MatchFile
Fixes #6369.

R=dsymonds, r
CC=golang-dev
https://golang.org/cl/13708043
2013-09-15 11:29:47 -04:00
Russ Cox
1385e394cf encoding/xml: document behavior for undefined name space prefixes
Fixes #5626.

R=golang-dev, dominik.honnef
CC=golang-dev
https://golang.org/cl/13702043
2013-09-15 11:29:06 -04:00
Rob Pike
89dacb9cca fmt: %b for complex64 and complex128
Just an oversight they were missing.
Fixes #6387

R=golang-dev, dominik.honnef, rsc
CC=golang-dev
https://golang.org/cl/13715043
2013-09-15 10:45:36 +10:00
Russ Cox
22e8f82e8d os/exec: add more caveats to StdoutPipe, StderrPipe
(StdinPipe was taken care of by CL 13329043.)

Fixes #6008.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13606046
2013-09-13 15:43:54 -04:00
Russ Cox
439f9397fc runtime: avoid inconsistent goroutine state in profiler
Because profiling signals can arrive at any time, we must
handle the case where a profiling signal arrives halfway
through a goroutine switch. Luckily, although there is much
to think through, very little needs to change.

Fixes #6000.
Fixes #6015.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13421048
2013-09-13 14:19:23 -04:00
Russ Cox
7fb3d8e45e reflect: document FieldByName shortcoming
Fixes #4876.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13701044
2013-09-13 13:56:39 -04:00
Dave Cheney
bd9cd6e30e syscall: add TCIOFLUSH family of constants
Fixes #6355.

zerrors_linux_{386,amd64,arm}.go were regenerated using mkerrors.sh but I opted to add the three TC.*FLUSH lines by hand to keep the diff smaller and avoid problems with the API checker.

I'll check freebsd and darwin, could I ask for help with net/open bsd.

R=mikioh.mikioh, jsing, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/13660043
2013-09-13 15:01:22 +10:00
Rob Pike
c842e43ef6 text/template/parse: mostly roll back the error detection for unmatched right delimiters
It's too late to change this behavior: it breaks templates with minimized JavaScript.

Makes me sad because this common error can never be caught: "{foo}}".
Three cheers for compatibility.

(Leave in a fix to a broken test.)

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13689043
2013-09-13 12:44:45 +10:00
Russ Cox
3c11dd8ebc encoding/xml: add Encoder.Flush
Fixes #6365.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13627046
2013-09-12 16:54:01 -04:00
Russ Cox
7276c02b41 runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:

Issue 5406 identified an interesting case:
        defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.

[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]

Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.

Bug #2:

The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.

Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.

Fixes #5406.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 14:00:16 -04:00
Josh Bleecher Snyder
1ea0c480dc go/token: rename RemoveLine to MergeLine, improve documentation
This is a follow-up to feedback from gri in
https://golang.org/cl/12837044/. Most of the wording
and naming improvements are lifted shamelessly from him.

R=gri
CC=golang-dev
https://golang.org/cl/13670043
2013-09-12 09:31:07 -07:00
Nicholas Sullivan
4874bc9b76 crypto/x509: allow ECDSA public keys to be marshaled.
The public key serialization from CreateCertificate is factored out to be
used in MarshalPKIXPublicKey.
Testcode with one P224 ECDSA keypair has been added.

R=golang-dev, agl
CC=agl, golang-dev
https://golang.org/cl/13427044
2013-09-12 12:23:34 -04:00
Han-Wen Nienhuys
1e71e74262 net/rpc: document thread safety requirements of codec types.
Fixes #6306.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/13474043
2013-09-12 22:03:53 +10:00
Brad Fitzpatrick
1a819be590 net/http: document ServeMux handling of pattern "/"
Fixes #4799

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/13457047
2013-09-12 11:20:16 +01:00
Rob Pike
caa462137a text/template: catch unmatched right delimiter
It was simply a missing error case: when scanning plain text
outside of an action, a right delimiter should be an error.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13468045
2013-09-12 13:22:56 +10:00
Mikio Hara
fe62a1f1fe net: move mock ICMP into separate file
This is in prepartion for fixing issue 6320.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13611043
2013-09-12 11:59:18 +09:00
Mikio Hara
81737a9a51 net: make TestDialFailPDLeak shorter
Reduces a number of trials but it still can detect memory leak
when we make blunders in runtime-integarted network poller work,
like just forgetting to call runtime_pollClose in code paths.

Also disables the test on windows/386.

R=alex.brainman, r
CC=golang-dev
https://golang.org/cl/13022046
2013-09-12 11:10:25 +09:00
Russ Cox
bab302dea2 undo CL 13348045 / 43675523c526
There is no reason to do this, and it's more work.

««« original CL description
net: make channel-based semaphore depend on receive, not send

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

»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13632047
2013-09-11 20:29:22 -04:00
Russ Cox
7f6a7e22a8 net/http: explain the "1.1" in the default User-Agent
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13263052
2013-09-11 20:28:14 -04:00
Rémy Oudompheng
ff416a3f19 cmd/gc: inline copy in frontend to call memmove directly.
A new node type OSPTR is added to refer to the data pointer of
strings and slices in a simple way during walk(). It will be
useful for future work on simplification of slice arithmetic.

benchmark                  old ns/op    new ns/op    delta
BenchmarkCopy1Byte                 9            8  -13.98%
BenchmarkCopy2Byte                14            8  -40.49%
BenchmarkCopy4Byte                13            8  -35.04%
BenchmarkCopy8Byte                13            8  -37.10%
BenchmarkCopy12Byte               14           12  -15.38%
BenchmarkCopy16Byte               14           12  -17.24%
BenchmarkCopy32Byte               19           14  -27.32%
BenchmarkCopy128Byte              31           26  -15.29%
BenchmarkCopy1024Byte            100           92   -7.50%
BenchmarkCopy1String              10            7  -28.99%
BenchmarkCopy2String              10            7  -28.06%
BenchmarkCopy4String              10            8  -22.69%
BenchmarkCopy8String              10            8  -23.30%
BenchmarkCopy12String             11           11   -5.88%
BenchmarkCopy16String             11           11   -5.08%
BenchmarkCopy32String             15           14   -6.58%
BenchmarkCopy128String            28           25  -10.60%
BenchmarkCopy1024String           95           95   +0.53%

R=golang-dev, bradfitz, cshapiro, dave, daniel.morsing, rsc, khr, khr
CC=golang-dev
https://golang.org/cl/9101048
2013-09-12 00:15:28 +02:00
Russ Cox
ce9ddd0eee runtime: keep args and frame in struct Func
args is useful for printing tracebacks.

frame is not necessary anymore, but we might some day
get back to functions where the frame size does not vary
by program counter, and if so we'll need it. Avoid needing
to introduce a new struct format later by keeping it now.

Fixes #5907.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13632051
2013-09-11 14:18:52 -04:00
Russ Cox
611b182190 go/build: reject directory with only cgo files if cgo not in use
The old test for "no Go files" was p.Name == "", meaning we never
saw a Go package statement. That test fails if there are cgo files
that we parsed (and recorded the package name) but then chose
not to use (because cgo is not available).

Test the actual file lists instead.

Fixes #6078.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13661043
2013-09-11 13:25:30 -04:00
Russ Cox
ab38e2a498 runtime: show m stack during crash on m stack
The various throwing > 0 finish a change started
in a previous CL, which sets throwing = -1 to mean
"don't show the internals". That gets set during the
"all goroutines are asleep - deadlock!" crash, and it
should also be set during any other expected crash
that does not indicate a problem within the runtime.

Most runtime.throw do indicate a problem within the
runtime, however, so we should be able to enumerate
the ones that should be silent. The goroutine sleeping
deadlock is the only one I can think of.

Update #5139

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13662043
2013-09-11 12:00:37 -04:00
Russ Cox
fa4984d535 runtime: show runtime.panic frame in traceback
Otherwise, if panic starts running deferred functions,
the code that panicked appears to be calling those
functions directly, which is not the case and can be
confusing.

For example:

main.Two()
        /Users/rsc/x.go:12 +0x2a
runtime.panic(0x20dc0, 0x2100cc010)
        /Users/rsc/g/go/src/pkg/runtime/panic.c:248 +0x106
main.One()
        /Users/rsc/x.go:8 +0x55

This makes clear(er) that main.Two is being called during
a panic, not as a direct call from main.One.

Fixes #5832.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13302051
2013-09-11 11:59:19 -04:00
Russ Cox
382738af51 net: defend against broken getaddrinfo on Linux
getaddrinfo is supposed to set errno when it returns
EAI_SYSTEM, but sometimes it does not.

Fixes #6232.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13532045
2013-09-11 11:38:56 -04:00
Russ Cox
397ba2cb4a cmd/cgo: replace C.malloc with our own wrapper
This allows us to make two changes:

1. Force the argument type to be size_t, even on broken
   systems that declare malloc to take a ulong.

2. Call runtime.throw if malloc fails.
   (That is, the program crashes; it does not panic.)

Fixes #3403.
Fixes #5926.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13413047
2013-09-11 11:30:08 -04:00
Mikio Hara
89b26760d7 net: implement TCP connection setup with fast failover
This CL adds minimal support of Happy Eyeballs-like TCP connection
setup to Dialer API. Happy Eyeballs and derivation techniques are
described in the following:

- Happy Eyeballs: Success with Dual-Stack Hosts
  http://tools.ietf.org/html/rfc6555

- Analysing Dual Stack Behaviour and IPv6 Quality
  http://www.potaroo.net/presentations/2012-04-17-dual-stack-quality.pdf

Usually, the techniques consist of three components below.

- DNS query racers, that run A and AAAA queries in parallel or series
- A short list of destination addresses
- TCP SYN racers, that run IPv4 and IPv6 transport in parallel or series

This CL implements only the latter two. The existing DNS query
component gathers together A and AAAA records in series, so we don't
touch it here. This CL just uses extended resolveInternetAddr and makes
it possible to run multiple Dial racers in parallel.

For example, when the given destination is a DNS name and the name has
multiple address family A and AAAA records, and it happens on the TCP
wildcard network "tcp" with DualStack=true like the following:

(&net.Dialer{DualStack: true}).Dial("tcp", "www.example.com:80")

The function will return a first established connection either TCP over
IPv4 or TCP over IPv6, and close the other connection internally.

Fixes #3610.
Fixes #5267.

Benchmark results on freebsd/amd64 virtual machine, tip vs. tip+12416043:

benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                    50696        52141   +2.85%
BenchmarkTCP4OneShotTimeout             65775        66426   +0.99%
BenchmarkTCP4Persistent                 10986        10457   -4.82%
BenchmarkTCP4PersistentTimeout          11207        10445   -6.80%
BenchmarkTCP6OneShot                    62009        63718   +2.76%
BenchmarkTCP6OneShotTimeout             78351        79138   +1.00%
BenchmarkTCP6Persistent                 14695        14659   -0.24%
BenchmarkTCP6PersistentTimeout          15032        14646   -2.57%
BenchmarkTCP4ConcurrentReadWrite         7215         6217  -13.83%
BenchmarkTCP6ConcurrentReadWrite         7528         7493   -0.46%

benchmark                          old allocs   new allocs    delta
BenchmarkTCP4OneShot                       36           36    0.00%
BenchmarkTCP4OneShotTimeout                36           36    0.00%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                       37           37    0.00%
BenchmarkTCP6OneShotTimeout                37           37    0.00%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

benchmark                           old bytes    new bytes    delta
BenchmarkTCP4OneShot                     2500         2503    0.12%
BenchmarkTCP4OneShotTimeout              2508         2505   -0.12%
BenchmarkTCP4Persistent                     0            0     n/a%
BenchmarkTCP4PersistentTimeout              0            0     n/a%
BenchmarkTCP6OneShot                     2713         2707   -0.22%
BenchmarkTCP6OneShotTimeout              2722         2720   -0.07%
BenchmarkTCP6Persistent                     0            0     n/a%
BenchmarkTCP6PersistentTimeout              0            0     n/a%
BenchmarkTCP4ConcurrentReadWrite            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite            0            0     n/a%

R=golang-dev, bradfitz, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12416043
2013-09-11 10:48:53 -04:00
Dave Cheney
3ee0744c06 bytes: additional test coverage
Add coverage for some uncovered bytes methods. The increase in actual coverage is disapointing small.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13651044
2013-09-11 21:20:15 +10:00
Russ Cox
6706931a71 go/doc: restore handling of multi-paragraph BUG comments
It was lost when the generic "Notes" support went in.

Had to change the test setup, because it precluded even
being able test multi-line comments, much less multi-paragraph
comments.

Now 'godoc sync/atomic' works correctly again.

Fixes #6135.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13427045
2013-09-10 14:41:20 -04:00
Russ Cox
d5fbad0de8 cmd/go: better error for shadowed directories in GOPATH
Fixes #5774.

R=golang-dev, adg, r, bradfitz
CC=golang-dev
https://golang.org/cl/9164043
2013-09-10 13:17:21 -04:00
Alexis Imperial-Legrand
927b7ac327 runtime: explicit init of runtime-gdb helpers
If using other gdb python scripts loaded before Go's gdb-runtime.py
and that have a different init prototype:
Traceback (most recent call last):
  File "/usr/lib/go/src/pkg/runtime/runtime-gdb.py", line 446, in <module>
    k()
TypeError: __init__() takes exactly 3 arguments (1 given)

The problem is that gdb keeps all python scripts in the same namespace,
so vars() contains them. To avoid that, load helpers one by one.

R=iant, rsc
CC=gobot, golang-dev
https://golang.org/cl/9752044
2013-09-10 13:00:08 -04:00
Russ Cox
c971f95c10 go/build: allow $ in cgo LDFLAGS
Fixes #6038.

R=iant
CC=golang-dev
https://golang.org/cl/13649043
2013-09-10 12:47:43 -04:00
Keith Randall
4487054751 runtime: clean up / align comment tabbing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13336046
2013-09-10 09:02:22 -07:00
Mikio Hara
02faa939d3 net: remove dreg of obsoleted network poller
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13396051
2013-09-10 20:00:21 +09:00
Alex Brainman
a6149da08a os/exec: change windows LookPath so it works like cmd.exe
Fixes #6224

R=golang-dev, hcwfrichter, bradfitz
CC=golang-dev
https://golang.org/cl/13410045
2013-09-10 14:50:29 +10:00
Russ Cox
5d2c3a687c encoding/json: document actual behavior for Unmarshal into interface{}
Fixes #4900.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13400044
2013-09-09 19:11:05 -04:00
Richard Eric Gavaletz
7adb42eee4 container/list: unexpected panic if Next/Prev called outside of list.
Before CL 7065067 calling Next on an element returned either the
next/prev element or nil was returned.  After the CL if an element
was not part of a list e.Next() and e.Prev() will panic.  This CL
returns to the documented behavior, that Next/Prev returns the
next/prev list element or nil.

Fixes #6349.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/13234051
2013-09-09 15:41:36 -07:00
Russ Cox
5dc8c4dbfb path/filepath: fix race with other tests
Bug3486 tried to walk the entire file tree, but other tests might
be creating and removing files in that tree. In particular, package os
creates and removes files in the os directory, and issue 5863
reports failures due to seeing those files appear and then disappear.

Change the test to walk just the test tree, which should not be
changing.

Fixes #5863.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13467045
2013-09-09 16:42:18 -04:00
Russ Cox
10c36fbc9d encoding/xml: fix panic in Marshal
Fixes #6341.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13512048
2013-09-09 16:42:07 -04:00
Russ Cox
1b651556c3 syslog: fix data race on 'crashy' in test function
Fixes #5894.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303051
2013-09-09 16:17:59 -04:00
Russ Cox
87a6d75012 log/syslog: use alternate format for logging to local syslog daemon
Fixes #5803.
Is it correct behavior? Who knows.

R=golang-dev, bradfitz, jgc
CC=golang-dev, jgc
https://golang.org/cl/13248048
2013-09-09 16:17:44 -04:00
Russ Cox
6252b41981 runtime: remove OABI check from ARM startup
The code in question is trying to print a nice error message
when a Go EABI binary runs on an OABI machine.
Unfortunately, the only way to do that is to use
ARM Thumb instructions, which we otherwise don't use.

There exist ARM EABI machines that do not support Thumb.
We could run on them if not for this OABI check, so disable it.

Fixes #5685.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13234050
2013-09-09 15:06:05 -04:00
Joel Sing
3b089179c4 runtime: unbreak build on dragonfly
Update dragonfly memory functions to work with new memory statistics.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13615043
2013-09-09 08:48:06 -07:00
Alex Brainman
5f75314e18 time: allow more time for TestOverflowRuntimeTimer to succeed
Attempting to fix windows gobuilders

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13507044
2013-09-09 15:50:11 +10:00
Dominik Honnef
a789ae9e8e compress/flate: small documentation fix
R=golang-dev, adg
CC=bradfitz, golang-dev, remyoudompheng
https://golang.org/cl/13568045
2013-09-09 09:37:05 +10:00
Robert Daniel Kortschak
c01945afc9 sort: fix up example expected output formatting
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13426046
2013-09-08 13:21:03 +10:00
Andriy Lytvynov
467122ce0b sort: add a simpler sort.Interface example
Existing example renamed to Example_sortWrapper.
Fixes #6335.

R=golang-dev, rsc, taj.khattra, r
CC=golang-dev
https://golang.org/cl/13586043
2013-09-08 11:17:23 +10:00
Keith Randall
78338d8c66 runtime: Smhasher tests of our map hash function.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13436045
2013-09-06 16:23:46 -07:00
Brad Fitzpatrick
da7a51d16b net: don't error when marshalling nil IP addresses
See https://code.google.com/p/go/issues/detail?id=6339#c3

Fixes #6339

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13553044
2013-09-06 15:29:09 -07:00
Ehren Kret
3b6b53f493 compress/flate: prevent panic when reinitializing huffmanDecoder with bad input
The huffmanDecoder struct appears to be intented for reuse by calling init a
second time with a second sequence of code lengths. Unfortunately, it can
currently panic if the second sequence of code lengths has a minimum value
greater than 10 due to failure to reinitialize the links table.

This change prevents the panic by resetting the huffmanDecoder struct back to
the struct's zero value at the beginning of the init method if the
huffmanDecoder is being reused (determined by checking if min has been set to a
non-zero value).

Fixes #6255.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13230043
2013-09-06 15:09:42 -07:00
Dmitriy Vyukov
a33ef8d11b runtime: account for all sys memory in MemStats
Currently lots of sys allocations are not accounted in any of XxxSys,
including GC bitmap, spans table, GC roots blocks, GC finalizer blocks,
iface table, netpoll descriptors and more. Up to ~20% can unaccounted.
This change introduces 2 new stats: GCSys and OtherSys for GC metadata
and all other misc allocations, respectively.
Also ensures that all XxxSys indeed sum up to Sys. All sys memory allocation
functions require the stat for accounting, so that it's impossible to miss something.
Also fix updating of mcache_sys/inuse, they were not updated after deallocation.

test/bench/garbage/parser before:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14204928
MCacheSys	16384
BuckHashSys	1439992

after:
Sys		670064344
HeapSys		610271232
StackSys	65536
MSpanSys	14188544
MCacheSys	16384
BuckHashSys	3194304
GCSys		39198688
OtherSys	3129656

Fixes #5799.

R=rsc, dave, alex.brainman
CC=golang-dev
https://golang.org/cl/12946043
2013-09-06 16:55:40 -04:00
Marco Hennings
4e998d71c9 archive/tar: fix a case where USTAR-split is not working correctly.
For some long filenames the USTAR-split code does not work
correctly. It is wrongly assumed that the path would not be too long,
but it is.

The user visible result was that a filename was split, but it still
caused an error.

The cause was a wrongly calculated nlen. In addition I noticed that
at this place it is also seems necessary to check if the prefix will
fit in the 155 chars available for the prefix.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/13300046
2013-09-06 16:49:38 -04:00
Andriy Lytvynov
fb25a61872 sort: fix Example_sortMultiKeys
Old example referenced global var from multiSorter.Sort and ignored it's argument.
Changed one of example calls to actually pass slice to sort.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13551044
2013-09-06 16:49:34 -04:00
Josh Bleecher Snyder
08925ce6ee cmd/gofmt: sort more, remove some duplicate imports
* Sort imports by import path, then import name, then comment. Currently, gofmt sorts only by import path.
* If two imports have the same import path and import name, and one of them has no comment, remove the import with no comment. (See the discussion at issue 4414.)

Based on @rsc's https://golang.org/cl/7231070/

Fixes #4414.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/12837044
2013-09-06 16:25:15 -04:00
Anthony Martin
3548ab5ebb runtime: handle timer overflow in tsleep
Make sure we never pass a timer into timerproc with
a negative duration since it will cause other timers
to never expire.

Fixes #5321.

R=golang-dev, minux.ma, remyoudompheng, mikioh.mikioh, r, bradfitz, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/9035047
2013-09-06 15:47:39 -04:00
Brad Fitzpatrick
da50221e8e reflect: unexport BUCKETSIZE, MAXKEYSIZE, MAXVALSIZE
But keep their case for ease of searching.

They were added recently. We don't want them part of go1.2's API.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13569044
2013-09-06 12:00:42 -07:00
Brad Fitzpatrick
c327e82ddb crypto/rand: make Read use io.ReadFull
Fixes #6084

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/13523044
2013-09-06 12:00:27 -07:00
Kamil Kisiel
a3834a2e8a net: Fix inaccurate docs for AcceptTCP and AcceptUnix.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13592043
2013-09-06 12:00:03 -07:00
Rob Pike
46f96079df undo CL 13004046 / 5db14b33d6ef
Flushing after every token negates the point of buffering. A different approach is required.

««« original CL description
encoding/xml: flush buffer after encoding token

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

»»»

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/13515043
2013-09-06 07:54:43 +10:00
Rémy Oudompheng
86c0cf10cb compress/zlib: add Reset method to Writer.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13171046
2013-09-05 21:50:47 +02:00
Rémy Oudompheng
780f5b714d reflect: do not cache trivial values in DeepEqual.
DeepEqual caches addresses of compared values
each time it visits addressable values. This is
more expensive than actually comparing them in
the common case of large slices of bytes or integers.

Also add a fast path for slices with identical
underlying array.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13000044
2013-09-05 21:37:07 +02:00
Brad Fitzpatrick
fca660892d compress/flate: use bytes.NewReader instead of NewBuffer in test
Also, report allocations in benchmark.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13410044
2013-09-04 15:31:46 -07:00
Rob Pike
80f39f7b73 html/template: export the parse.Tree for the escaped template
The underlying parse tree is visible in text/template, so it should be visible here.
Done by copying the underlying *parse.Tree up to the top level of the struct, and then making sure it's kept up to date.
Fixes #6318.

R=mikesamuel
CC=golang-dev
https://golang.org/cl/13479044
2013-09-05 08:23:11 +10:00
Aulus Egnatius Varialus
2b44b36487 cgo: enable cgo on dragonfly
Enable cgo for dragonfly/386 and dragonfly/amd64.

R=golang-dev, jsing, iant, bradfitz
CC=golang-dev
https://golang.org/cl/13247046
2013-09-04 15:19:21 -07:00
Rob Pike
0ba7ffe289 text/template: allow eq to take more than two arguments
Based on an old suggestion by rsc, it compares the second
and following arguments to the first.

Unfortunately the code cannot be as pretty as rsc's original
because it doesn't require identical types.

R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/13509046
2013-09-04 13:42:22 +10:00
Mikio Hara
54b2a83d9a net/http: remove dreg of obsoleted network poller
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13261049
2013-09-04 10:04:12 +09:00
Brad Fitzpatrick
8272c14f7e net/http: sniff less
We were reading 1024 bytes but only using 512.

Fixes #6311

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13289047
2013-09-03 09:11:25 -07:00
Mikio Hara
c576bcbad5 net: fix TestFirstFavoriteAddr failure on single IP stack kernel
Update #3610
Update #5267
Update #5707

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13465043
2013-09-02 16:44:51 +09:00
Keith Randall
23f9751e83 runtime: clean up map code. Remove hashmap.h.
Use cnew/cnewarray instead of mallocgc.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13396045
2013-08-31 14:09:34 -07:00
Joel Sing
465ba6b78c runtime, syscall: add support for dragonfly/386
Add runtime and syscall support for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13237051
2013-08-31 09:32:07 -07:00
Joel Sing
f6f02a69ae syscall: z* files for dragonfly/386
Add generated z* files for dragonfly/386.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13303046
2013-08-31 09:29:38 -07:00
Keith Randall
fb376021be runtime: record type information for hashtable internal structures.
Remove all hashtable-specific GC code.

Fixes bug 6119.

R=cshapiro, dvyukov, khr
CC=golang-dev
https://golang.org/cl/13078044
2013-08-31 09:09:50 -07:00
Mikio Hara
29de03adf3 net: keep lookup IP stuff close
Also flattens import declaration.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/13373046
2013-08-31 16:29:50 +09:00
Mikio Hara
7c59c8bdee net: make resolveInternetAddr return a list of addresses
This CL makes resolveInternetAddr return a list of addresses that
contain a pair of different address family IP addresses if possible,
but doesn't contain any API behavioral changes yet. A simple IP
address selection mechanism for Resolve{TCP,UDP,IP}Addr and Dial API
still prefers IPv4.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13374043
2013-08-31 10:28:49 +09:00
Brad Fitzpatrick
db12f9d4e4 compress/gzip: add Writer.Reset
compress/flate is https://golang.org/cl/12953048
compress/zlib is https://golang.org/cl/13171046

Update #6138

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13435043
2013-08-30 11:41:12 -07:00
Tad Glines
41c5d8d85f database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added separate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-30 09:27:33 -07:00
Adam Langley
87404c9887 crypto/x509: expose arbitary X.509 extensions.
This change allows people who want to parse or set odd X.509 extensions
to do so without having to add support for them all to the package.

I tried to make it so that only a single member: Extensions would be
needed. However, that would mean detecting when the caller had altered
the contents of it so that parsing and marshaling a certificate
wouldn't ignore all changes to the other members. This ended up being
messy, thus the current design where there are two members: one for
reading and another for writing.

As crypto/x509 adds support for more extensions in the future, the raw
extensions will still be in Extensions for older code that expects it
there. Also, future extensions will be overridden by any raw extensions
added to ExtraExtensions by code that was written before support was
added.

R=golang-dev, r
CC=golang-dev, jpsugar
https://golang.org/cl/12056043
2013-08-30 10:14:45 -04:00
Nigel Tao
2df3d80037 go/build: fix deps_test for Plan 9's os/user dependencies and to
include the new image/color/palette package.

R=r
CC=golang-dev
https://golang.org/cl/13314044
2013-08-30 17:12:42 +10:00
Nigel Tao
aeb8b45866 image/color/palette: move Plan9Palette and WebSafePalette out of the
image/color package into their own package. They require some non-
trivial init-time code (interface conversions, currently 40KiB of text)
that would otherwise burden any Go program that imported image/color.

R=r
CC=golang-dev
https://golang.org/cl/13256046
2013-08-30 16:03:16 +10:00
Mikio Hara
20692c22d7 net: add addrList
This CL adds a new type addrList that will carry a short list of IP
addresses to dial helper functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13241046
2013-08-30 09:28:26 +09:00
Brad Fitzpatrick
9456adb36b undo CL 10726044 / c9bea548fb6f
Breaks build, and has a race.

««« original CL description
database/sql: add SetMaxOpenConns

Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

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

»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13252046
2013-08-29 17:26:00 -07:00
Tad Glines
4572e48483 database/sql: add SetMaxOpenConns
Update #4805

Add the ability to set an open connection limit.
Fixed case where the Conn finalCloser was being called with db.mu locked.
Added seperate benchmarks for each path for Exec and Query.
Replaced slice based idle pool with list based idle pool.

R=bradfitz
CC=golang-dev
https://golang.org/cl/10726044
2013-08-29 17:20:39 -07:00
Mikio Hara
3c6558ad90 net: add netaddr interface
This CL adds the netaddr interface that will carry a single network
endpoint address or a short list of IP addresses to dial helper
functions in the upcoming CLs.

This is in preparation for TCP connection setup with fast failover on
dual IP stack node as described in RFC 6555.

Update #3610
Update #5267

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13368044
2013-08-30 09:09:45 +09:00
Keith Randall
32b770b2c0 runtime: jump to badmcall instead of calling it.
This replaces the mcall frame with the badmcall frame instead of
leaving the mcall frame on the stack and adding the badmcall frame.
Because mcall is no longer on the stack, traceback will now report what
called mcall, which is what we would like to see in this situation.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13012044
2013-08-29 15:53:34 -07:00
Brad Fitzpatrick
90351506d4 regexp/syntax: optimize EmptyOpContext
Minor. Saw this in a profile at few percent of CPU and was
curious what it was. Improves overall regexp benchmarks
anywhere from 0 to 3%, but they're a pain to run. You need to
run them in isolation for long runs to get stable numbers.

benchmark                  old ns/op    new ns/op    delta
BenchmarkEmptyOpContext          537          473  -11.92%

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13407043
2013-08-29 14:31:10 -07:00
Adam Langley
2fe9a5a3e8 crypto/tls: support AES-GCM.
AES-GCM is the only current TLS ciphersuite that doesn't have
cryptographic weaknesses (RC4), nor major construction issues (CBC mode
ciphers) and has some deployment (i.e. not-CCM).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13249044
2013-08-29 17:18:59 -04:00
Brad Fitzpatrick
c4aa9c5c4e regexp: fix a benchmark case
I noticed that this one benchmark in particular was very
noisy.  Looking into it, I saw that the table was wrong
and inconsistent with the lines above and below.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/13393045
2013-08-29 13:55:30 -07:00
Shenghou Ma
716a409b90 net/http: redirect handlers from mux.Handler() shouldn't clear the query string
R=bradfitz, alberto.garcia.hierro, rsc, adg
CC=golang-dev
https://golang.org/cl/7099045
2013-08-29 13:55:12 -07:00
Carl Shapiro
c51152f438 runtime: check bitmap word for allocated bit in markonly
When searching for an allocated bit, flushptrbuf would search
backward in the bitmap word containing the bit of pointer
being looked-up before searching the span.  This extra check
was not replicated in markonly which, instead, after not
finding an allocated bit for a pointer would directly look in
the span.

Using statistics generated from godoc, before this change span
lookups were, on average, more common than word lookups.  It
was common for markonly to consult spans for one third of its
pointer lookups.  With this change in place, what were
previously span lookups are overwhelmingly become by the word
lookups making the total number of span lookups a relatively
small fraction of the whole.

This change also introduces some statistics gathering about
lookups guarded by the CollectStats enum.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/13311043
2013-08-29 13:52:38 -07:00
Keith Randall
ed467db6d8 cmd/cc,runtime: change preprocessor to expand macros inside of
#pragma textflag and #pragma dataflag directives.
Update dataflag directives to use symbols instead of integer constants.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13310043
2013-08-29 12:36:59 -07:00
Rémy Oudompheng
f5f0e40e80 compress/flate: implement Reset method on Writer.
Fixes #6138.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12953048
2013-08-29 21:09:23 +02:00
Robert Daniel Kortschak
b3fd434ae0 net: make channel-based semaphore depend on receive, not send
R=r, dvyukov
CC=golang-dev
https://golang.org/cl/13348045
2013-08-29 17:14:57 +10:00
Andrew Gerrand
27f4166e37 undo CL 13180043 / 318540e7857f
Accidentally submitted.

««« original CL description
encoding/json: add "overflow" struct tag option

Fixes #6213.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/13180043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/13234045
2013-08-29 14:45:59 +10:00
Andrew Gerrand
10e2ffdf2c os/exec: return idempotent Closer from StdinPipe
Before this fix, it was always an error to use the Close method on the
io.WriteCloser obtained from Cmd.StdinPipe, as it would race with the
Close performed by Cmd.Wait.

Fixes #6270.

R=golang-dev, r, remyoudompheng, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/13329043
2013-08-29 14:41:44 +10:00
Andrew Gerrand
466001d05d encoding/json: add "overflow" struct tag option
Fixes #6213.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/13180043
2013-08-29 14:39:55 +10:00
Dave Cheney
9169372749 sort: use a very fast random generator for benchmarks
Adapted from https://golang.org/cl/11564044.

Fixes breakage of darwin-amd64-race builder.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13352045
2013-08-29 13:21:21 +10:00
Rob Pike
7c7d22ac5f runtime: re-enable TestParForParallel
See how it flies. We'll disable it again if the underlying issue is not resolved.
See issue 4155 for details.

Fixes #4155.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13368045
2013-08-29 11:42:18 +10:00
Mikio Hara
e4bb139e75 net: make protocol-specific Dial and Listen return consistent error value
Update #4856

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/12916046
2013-08-28 19:51:02 +09:00
Mikio Hara
a8b4a1e63a net: BUG section for ReadFrom, ReadFromIP methods of IPConn on "ip4" network
Fixes #3944.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13263043
2013-08-28 19:49:17 +09:00
Robin Eklind
cfb02f7b74 fmt: Remove some unnecessary conversions.
R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/12795052
2013-08-28 11:55:39 -07:00
Brad Fitzpatrick
8159b6901f time: add more docs on Sleep
Merge the comment from runtime/time.goc ("at least")
and also note that negative is okay and won't crash.
I see people going out of their way to avoid passing
a negative value to Sleep.

R=golang-dev, adg, r, alex.brainman
CC=golang-dev
https://golang.org/cl/13271045
2013-08-28 11:16:55 -07:00
Rob Pike
37cee77ac6 text/template: allow {{else if ... }} to simplify if chains
The method is simple: the parser just parses

        {{if A}}a{{else if B}}b{{end}}

to the same tree that would be produced by

        {{if A}}a{{else}}{{if B}}b{{end}}{{end}}

Thus no changes are required in text/template itself
or in html/template, only in text/template/parse.

Fixes #6085

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13327043
2013-08-28 14:43:56 +10:00
Josh Bleecher Snyder
cbea724378 sync: improve once.Do documentation readability
The previous wording, though accurate, was hard to parse.
In particular, it was tempting to interpret "the method"
as referring to "the function f" instead of "Do", and
required effort to find the correct antecedent for
"this receiver".

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/13307043
2013-08-28 12:53:59 +10:00
Brad Fitzpatrick
2ede818ae0 net/http: document Request.Body more
Fixes #6221

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13289043
2013-08-27 16:13:21 -07:00
Brad Fitzpatrick
c7c1a1bbaa net/smtp: clarify that SendMail's auth param is optional
It wasn't obvious that the Auth could be nil.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13060048
2013-08-27 16:12:11 -07:00
Caleb Spare
8b047893a0 go/ast: fix comment formatting
A bullet list was getting mangled in godoc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13060047
2013-08-27 09:03:38 -07:00
Volker Dobler
2f81dfd53f sort: harden limit in stable test
Reduce the number of allowed swap operations during stable sort. 

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12907045
2013-08-27 08:41:43 -07:00
Mathieu Lonjaret
d5c806d581 encoding/binary: use bytes.Reader in read example
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/13274043
2013-08-27 06:32:24 -07:00
Alex Brainman
11320fa500 net: have separate read and write processing threads on windows
Fixes #4195

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12960046
2013-08-27 14:53:57 +10:00
Rob Pike
1f661fc205 text/template: make the escapers for HTML etc. handle pointers correctly
Apply the same rules for argument evaluation and indirection that are
used by the regular evaluator.

Fixes #5802

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13257043
2013-08-27 13:29:07 +10:00
Mikio Hara
519a9e8e9b net: enable PacketConn test for raw IP network on Windows
Just forgot to include this in CL 12843043.
Also consolidates the code dealing with test environment.

Update #6122

R=alex.brainman
CC=golang-dev
https://golang.org/cl/13184043
2013-08-26 18:36:58 +09:00
Evan Shaw
f033d988b1 bytes, strings: use copy in Repeat
R=golang-dev, dave, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13249043
2013-08-27 09:21:08 +10:00
Volker Dobler
f1d61b959f net/http: do not send leading dot in cookie domain attribute
RFC 6265 allows a leading dot in a cookie domain attribute
but is clear (see section 4.1.1) that a Set-Cookie header
should be sent without these dots.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13111043
2013-08-26 07:41:37 -05:00
Mikio Hara
9a7947288b syscall: update routing socket parser for NetBSD 6 and beyond
NetBSD 6 kernel and beyond require 64-bit aligned access to routing
facilities.

Fixes #6226.

R=golang-dev, bsiegert, bradfitz
CC=golang-dev
https://golang.org/cl/13170043
2013-08-25 08:44:31 +09:00
Brad Fitzpatrick
9ec0f30a25 bytes: clarify Equal docs
== isn't defined on slices, so don't use it in docs.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/12983045
2013-08-24 17:05:27 -05:00
Mikio Hara
33f3dffa7c net: allow TestDialFailPDLeak run in long-mode test
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12917050
2013-08-24 22:05:14 +09:00
Nicolas Owens
de8de8912e os/user: Current support on Plan 9
Current for Plan 9 is implemented with /dev/user for
Uid/Gid/Username/Name, and $home environment variable for
HomeDir.

Implementing Lookup/LookupId is not done, which would
require parsing /adm/users. It is unclear of how much benefit
this would be.

R=golang-dev
CC=bradfitz, golang-dev, r
https://golang.org/cl/13203043
2013-08-23 21:05:49 -05:00
Rémy Oudompheng
534c67abc4 syscall: add Cloneflags to Linux SysProcAttr.
Also use clone(2) syscall instead of fork().

Fixes #6214.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/13159044
2013-08-24 03:34:07 +02:00
Keith Randall
d0dd420a24 runtime: rename FlagNoPointers to FlagNoScan. Better represents
the use of the flag, especially for objects which actually do have
pointers but we don't want the GC to scan them.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13181045
2013-08-23 17:28:47 -07:00
Carl Shapiro
221eef6808 os/exec: remove flaky TestExtraFilesFDShuffle test
Update #5780

R=golang-dev, cshapiro, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12869049
2013-08-23 16:53:32 -07:00
Rémy Oudompheng
d4f719ee13 syscall: define CLONE_* constants on Linux.
Update #6214

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13160043
2013-08-23 22:26:49 +02:00
Joel Sing
4186e9d313 all: dragonfly support
Enable remaining packages (crypto, mime, path, time) to build on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13190043
2013-08-24 02:22:52 +10:00
Joel Sing
fce0608561 net: dragonfly support
Make the net package build and work on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13173044
2013-08-24 02:18:22 +10:00
Joel Sing
6939061d47 os: dragonfly support
Make the os package build and work on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13183044
2013-08-24 02:15:50 +10:00
Joel Sing
f3442a80c3 syscall: dragonfly/amd64 z-files
Add generated z-files for dragonfly/amd64.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13056045
2013-08-24 01:52:33 +10:00
Joel Sing
8f3f4c96a3 syscall: dragonfly/amd64 support
Add syscall support for dragonfly/amd64.

Also add support for generating syscall z* files for dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13188043
2013-08-24 01:51:25 +10:00
Joel Sing
ac00524beb runtime: add dragonfly/amd64 port
Go runtime support for dragonfly/amd64, largely based of the existing
FreeBSD runtime (with some clues from the varialus/godfly work).

R=bradfitz
CC=golang-dev
https://golang.org/cl/13088044
2013-08-24 01:50:24 +10:00
Joel Sing
71dc91db0f all: compiler/bootstrap for dragonfly/amd64
Add dragonfly/amd64 support to the Go compiler, bootstrap and GOOS list.

R=devon.odell, bradfitz
CC=golang-dev
https://golang.org/cl/12796050
2013-08-24 01:18:04 +10:00
Mikio Hara
180da80e90 net: fix dial to raw IP networks on Windows
Also avoids platform-dependent datagram truncation in raw IP tests.
At least it's different between Windows and others.

Fixes #6122.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/12843043
2013-08-23 19:31:24 +09:00
Mikio Hara
910a6faa93 net: fix race in TestDNSThreadLimit
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13141045
2013-08-23 14:26:52 +09:00
Alex Brainman
ec9e3e62a1 net: wait longer before failing TestVariousDeadlines4Proc on windows
This is an attempt to make our slow
windows-386 builder more reliable.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/12798045
2013-08-23 15:07:42 +10:00
Mikio Hara
6383896fee net: update doc on socket
Also makes variable names a bit cleaner.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/12808047
2013-08-23 13:13:43 +09:00
Mikio Hara
d3043b7b4a net: add test for protocol numbers lookup using internal information base
Update #5344

R=alex.brainman
CC=golang-dev
https://golang.org/cl/12966046
2013-08-22 12:13:54 +09:00
Alex Brainman
e541c861a3 net: fix misspelled variable name (fixes windows build)
R=golang-dev, adg
CC=golang-dev, mikioh.mikioh
https://golang.org/cl/12848047
2013-08-22 12:34:05 +10:00
Mikio Hara
fd58320f32 net: add minimal internet protocol number information base
This CL adds minimal information for supporting platforms that don't
have a complete list of internet protocol numbers.

Fixes #5344.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12898045
2013-08-22 10:33:37 +09:00
Mikio Hara
3b961bf88b net: remove redundant argument check from Dial on udp, unix networks
The net package consists of thin three layers like the follwoing;

- Exposed API, that contains net.Dial, net.DialUDP, net.DialUnix
- Socket and network file descriptor, that contains net.netFD and
  its methods, helper functions such as dialUDP, dialUnix
- Network pollster, that contains net.pollDesc and its methods

This CL removes redundant argument check which is already done by
API layer.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/13092043
2013-08-22 10:33:06 +09:00
Rémy Oudompheng
4a7a72b8c1 syscall: fix stale URL for linux/arm unistd.h
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13105047
2013-08-22 00:59:48 +02:00
Dmitriy Vyukov
dfdd1ba028 runtime: do not trigger GC on g0
GC acquires worldsema, which is a goroutine-level semaphore
which parks goroutines. g0 can not be parked.
Fixes #6193.

R=khr, khr
CC=golang-dev
https://golang.org/cl/12880045
2013-08-22 02:17:45 +04:00
Carl Shapiro
87fdb8fb9a undo CL 13010045 / 04f8101b46dd
Update the original change but do not read interface types in
the arguments area.  Once the arguments area is zeroed as the
locals area is we can safely read interface type values there
too.

««« original CL description
undo CL 12785045 / 71ce80dc4195

This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
»»»

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
»»»

R=khr, khr
CC=golang-dev
https://golang.org/cl/13073045
2013-08-21 13:51:00 -07:00
Sokolov Yura
fcf6a7e5ce time: make timers heap 4-ary
This slightly improves performance when a lot of timers are present

$ misc/benchcmp ../old_timers_m.txt ../new_timers_m.txt
benchmark                           old ns/op    new ns/op    delta
BenchmarkAfterFunc                       6884         6605   -4.05%
BenchmarkAfterFunc-2                     4473         4144   -7.36%
BenchmarkAfterFunc-3                     8601         6185  -28.09%
BenchmarkAfterFunc-4                     9378         8773   -6.45%
BenchmarkAfter                           7237         7278   +0.57%
BenchmarkAfter-2                         4638         3923  -15.42%
BenchmarkAfter-3                         8751         6239  -28.71%
BenchmarkAfter-4                         9223         8737   -5.27%
BenchmarkStop                             603          496  -17.74%
BenchmarkStop-2                           795          577  -27.42%
BenchmarkStop-3                           982          680  -30.75%
BenchmarkStop-4                          1164          739  -36.51%
BenchmarkSimultaneousAfterFunc            657          593   -9.74%
BenchmarkSimultaneousAfterFunc-2          816          757   -7.23%
BenchmarkSimultaneousAfterFunc-3          844          830   -1.66%
BenchmarkSimultaneousAfterFunc-4          785          771   -1.78%
BenchmarkStartStop                        238          239   +0.42%
BenchmarkStartStop-2                      249          234   -6.02%
BenchmarkStartStop-3                      271          268   -1.11%
BenchmarkStartStop-4                      293          295   +0.68%

R=golang-dev, dvyukov, bradfitz, r
CC=golang-dev
https://golang.org/cl/13094043
2013-08-21 18:51:37 +04:00
Dmitriy Vyukov
2f2d4c6bc3 net: ensure that Read/Write on all platforms do 0 mallocs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12780045
2013-08-21 14:21:02 +04:00
Todd Wang
0e73497a4b reflect: Fix Convert to add indir bit when the value is actually a
pointer.  An example that triggers the bad behavior on a 64bit
machine http://play.golang.org/p/GrNFakAYLN
        rv1 := reflect.ValueOf(complex128(0))
        rt := rv1.Type()
        rv2 := rv1.Convert(rt)
        rv3 := reflect.New(rt).Elem()
        rv3.Set(rv2)

Running the code fails with the following:
        panic: reflect: internal error: storeIword of 16-byte value

I've tested on a 64bit machine and verified this fixes the panic.  I
haven't tested on a 32bit machine so I haven't verified the other
cases, but they follow logically.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/12805045
2013-08-21 14:41:55 +10:00
Rob Pike
f578726de1 all: protect alloc count tests by -testing.short
Update #5000
Should reduce the flakiness a little. Malloc counting is important
to general testing but not to the build dashboard, which uses -short.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12866047
2013-08-21 14:00:45 +10:00
Rob Pike
7bbe320679 text/template: implement comparison of basic types
Add eq, lt, etc. to allow one to do simple comparisons.
It's basic types only (booleans, integers, unsigned integers,
floats, complex, string) because that's easy, easy to define,
and covers the great majority of useful cases, while leaving
open the possibility of a more sweeping definition later.

{{if eq .X .Y}}X and Y are equal{{else}}X and Y are unequal{{end}}

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13091045
2013-08-21 11:27:27 +10:00
Rob Pike
9364868a07 archive/tar,zip: implement the os.FileInfo interface correctly.
This is potentially an API-breaking change, but it is an important bug fix.

The CL https://golang.org/cl/7305072/ added stuff to make
the tar file look more like a file system internally, including providing an
implementation of os.FileInfo for the file headers within the archive.
But the code is incorrect because FileInfo.Name is supposed to return
the base name only; this implementation returns the full path. A round
trip test added in the same shows this in action, as the slashes are
preserved as we create a header using the local implementation of
FileInfo.

The CL here changes the behavior of the tar (and zip) FileInfo to honor
the Go spec for that interface. It also clarifies that the FileInfoHeader
function, which takes a FileInfo as an argument, will therefore create
a header with only the base name of the file recorded, and that
subsequent adjustment may be necessary.

There may be code out there that depends on the broken behavior.
We can call out the risk in the release notes.

Fixes #6180.

R=golang-dev, dsymonds, adg, bradfitz
CC=golang-dev
https://golang.org/cl/13118043
2013-08-21 08:29:41 +10:00
Mikio Hara
ed738ad354 net: remove obsolete builtin network pollster
Update #5199
Update #6146

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13112044
2013-08-20 17:32:55 +09:00
Mikio Hara
9b65dac494 net: enable runtime-integrated network pollster on freebsd/arm
Fixes #6146.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12927048
2013-08-20 17:02:42 +09:00
Mikio Hara
e82614e5be runtime: integrated network pollster for freebsd/arm
Update #6146

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12927047
2013-08-20 16:57:30 +09:00
Brad Fitzpatrick
33d531dfa4 net/http: support WriteString on the ResponseWriter
Fixes #5377

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12991046
2013-08-19 22:56:54 -07:00
Rob Pike
94b42fb14a os: fix windows build
The os windows source uses file as the receiver, not f.
TBR=golang-dev@googlegroups.com

R=adg
CC=golang-dev
https://golang.org/cl/12922044
2013-08-20 14:45:46 +10:00
Rob Pike
4cb086b838 os: be consistent about File methods with nil receivers
Some crashed, some didn't. Make a nil receiver always
return ErrInvalid rather than crash.
Fixes #5824.
The program in the bug listing is silent now, at least on my Mac.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13108044
2013-08-20 14:33:03 +10:00
Carl Shapiro
ca2d32b46d undo CL 12785045 / 71ce80dc4195
This has broken the 32-bit builds.

««« original CL description
cmd/gc, runtime: use type information to scan interface values

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
»»»

R=khr, golang-dev, khr
CC=golang-dev
https://golang.org/cl/13010045
2013-08-19 14:16:55 -07:00
Keith Randall
6401e0f83f runtime: don't run finalizers if we're still on the g0 stack.
R=golang-dev, rsc, dvyukov, khr
CC=golang-dev
https://golang.org/cl/11386044
2013-08-19 12:20:50 -07:00
Dmitriy Vyukov
88ee849a8a net: annotate Read/Write for race detector
Fixes #6167.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13052043
2013-08-19 23:09:24 +04:00
Dmitriy Vyukov
d017f578d0 runtime: do not preempt race calls
In the crash stack trace race cgocall() calls endcgo(),
this means that m->racecall is wrong.
Indeed this can happen is a goroutine is rescheduled to another M
during race call.
Disable preemption for race calls.
Fixes #6155.

R=golang-dev, rsc, cshapiro
CC=golang-dev
https://golang.org/cl/12866045
2013-08-19 23:06:46 +04:00
Carl Shapiro
21ea5103a4 cmd/gc, runtime: use type information to scan interface values
R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/12785045
2013-08-19 10:19:59 -07:00
Rob Pike
bc6bb3efb4 math/big: fix nil bug in GobEncode
Update #5305.
This handles the case where the nil pointers are inside a slice.
A top-level nil pointer is harder, maybe fundamentally broken by gob's model.
Thinking required.
However, a slice is the important case since people don't expect to be sending
top-level nils much, but they can arise easily in slices.

R=golang-dev, josharian, adg
CC=golang-dev
https://golang.org/cl/13042044
2013-08-19 11:22:09 +10:00
Marco Hennings
a07c95a53c archive/tar: Fix support for long links and improve PAX support.
The tar/archive code from golang has a problem with linknames with length >
100. A pax header is added but the original header still written with a too
long field length.

As it is clear that pax support is incomplete I have added missing
implementation parts.

This commit contains code from the golang project in the folder tar/archiv.

The following pax header records are now automatically written:

- gname)
- linkpath
- path
- uname

The following fields can be written with PAX, but the default is to use the
star binary extension.

- gid  (value > 2097151)
- size (value > 8589934591)
- uid (value > 2097151)

The string fields are written when the value is longer as the field or if the
string contains a char that is not encodable as 7-bit ASCII value.

The change was tested against a current ubuntu-cloud image tarball comparing
the compressed result.

+ added some automated tests for the new functionality.

Fixes #6056.

R=dsymonds
CC=golang-dev
https://golang.org/cl/12561043
2013-08-19 10:45:44 +10:00
Rob Pike
6fb9cc1f63 testing: don't start timing a Parallel test until it's actually starting
Fixes #5285.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/13045044
2013-08-19 10:15:30 +10:00
Dominik Honnef
43a39bfd7f encoding/xml: flush buffer after encoding token
R=rsc, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13004046
2013-08-19 10:14:10 +10:00
Mikio Hara
7917b88a06 net: make protocol-specific WriteTo, WriteMsg methods return error instead of crash
R=golang-dev, dave, rsc, adg, bradfitz
CC=golang-dev
https://golang.org/cl/11809043
2013-08-18 19:19:36 +09:00
Emil Hessman
df7b93c175 net/textproto: use ReadDotBytes instead of non-existent ReadDotAll.
Fixes #5893.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13086043
2013-08-18 08:11:34 +10:00
Emil Hessman
20eb4cba37 net/textproto: replace '3-digit' with 'three-digit'
A matter on form in documentation.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13087043
2013-08-18 08:10:00 +10:00
Mikio Hara
ca01ab39ef net: fix garbage connection close in dual stack tests
This may possibly be the root cause of flaky dual stack tests.

Update #4176
Update #5001

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13050043
2013-08-17 13:40:55 +09:00
Mikio Hara
96d7997f03 net: enable runtime-integrated network pollster on netbsd
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13080043
2013-08-17 13:40:14 +09:00
Mikio Hara
c4cdd35e6e runtime: integrated network pollster for netbsd/amd64,386,arm
Original CL by minux (9545044).

Update #6146

R=golang-dev, rsc
CC=golang-dev, minux.ma
https://golang.org/cl/12949045
2013-08-17 12:11:29 +09:00
Russ Cox
1d3efd6533 net: limit number of concurrent cgo calls
The limit is 500. There is no way to change it.
This primarily affects name resolution.
If a million goroutines try to resolve DNS names,
only 500 will get to execute cgo calls at a time.
But in return the operating system will not crash.

Fixes #5625.

R=golang-dev, dan.kortschak, r, dvyukov
CC=bradfitz, golang-dev
https://golang.org/cl/13038043
2013-08-16 22:43:05 -04:00
Russ Cox
665feeedcb runtime: impose thread count limit
Actually working to stay within the limit could cause subtle deadlocks.
Crashing avoids the subtlety.

Fixes #4056.

R=golang-dev, r, dvyukov
CC=golang-dev
https://golang.org/cl/13037043
2013-08-16 22:25:26 -04:00
Dmitriy Vyukov
18f5ce8561 runtime/race: add output tests for different GORACE params
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13065043
2013-08-16 21:54:04 +04:00
Dmitriy Vyukov
187b9c695f runtime: fix goroutine stack accounting
Fixes #6166.
Fixes #6168.

R=golang-dev, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/12927045
2013-08-16 21:04:05 +04:00
Dmitriy Vyukov
fbf5fd5f1e runtime/race: update runtime to rev 188542
Fixes #6107.
race: output goroutine 1 as main goroutine

Fixes #6130.
race: option to abort program on first detected error

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12968044
2013-08-16 17:51:09 +04:00
Dmitriy Vyukov
727dd08cdf net: fix bug in fdMutex
Fixes #6165.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12984044
2013-08-16 16:02:55 +04:00
Rob Pike
4c855f3830 time: fix time zones yet again.
This time we're going for 5!
http://goo.gl/3ETYH7

Fixes #3790
Yeah, right.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13002044
2013-08-16 14:57:49 +10:00
David Symonds
ea6cfc57b3 undo CL 12822043 / 96fefaa02ae3
Fixes #6160.

««« original CL description
go/doc: permit a package synopsis to end with ":\n".

R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
»»»

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13040043
2013-08-16 14:36:06 +10:00
Russ Cox
757e0de89f runtime: impose stack size limit
The goal is to stop only those programs that would keep
going and run the machine out of memory, but before they do that.
1 GB on 64-bit, 250 MB on 32-bit.
That seems implausibly large, and it can be adjusted.

Fixes #2556.
Fixes #4494.
Fixes #5173.

R=khr, r, dvyukov
CC=golang-dev
https://golang.org/cl/12541052
2013-08-15 22:34:06 -04:00
Dimitri Tcaciuc
205329aaf2 image: Inline example image data to make it runnable on playground.
Use more compressed image to reduce source clutter.

Fixes #5983.

R=nigeltao, adg
CC=golang-dev
https://golang.org/cl/12513044
2013-08-16 11:43:43 +10:00
Nigel Tao
bc21265074 database/sql: make Rows.Next returning false always implicitly call
Rows.Close.

Previously, callers that followed the example code (but not call
rows.Close after "for rows.Next() { ... }") could leak statements if
the driver returned an error other than io.EOF.

R=bradfitz, alex.brainman
CC=golang-dev, rsc
https://golang.org/cl/12677050
2013-08-16 11:23:35 +10:00
Brad Fitzpatrick
67a69bce6b net/http: don't send an automatic Content-Length on a 304 Not Modified
Also start of some test helper unification, long overdue.
I refrained from cleaning up the rest in this CL.

Fixes #6157

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13030043
2013-08-15 17:40:05 -07:00
Brad Fitzpatrick
95e0a8c277 net/http: unify the confusingly-named serve_test and server_test
One was tiny. One was gigantic. Now one is gone and one is giganticer.

No code changes.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13025043
2013-08-15 16:47:31 -07:00
Russ Cox
08fdf00906 tests: remove two misuses of nil pointers
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12858044
2013-08-15 11:51:04 -04:00
Mikio Hara
ff86d222be runtime: fix wrong syscall numbers on freebsd/386, openbsd/386
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/12876044
2013-08-15 23:22:55 +09:00
Mikio Hara
cb3b292201 net: enable runtime-integrated network pollster on freebsd, openbsd
Fixes #5199.

Benchmark results on freebsd/amd64 (virtual machine):

benchmark                             old ns/op    new ns/op    delta
BenchmarkTCP4OneShot-2                   184566       187164   +1.41%
BenchmarkTCP4OneShotTimeout-2            215558       187722  -12.91%
BenchmarkTCP4Persistent-2                 59686        41294  -30.81%
BenchmarkTCP4PersistentTimeout-2          60692        39974  -34.14%
BenchmarkTCP6OneShot-2                   226595       223688   -1.28%
BenchmarkTCP6OneShotTimeout-2            253144       225161  -11.05%
BenchmarkTCP6Persistent-2                 69157        55605  -19.60%
BenchmarkTCP6PersistentTimeout-2          70426        53805  -23.60%
BenchmarkTCP4ConcurrentReadWrite-2        53878        56087   +4.10%
BenchmarkTCP6ConcurrentReadWrite-2        66538        68190   +2.48%

benchmark                            old allocs   new allocs    delta
BenchmarkTCP4OneShot-2                       39           36   -7.69%
BenchmarkTCP4OneShotTimeout-2                42           36  -14.29%
BenchmarkTCP4Persistent-2                     1            0  -100.00%
BenchmarkTCP4PersistentTimeout-2              1            0  -100.00%
BenchmarkTCP6OneShot-2                       41           36  -12.20%
BenchmarkTCP6OneShotTimeout-2                43           36  -16.28%
BenchmarkTCP6Persistent-2                     1            0  -100.00%
BenchmarkTCP6PersistentTimeout-2              1            0  -100.00%
BenchmarkTCP4ConcurrentReadWrite-2            0            0     n/a%
BenchmarkTCP6ConcurrentReadWrite-2            0            0     n/a%

benchmark                             old bytes    new bytes    delta
BenchmarkTCP4OneShot-2                     3084         2544  -17.51%
BenchmarkTCP4OneShotTimeout-2              3129         2519  -19.50%
BenchmarkTCP4Persistent-2                    30            0  -100.00%
BenchmarkTCP4PersistentTimeout-2             31            0  -100.00%
BenchmarkTCP6OneShot-2                     3297         2660  -19.32%
BenchmarkTCP6OneShotTimeout-2              3306         2655  -19.69%
BenchmarkTCP6Persistent-2                    31            0  -100.00%
BenchmarkTCP6PersistentTimeout-2             29            0  -100.00%
BenchmarkTCP4ConcurrentReadWrite-2            2            0  -100.00%
BenchmarkTCP6ConcurrentReadWrite-2            7            0  -100.00%

R=dvyukov, minux.ma, dave, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/8264043
2013-08-15 21:10:03 +09:00
Dmitriy Vyukov
f195ae94ca runtime: remove old preemption checks
runtime.gcwaiting checks are not needed anymore

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/12934043
2013-08-15 14:32:10 +04:00
Dmitriy Vyukov
67c79da857 runtime: fix plan9 build
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12986043
2013-08-15 14:24:28 +04:00
Mikio Hara
5d5defc77f net: rearrange the call order of runtime-integrated network pollster and syscall functions
This CL rearranges the call order for raw networking primitives like
the following;

- For dialers that open active connections, pollDesc.Init will be
  called before syscall.Connect.

- For stream listeners that open passive stream connections,
  pollDesc.Init will be called just after syscall.Listen.

- For datagram listeners that open datagram connections,
  pollDesc.Init will be called just after syscall.Bind.

This is in preparation for runtime-integrated network pollster for BSD
variants.

Update #5199

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12730043
2013-08-15 16:40:33 +09:00
Rob Pike
a454d2fd2e time: expand acceptance of time zones when parsing
I tried to make it absolutely correct but there are too many
conflicting definitions for the official list of time zones.
Since when we're parsing we know when to expect
a time zone and we know what they look like if not exactly
what the definitive set is, we compromise. We accept any
three-character sequence of upper case letters, possibly
followed by a capital T (all four-letter zones end in T).

There is one crazy special case (ChST) and the possibility
of a signed hour offset for GMT.

Fixes #3790
I hope forever, but I doubt that very much.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12969043
2013-08-15 16:42:54 +10:00
Brad Fitzpatrick
ec837ad73c archive/zip: speed up Zip64 test
Took 76 seconds or so before. By avoiding flate and crc32 on
4GB of data, it's now only 12 seconds.  Still a slow test, but
not painful to run anymore when you forget -short.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12950043
2013-08-14 23:21:57 -07:00
Brad Fitzpatrick
35d8bb39bd testing: add TB, an interface common to T and B
R=golang-dev, kevlar, rsc, adg, r
CC=golang-dev
https://golang.org/cl/12962043
2013-08-14 23:21:32 -07:00
Rob Pike
a41a5bb207 os/exec: document that LookPath's result may be a relative path
Fixes #3622

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12971043
2013-08-15 14:29:04 +10:00
Rob Pike
727b2b6f7d time: handle GMT possibly with offset
Update #3790
Handle time zones like GMT-8.
The more general time zone-matching problem is not yet resolved.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12922043
2013-08-15 10:10:49 +10:00
Russ Cox
904e113615 encoding/xml: support generic encoding interfaces
Remove custom support for time.Time.
No new tests: the tests for the time.Time special case
now test the general case.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12751045
2013-08-14 18:52:09 -04:00
Carl Shapiro
3ec0427a07 cmd/go, runtime/cgo: explicitly target ARMv5T
The baseline architecture had been left to the GCC configured
default which can be more accomodating than the rest of the Go
toolchain.  This prevented instructions used by the 5g compiler,
like BLX, from being used in GCC compiled assembler code.

R=golang-dev, dave, rsc, elias.naur, cshapiro
CC=golang-dev
https://golang.org/cl/12954043
2013-08-14 15:21:53 -07:00
Mikio Hara
88411547d4 net: simplify dial
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12884044
2013-08-15 05:53:53 +09:00
Dmitriy Vyukov
3bd0b0a80d runtime: fix SetBlockProfileRate
It doughtily misses all possible corner cases.
In particular on machines with <1GHz processors,
SetBlockProfileRate(1) disables profiling.
Fixes #6114.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12936043
2013-08-15 00:20:36 +04:00
Mikio Hara
2eb7c6ec8a net: simplify non-cgo DNS exchange
Also does less buffer allocation in case of TCP fallback.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12925043
2013-08-15 05:08:08 +09:00
Mikio Hara
3a93626b49 net: fix TestTCPLookup
R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/12766044
2013-08-15 05:07:35 +09:00
Russ Cox
54bdfc007f encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Repeat of CL 12603044, which was submitted accidentally
and then rolled back.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev
CC=golang-dev
https://golang.org/cl/12919043
2013-08-14 14:58:28 -04:00
Russ Cox
84b0842a59 encoding/xml: add, support Unmarshaler interface
See golang.org/s/go12xml for design.

R=golang-dev, dominik.honnef, dan.kortschak
CC=golang-dev
https://golang.org/cl/12556043
2013-08-14 14:57:45 -04:00
Russ Cox
7e886740d1 encoding/json: support encoding.TextMarshaler, encoding.TextUnmarshaler
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12703043
2013-08-14 14:56:07 -04:00
Russ Cox
5822e7848a runtime: make SetFinalizer(x, f) accept any f for which f(x) is valid
Originally the requirement was f(x) where f's argument is
exactly x's type.

CL 11858043 relaxed the requirement in a non-standard
way: f's argument must be exactly x's type or interface{}.

If we're going to relax the requirement, it should be done
in a way consistent with the rest of Go. This CL allows f's
argument to have any type for which x is assignable;
that's the same requirement the compiler would impose
if compiling f(x) directly.

Fixes #5368.

R=dvyukov, bradfitz, pieter
CC=golang-dev
https://golang.org/cl/12895043
2013-08-14 14:54:31 -04:00
Russ Cox
2560f8fe22 runtime/cgo: use old-style indirect call on arm
TBR=elias.naur
CC=golang-dev
https://golang.org/cl/12943043
2013-08-14 14:54:08 -04:00
Dmitriy Vyukov
dd50dac56c runtime: fix windows build
R=golang-dev
CC=golang-dev
https://golang.org/cl/12941043
2013-08-14 22:18:49 +04:00
Dmitriy Vyukov
4e76abbc60 runtime: implement SysUnused on windows
Fixes #5584.

R=golang-dev, chaishushan, alex.brainman
CC=golang-dev
https://golang.org/cl/12720043
2013-08-14 21:54:07 +04:00
Dmitriy Vyukov
f8ca13c3e5 net: make TCPStress test shorter
It timeouts on freebsd builders:
http://build.golang.org/log/3d8169e13bff912bebf6fd3c54b34ad2d29a7221
but there are always runnable goroutines,
which suggests that it's slowly progressing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12939043
2013-08-14 21:53:27 +04:00
Elias Naur
dc48e9516c runtime: Fix build on older ARM
The ARM external linking CL used BLX instructions in gcc assembler. Replace with BL to retain support on older ARM processors.

R=rsc
CC=golang-dev
https://golang.org/cl/12938043
2013-08-14 13:50:12 -04:00
Dmitriy Vyukov
9bbf1e1b72 net: make TestDeadlineRace shorter
1. Do less iterations in short mode
2. Bound number of times SetDeadline is executed

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12937043
2013-08-14 21:20:11 +04:00
Elias Naur
48c0d8b6e2 runtime: Fix netbsd/arm and freebsd/arm build
The ARM external linking CL left missed changes to sys_freebsd_arm.s and sys_netbsd_arm.s already done to sys_linux_arm.s.

R=rsc
CC=golang-dev
https://golang.org/cl/12842044
2013-08-14 13:18:32 -04:00
Matt Joiner
13c7896fb6 database/sql: fix accumulation of bad conns on prepared statements
Fixes an issue where prepared statements that outlive many
connections become expensive to invoke.

Fixes #6081

R=golang-dev
CC=bradfitz, golang-dev
https://golang.org/cl/12646044
2013-08-14 09:27:30 -07:00
Elias Naur
45233734e2 runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 15:38:54 +00:00
Dmitriy Vyukov
c92287686d runtime: improve block profiler support for channels
1. Handle select statements.
2. Handle chan close.
3. Show top frame in debug mode (chansend/chanrecv/selectgo).
Fixes #6049.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/12694050
2013-08-14 13:56:01 +04:00
Russ Cox
883530c019 sync/atomic: fix new swap on arm linux
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12920043
2013-08-14 00:50:47 -04:00
Russ Cox
071e44e4e4 time: make Time implement encoding interfaces
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12706043
2013-08-14 00:34:00 -04:00
Russ Cox
413d4c6c11 net: make IP implement encoding.MarshalerText, encoding.UnmarshalerText
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12705043
2013-08-14 00:33:20 -04:00
Russ Cox
56ce83f7ba undo CL 12603044 / 2ca230b93195
fat fingers - did not intend to submit.
depends on the Unmarshaler CL anyway.

««« original CL description
encoding/xml: add, support Marshaler interface

See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
»»»

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/12918043
2013-08-14 00:20:55 -04:00
Russ Cox
ce3ba126a0 encoding/gob: support new generic interfaces in package encoding
R=r
CC=golang-dev
https://golang.org/cl/12681044
2013-08-14 00:18:48 -04:00
Russ Cox
48b90bbc55 encoding: new package
See golang.org/s/go12encoding for design.

R=r
CC=golang-dev
https://golang.org/cl/12541051
2013-08-14 00:18:20 -04:00
Russ Cox
85f3acd788 encoding/xml: add, support Marshaler interface
See golang.org/s/go12xml for design.

Fixes #2771.
Fixes #4169.
Fixes #5975.
Fixes #6125.

R=golang-dev, iant, dan.kortschak
CC=golang-dev
https://golang.org/cl/12603044
2013-08-14 00:17:42 -04:00
Russ Cox
1a09d70e23 runtime: fix build on arm
Do not use ? :
I cannot say this enough.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12903043
2013-08-13 19:37:54 -04:00
Brad Fitzpatrick
a2599cf50e archive/zip: add File.DataOffset
Accessor to find where the bytes of a file start.

R=golang-dev, rsc, dsymonds, adg
CC=golang-dev
https://golang.org/cl/12784045
2013-08-13 16:29:51 -07:00
Mikio Hara
45cb2e1b70 net: make Dial, Listen and ListenPacket return consistent error value
Update #4856

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12763044
2013-08-14 07:04:39 +09:00
Brad Fitzpatrick
ca3ed9f352 database/sql: add a disabled broken test
Update #6081

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12810043
2013-08-13 14:56:40 -07:00
Brad Fitzpatrick
c7d352c941 archive/zip: remove an allocation, speed up a test
Update #6138

TestOver65kFiles spends all its time garbage collecting.
Removing the 1.4 MB of allocations per each of the 65k
files brings this from 34 seconds to 0.23 seconds.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12894043
2013-08-13 14:48:08 -07:00
Rob Pike
c18af467fd encoding/binary: make Write work like Read
Use the fast path calculation to shorten the code.
No effect on benchmarks.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12696046
2013-08-14 07:03:56 +10:00
Dmitriy Vyukov
992374f8fb net: fix build fix
Now builders say:
pkg/net/dnsclient_unix_test.go:10: imported and not used: "runtime"

R=golang-dev
CC=golang-dev
https://golang.org/cl/12890043
2013-08-14 00:55:18 +04:00
Dmitriy Vyukov
d90a81c39f net: fix windows build
Windows builders say:
pkg\net\dnsclient_unix_test.go:24: undefined: dnsConfig
pkg\net\dnsclient_unix_test.go:25: undefined: exchange

R=golang-dev
CC=golang-dev
https://golang.org/cl/12889043
2013-08-14 00:44:57 +04:00
Dmitriy Vyukov
4f2e382c9f runtime: dump scheduler state if GODEBUG=schedtrace is set
The schedtrace value sets dump period in milliseconds.
In default mode the trace looks as follows:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 [1 0 0 0]
SCHED 1001ms: gomaxprocs=4 idleprocs=3 threads=6 idlethreads=3 runqueue=0 [0 0 0 0]
SCHED 2008ms: gomaxprocs=4 idleprocs=1 threads=6 idlethreads=1 runqueue=0 [0 1 0 0]
If GODEBUG=scheddetail=1 is set as well, then the detailed trace is printed:
SCHED 0ms: gomaxprocs=4 idleprocs=0 threads=3 idlethreads=0 runqueue=0 singleproc=0 gcwaiting=1 mlocked=0 nmspinning=0 stopwait=0 sysmonwait=0
  P0: status=3 tick=1 m=0 runqsize=1/128 gfreecnt=0
  P1: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P2: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  P3: status=3 tick=0 m=-1 runqsize=0/128 gfreecnt=0
  M2: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M1: p=-1 curg=-1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=-1
  M0: p=0 curg=1 mallocing=0 throwing=0 gcing=0 locks=1 dying=0 helpgc=0 spinning=0 lockedg=1
  G1: status=2() m=0 lockedm=0
  G2: status=1() m=-1 lockedm=-1

R=golang-dev, raggi, rsc
CC=golang-dev
https://golang.org/cl/11435044
2013-08-14 00:30:55 +04:00
Russ Cox
2642c6e24d sync/atomic: update comment for ARM 64-bit atomics
They don't work on older chips, just like the x86-32 64-bit atomics.

Update #6134

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12880043
2013-08-13 16:16:05 -04:00
Keith Randall
74e78df107 undo CL 12840043 / 3b9f54db72a1
Breaks the build.  Old bucket arrays kept by iterators
still need to be scanned.

««« original CL description
runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/12884043
2013-08-13 12:59:39 -07:00
Keith Randall
0df438c683 runtime: tell GC not to scan internal hashmap structures.
We'll do it ourselves via hash_gciter, thanks.
Fixes bug 6119.

R=golang-dev, dvyukov, cookieo9, rsc
CC=golang-dev
https://golang.org/cl/12840043
2013-08-13 12:36:03 -07:00
Russ Cox
ba14974e07 undo CL 12787044 / ed695cdf962b
The NetBSD and OpenBSD failures are apparently real,
not due to the test bug fixed in 100b9fc0c46f.

««« original CL description
runtime/pprof: test netbsd and openbsd again

Maybe these will work now.

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12873043
2013-08-13 23:33:49 +04:00
Dmitriy Vyukov
4961483e7d runtime: fix LockOSThread
Fixes #6100.

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12703045
2013-08-13 22:37:04 +04:00
Dmitriy Vyukov
f9066fe1c0 runtime: more reliable preemption
Currently it's possible that a goroutine
that periodically executes non-blocking
cgo/syscalls is never preempted.
This change splits scheduler and syscall
ticks to prevent such situation.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12658045
2013-08-13 22:14:04 +04:00
Dmitriy Vyukov
cc4e6aad8e runtime: do no lose CPU profiling signals
Currently we lose lots of profiling signals.
Most notably, GC is not accounted at all.
But stack splits, scheduler, syscalls, etc are lost as well.
This creates seriously misleading profile.
With this change all profiling signals are accounted.
Now I see these additional entries that were previously absent:
161  29.7%  29.7%      164  30.3% syscall.Syscall
 12   2.2%  50.9%       12   2.2% scanblock
 11   2.0%  55.0%       11   2.0% markonly
 10   1.8%  58.9%       10   1.8% sweepspan
  2   0.4%  85.8%        2   0.4% runtime.newstack
It is still impossible to understand what causes stack splits,
but at least it's clear how many time is spent on them.
Update #2197.
Update #5659.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12179043
2013-08-13 22:12:02 +04:00
Dmitriy Vyukov
1da1030b5d runtime: fix false deadlock crash
Fixes #6070.
Update #6055.

R=golang-dev, nightlyone, rsc
CC=golang-dev
https://golang.org/cl/12602043
2013-08-13 22:07:42 +04:00
Dmitriy Vyukov
7eb6a6f46d sync/atomic: fix ARM nomenclature in comments
R=cshapiro
CC=golang-dev
https://golang.org/cl/12877043
2013-08-13 22:07:21 +04:00
Rick Arnold
4be93851c3 io: prevent write to PipeWriter after Close
Return an ErrClosedPipe rather than allowing the write to proceed.

Fixes #5330.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12541053
2013-08-13 11:04:09 -07:00
Dmitriy Vyukov
d3f36dbfc7 sync/atomic: add Swap to nil deref test
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12870043
2013-08-13 21:18:33 +04:00
Dmitriy Vyukov
66c58cea67 sync/atomic: trigger paging fault early on linux/arm
so that we don't need to traceback through __kuser_cmpxchg

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12869043
2013-08-13 21:15:47 +04:00
Alex A Skinner
0a3cb7ece3 net: implement DNS TCP fallback query if UDP response is truncated
Fixes #5686.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12458043
2013-08-13 09:44:12 -07:00
Russ Cox
469250fb77 runtime/pprof: test netbsd and openbsd again
Maybe these will work now.

R=golang-dev, dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/12787044
2013-08-13 12:35:37 -04:00
Dmitriy Vyukov
71c6da39ce runtime/pprof: fix test
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12790043
2013-08-13 12:18:29 -04:00
Dmitriy Vyukov
aaab946943 runtime: fix handling of network deadlines
Ensure that deadlines affect already issued IO.

R=golang-dev, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/12847043
2013-08-13 19:11:42 +04:00
Dmitriy Vyukov
0e15b03f93 sync/atomic: add Swap functions
Fixes #5722.

R=golang-dev, khr, cshapiro, rsc, r
CC=golang-dev
https://golang.org/cl/12670045
2013-08-13 15:26:48 +04:00
Mikio Hara
39a7017c26 net: make deadline helpers join to netFD as its methods
Just for readability reasons; to prevent overlooking deadline stuff
across over platforms.

R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/8656044
2013-08-13 20:00:58 +09:00
Dmitriy Vyukov
5a20b4a6a9 sync: faster Cond
The new version does not require any memory allocations and is 30-50% faster.
Also detect and painc if Cond is copied after first.

benchmark            old ns/op    new ns/op    delta
BenchmarkCond1             317          195  -38.49%
BenchmarkCond1-2           875          607  -30.63%
BenchmarkCond1-4          1116          548  -50.90%
BenchmarkCond1-8          1013          613  -39.49%
BenchmarkCond1-16          983          450  -54.22%
BenchmarkCond2             559          352  -37.03%
BenchmarkCond2-2          1916         1378  -28.08%
BenchmarkCond2-4          1518         1322  -12.91%
BenchmarkCond2-8          2313         1291  -44.19%
BenchmarkCond2-16         1885         1078  -42.81%
BenchmarkCond4            1070          614  -42.62%
BenchmarkCond4-2          4899         3047  -37.80%
BenchmarkCond4-4          3813         3006  -21.16%
BenchmarkCond4-8          3605         3045  -15.53%
BenchmarkCond4-16         4148         2637  -36.43%
BenchmarkCond8            2086         1264  -39.41%
BenchmarkCond8-2          9961         6736  -32.38%
BenchmarkCond8-4          8135         7689   -5.48%
BenchmarkCond8-8          9623         7517  -21.89%
BenchmarkCond8-16        11661         8093  -30.60%

R=sougou, rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/11573043
2013-08-13 14:45:36 +04:00
Dmitriy Vyukov
d1b66439f9 runtime: eliminate excessive notewakeup calls in timers
If the timer goroutine is wakeup by timeout,
other goroutines will still notewakeup because sleeping is still set.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12763043
2013-08-13 14:14:24 +04:00
Dmitriy Vyukov
e33e476e07 syscall: disable cpu profiling around fork
Fixes #5517.
Fixes #5659.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12183044
2013-08-13 13:01:30 +04:00
Dmitriy Vyukov
9707f269c1 runtime: fix network timers related crash
Fixes #6103.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/12686045
2013-08-13 12:55:57 +04:00
David Symonds
c272fd14a8 go/doc: permit a package synopsis to end with ":\n".
R=gri, r
CC=golang-dev
https://golang.org/cl/12822043
2013-08-13 16:20:17 +10:00
Rob Pike
954d14741d go/build: change the wording of NoGoError and comment it better
Out of context, it can be very confusing because there can be lots of Go
files in the directory, but the error message says there aren't.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/12823043
2013-08-13 11:32:32 +10:00
Elias Naur
83348a13fb text/template: Make function call builtin handle nil errors correctly
The call builtin unconditionally tries to convert a second return value from a function to the error type. This fails in case nil is returned, effectively making call useless for functions returning two values.

This CL adds a nil check for the second return value, and adds a test.

Note that for regular function and method calls the nil error case is handled correctly and is verified by a test.

R=r
CC=golang-dev
https://golang.org/cl/12804043
2013-08-13 11:11:05 +10:00
Volker Dobler
4f86a96ac9 net/http: do not send malformed cookie domain attribute
Malformed domain attributes are not sent in a Set-Cookie header.
Instead the domain attribute is dropped which turns the cookie
into a host-only cookie. This is much safer than dropping characters
from domain attribute.

Domain attributes with a leading dot '.' are still allowed, even
if discouraged by RFC 6265 section 4.1.1.

Fixes #6013

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12745043
2013-08-12 15:14:34 -07:00
Keith Randall
e838334beb runtime: change textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12798043
2013-08-12 13:47:18 -07:00
Dmitriy Vyukov
2791ef0b67 runtime/race: add end-to-end test
Fixes #5933.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12699051
2013-08-12 22:04:10 +04:00
Dmitriy Vyukov
fa4628346b runtime: remove unused m->racepc
The original plan was to collect allocation stacks
for all memory blocks. But it was never implemented
and it's not in near plans and it's unclear how to do it at all.

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/12724044
2013-08-12 21:48:19 +04:00
Dmitriy Vyukov
f3c1070fa4 sync/atomic: specify argsize for asm routines
Fixes #6098.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12717043
2013-08-12 21:46:33 +04:00
Dmitriy Vyukov
92254d4463 runtime: fix ARM assembly formatting
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12702048
2013-08-12 21:36:33 +04:00
Keith Randall
8b789e1738 all: change textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12774043
2013-08-12 10:25:36 -07:00
Keith Randall
1f7966346e math: convert textflags from numbers to symbols
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773044
2013-08-12 10:25:18 -07:00
Keith Randall
db324ccd72 syscall: Convert textflags from numbers to symbols.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12773043
2013-08-12 10:24:30 -07:00
Andrew Gerrand
8eb8ad2454 bufio: add Writer example
Update #5530

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12504044
2013-08-12 13:03:50 +10:00
Rob Pike
6b706cf50d bufio: make it clear that the client must call Writer.Flush
Fixes #5530.

R=golang-dev, iant, com.liigo
CC=golang-dev
https://golang.org/cl/12688044
2013-08-12 12:55:33 +10:00
Rob Pike
ce00562607 crypto/rand: simplify example to exploit properties of ReadFull
No need for the complex condition.
Fixes #6089

R=golang-dev, mischief, adg
CC=golang-dev
https://golang.org/cl/12731043
2013-08-12 12:52:23 +10:00
Dmitriy Vyukov
2758101b9d runtime/pprof: add block profile test
Fixes #5993.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12665046
2013-08-11 13:05:51 +04:00
Brad Fitzpatrick
3e38b7f246 net/http: simplify server, use bufio Reader.Reset and Writer.Reset
Update #5100
Update #6086

Remove switchReader, switchWriter, switchReaderPair,
switchWriterPair, etc.

Now it only maintains pools of bufio Readers and Writers, but
uses Reset instead of working around all their
previously-associated state.

Compared to before the bufio Reset change, it's the same number of
allocations, and also faster:

benchmark                                   old ns/op    new ns/op    delta
BenchmarkClientServer                          111218       109828   -1.25%
BenchmarkClientServerParallel4                  70580        70013   -0.80%
BenchmarkClientServerParallel64                 72636        68919   -5.12%
BenchmarkServer                                139858       137068   -1.99%
BenchmarkServerFakeConnNoKeepAlive              14619        14314   -2.09%
BenchmarkServerFakeConnWithKeepAlive            12390        11361   -8.31%
BenchmarkServerFakeConnWithKeepAliveLite         7630         7306   -4.25%
BenchmarkServerHandlerTypeLen                    9688         9342   -3.57%
BenchmarkServerHandlerNoLen                      8700         8470   -2.64%
BenchmarkServerHandlerNoType                     9255         8949   -3.31%
BenchmarkServerHandlerNoHeader                   7058         6806   -3.57%

benchmark                                  old allocs   new allocs    delta
BenchmarkClientServer                              61           61    0.00%
BenchmarkClientServerParallel4                     61           61    0.00%
BenchmarkClientServerParallel64                    61           61    0.00%
BenchmarkServer                                    16           16    0.00%
BenchmarkServerFakeConnNoKeepAlive                 24           24    0.00%
BenchmarkServerFakeConnWithKeepAlive               19           19    0.00%
BenchmarkServerFakeConnWithKeepAliveLite            9            9    0.00%
BenchmarkServerHandlerTypeLen                      17           17    0.00%
BenchmarkServerHandlerNoLen                        14           14    0.00%
BenchmarkServerHandlerNoType                       15           15    0.00%
BenchmarkServerHandlerNoHeader                      9            9    0.00%

benchmark                                   old bytes    new bytes    delta
BenchmarkClientServer                            6988         6985   -0.04%
BenchmarkClientServerParallel4                   6979         6985    0.09%
BenchmarkClientServerParallel64                  7002         7019    0.24%
BenchmarkServer                                  1846         1848    0.11%
BenchmarkServerFakeConnNoKeepAlive               2420         2412   -0.33%
BenchmarkServerFakeConnWithKeepAlive             2126         2129    0.14%
BenchmarkServerFakeConnWithKeepAliveLite          989          990    0.10%
BenchmarkServerHandlerTypeLen                    1818         1819    0.06%
BenchmarkServerHandlerNoLen                      1775         1777    0.11%
BenchmarkServerHandlerNoType                     1783         1785    0.11%
BenchmarkServerHandlerNoHeader                    989          990    0.10%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12708046
2013-08-10 19:22:44 -07:00
Brad Fitzpatrick
ede9aa9e02 bufio: drop buffer recycling, add Reader.Reset and Writer.Reset
Fixes #6086

R=golang-dev, pieter, r, rsc
CC=golang-dev
https://golang.org/cl/12603049
2013-08-10 19:22:19 -07:00
ChaiShushan
418e2f6aae strconv: fix typo in docs
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12709044
2013-08-10 11:38:42 +10:00
Mikio Hara
db84a450d7 net: move InvalidAddrError type into net.go
Probably we should remove this type before Go 1 contract has settled,
but too late. Instead, keep InvalidAddrError close to package generic
error types.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12670044
2013-08-10 09:46:22 +09:00
Carl Shapiro
abc516e420 cmd/cc, cmd/gc, runtime: Uniquely encode iface and eface pointers in the pointer map.
Prior to this change, pointer maps encoded the disposition of
a word using a single bit.  A zero signaled a non-pointer
value and a one signaled a pointer value.  Interface values,
which are a effectively a union type, were conservatively
labeled as a pointer.

This change widens the logical element size of the pointer map
to two bits per word.  As before, zero signals a non-pointer
value and one signals a pointer value.  Additionally, a two
signals an iface pointer and a three signals an eface pointer.

Following other changes to the runtime, values two and three
will allow a type information to drive interpretation of the
subsequent word so only those interface values containing a
pointer value will be scanned.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12689046
2013-08-09 16:48:12 -07:00
Rob Pike
556b337ece encoding/binary: better description for intReadSize
It used to be called intDestSize; the new name is better too.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12713043
2013-08-10 09:11:58 +10:00
Rob Pike
1f25f5ad48 encoding/binary: fast path for reading slices
Again, it still allocates but the code is simple.

benchmark                       old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s        35580        11465  -67.78%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s       112.42       348.86    3.10x

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12694048
2013-08-10 08:40:32 +10:00
Russ Cox
d9f93b0e0b go/build: add AllTags to Package
AllTags lists all the tags that can affect the decision
about which files to include. Tools scanning packages
can use this to decide how many variants there are
and what they are.

R=bradfitz
CC=golang-dev
https://golang.org/cl/12703044
2013-08-09 18:34:08 -04:00
Russ Cox
080e00d55d encoding/json: escape & always
There are a few different places in the code that escape
possibly-problematic characters like < > and &.
This one was the only one missing &, so add it.

This means that if you Marshal a string, you get the
same answer you do if you Marshal a string and
pass it through the compactor. (Ironically, the
compaction makes the string longer.)

Because html/template invokes json.Marshal to
prepare escaped strings for JavaScript, this changes
the form of some of the escaped strings, but not
their meaning.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12708044
2013-08-09 18:33:57 -04:00
Taru Karttunen
e3dbb1a310 net/http: Make ReadResponse work with a nil Request parameter
Fixes #5583

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/9821043
2013-08-09 15:11:03 -07:00