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

13225 Commits

Author SHA1 Message Date
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
Dmitriy Vyukov
06e686def6 cmd/5g, cmd/6g, cmd/8g: faster compilation
Replace linked list walk with memset.
This reduces CPU time taken by 'go install -a std' by ~10%.
Before:
real		user		sys
0m23.561s	0m16.625s	0m5.848s
0m23.766s	0m16.624s	0m5.846s
0m23.742s	0m16.621s	0m5.868s
after:
0m22.714s	0m14.858s	0m6.138s
0m22.644s	0m14.875s	0m6.120s
0m22.604s	0m14.854s	0m6.081s

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13084043
2013-08-21 14:20:28 +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
Andrew Gerrand
2f6e9a1e24 cmd/go: only try to clean executables for package main
Fixes #5665.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12807044
2013-08-19 16:22:33 +10:00
Rob Pike
c974b8b6ac cmd/go: diagnose import cycles better
Before this CL, the import stack was a) not printed and b) overwritten later
in the build, destroying the information about the cycle. This CL fixes both.

I made time depend on os (os already depends on time) and with this CL the error is:

/Users/r/go/src/pkg/fmt/print.go:10:2: import cycle not allowed
package code.google.com/p/XXX/YYY:
        imports fmt
        imports os
        imports time
        imports os

Doesn't give line numbers for the actual imports, as requested in the bug, but
I don't believe that's important.

Fixes #4292.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13100043
2013-08-19 15:50:57 +10:00
David Symonds
a790388afb cmd/gc: regenerate y.tab.{c,h} with Bison 2.5.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/12744048
2013-08-19 13:47:43 +10:00
Anthony Martin
f316a7ea87 cmd/gc: don't attempt to generate wrappers for blank interface methods
Fixes #5691.

R=golang-dev, bradfitz, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/10255047
2013-08-19 11:53:34 +10:00
Rob Pike
d00bd1d1f4 cmd/gc: better error messages for C-style if statements.
Given
        if (i == 0)
                x++
The old message was
        x.go:6: syntax error: unexpected semicolon or newline before {
Now we see
        x.go:6: syntax error: missing { after if clause

Fixes #5687

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12822045
2013-08-19 11:49:59 +10: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
Rob Pike
e8140bd03c make.bash: exit if dist fails
The shell's -e doesn't work across "eval"; need to error-check by hand.
The recent spate of Darwin build failures pointed out that if the first
run of cmd/dist fails, we keep going. We shouldn't.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13098043
2013-08-19 11:18:43 +10:00
David Symonds
24f302a69d cmd/dist: join with TMPDIR more carefully to avoid // in path.
This might fix the mkdtemp problem on the darwin builders if they
have TMPDIR set to a path ending in a slash; at worse this will
result in cleaner path names.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13097043
2013-08-19 11:11:27 +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
Rob Pike
7fb121aa47 cmd/dist: more informative error for mkdtemp failing
The Darwin builders are all failing here but strerror doesn't provide context.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/13095043
2013-08-19 08:29:43 +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
Russ Cox
3b4d792606 cmd/gc: separate "has pointers" from "needs zeroing" in stack frame
When the new call site-specific frame bitmaps are available,
we can cut the zeroing to just those values that need it due
to scope escaping.

R=cshapiro, cshapiro
CC=golang-dev
https://golang.org/cl/13045043
2013-08-16 21:45:59 -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
Carl Shapiro
d3b04f46b5 cmd/5g, cmd/6g, cmd/8g: update frame zeroing for new bitmap format
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12740046
2013-08-16 01:15:04 -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
Rob Pike
f0fef32383 cmd/go: fix at least some instances of double compilation
When the packages the tested package depends on don't build,
we weren't getting out early. Added a simple check for a successful
build to an existing early out.

There may be other ways that double compilation arises, but
this fixes the one listed in the issue.
Fixes #5679

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13036043
2013-08-16 12:49:51 +10:00
Rob Pike
703b897f78 cmd/gc: remove mentions of "ideal" from error messages.
_ = complex("foo", 0)
        _ = complex(true, 0)
now trigger:
        x.go:4: invalid operation: complex("foo", 0) (mismatched types untyped string and untyped number)
        x.go:5: invalid operation: complex(true, 0) (mismatched types untyped bool and untyped number)

Fixes #4521

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/12973043
2013-08-16 12:40:02 +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