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

9662 Commits

Author SHA1 Message Date
Alan Shreve
6f6f1bd054 syscall: implement syscall.Getppid() on Windows
Also added a test to verify os.Getppid() works across all platforms

LGTM=alex.brainman
R=golang-codereviews, alex.brainman, shreveal, iant
CC=golang-codereviews
https://golang.org/cl/102320044
2014-06-14 15:51:00 +10:00
Ian Lance Taylor
1db4c8dc41 runtime: fix VDSO lookup to use dynamic hash table
Reportedly in the Linux 3.16 kernel the VDSO will not have
section headers or a normal symbol table.

Too late for 1.3 but perhaps for 1.3.1, if there is one.

Fixes #8197.

LGTM=rsc
R=golang-codereviews, mattn.jp, rsc
CC=golang-codereviews
https://golang.org/cl/101260044
2014-06-13 13:29:26 -07:00
Nigel Tao
9f08c5c383 compress/lzw: add commentary that TIFF's LZW differs from the standard
algorithm.

See https://golang.org/cl/105750045/ for an implementation of
TIFF's LZW.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/102940043
2014-06-13 17:44:29 +10:00
Nigel Tao
eb788045d8 image/png: fix compare-to-golden-file test.
bufio.Scanner.Scan returns whether the scan succeeded, not whether it
is done, so the test was mistakenly breaking early.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/93670045
2014-06-13 17:43:02 +10:00
Russ Cox
50365666c7 undo CL 101970047 / 30307cc8bef2
makes windows-amd64-race benchmarks slower

««« original CL description
testing: make benchmarking faster

Allow the number of benchmark iterations to grow faster for fast benchmarks, and don't round up twice.

Using the default benchtime, this CL reduces wall clock time to run benchmarks:

net/http        49s   -> 37s   (-24%)
runtime         8m31s -> 5m55s (-30%)
bytes           2m37s -> 1m29s (-43%)
encoding/json   29s   -> 21s   (-27%)
strings         1m16s -> 53s   (-30%)

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

TBR=josharian
CC=golang-codereviews
https://golang.org/cl/105950044
2014-06-13 02:04:03 -04:00
Russ Cox
060a988011 runtime: revise CL 105140044 (defer nil) to work on Windows
It appears that something about Go on Windows
cannot handle the fault cause by a jump to address 0.
The way Go represents and calls functions, this
never happened at all, until CL 105140044.

This CL changes the code added in CL 105140044
to make jump to 0 impossible once again.

Fixes #8047. (again, on Windows)

TBR=bradfitz
R=golang-codereviews, dave
CC=adg, golang-codereviews, iant, r
https://golang.org/cl/105120044
2014-06-12 21:12:53 -04:00
Rob Pike
ce39b34f36 time: change formatting of microseconds duration to SI modifier
'u' is not micro, µ (U+00B5) is.

LGTM=gri, bradfitz
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/105030046
2014-06-12 17:01:13 -07:00
Russ Cox
597f87c997 runtime: do not trace past jmpdefer during pprof traceback on arm
jmpdefer modifies PC, SP, and LR, and not atomically,
so walking past jmpdefer will often end up in a state
where the three are not a consistent execution snapshot.
This was causing warning messages a few frames later
when the traceback realized it was confused, but given
the right memory it could easily crash instead.

Update #8153

LGTM=minux, iant
R=golang-codereviews, minux, iant
CC=golang-codereviews, r
https://golang.org/cl/107970043
2014-06-12 16:34:54 -04:00
Russ Cox
36207a91d3 runtime: fix defer of nil func
Fixes #8047.

LGTM=r, iant
R=golang-codereviews, r, iant
CC=dvyukov, golang-codereviews, khr
https://golang.org/cl/105140044
2014-06-12 16:34:36 -04:00
Rob Pike
83c8140662 time: avoid broken fix for buggy TestOverflowRuntimeTimer
The test requires that timerproc runs, but busy loops and starves
the scheduler so that, with high probability, timerproc doesn't run.
Avoid the issue by expecting the test to succeed; if not, a major
outside timeout will kill it and let us know.

As you can see from the diffs, there have been several attempts to
fix this with chicanery, but none has worked. Don't bother trying
any more.

Fixes #8136.

LGTM=rsc
R=rsc, josharian
CC=golang-codereviews
https://golang.org/cl/105140043
2014-06-12 11:44:55 -07:00
Brad Fitzpatrick
e46be90fec encoding/json: remove unused field from Encoder struct
It should've been removed in https://golang.org/cl/9365044

Thanks to Jacek Masiulaniec for noticing.

LGTM=ruiu
R=ruiu
CC=golang-codereviews
https://golang.org/cl/109880043
2014-06-12 09:44:59 -07:00
Josh Bleecher Snyder
a5bb1af432 testing: make benchmarking faster
Allow the number of benchmark iterations to grow faster for fast benchmarks, and don't round up twice.

Using the default benchtime, this CL reduces wall clock time to run benchmarks:

net/http        49s   -> 37s   (-24%)
runtime         8m31s -> 5m55s (-30%)
bytes           2m37s -> 1m29s (-43%)
encoding/json   29s   -> 21s   (-27%)
strings         1m16s -> 53s   (-30%)

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/101970047
2014-06-12 07:51:32 -07:00
Rui Ueyama
b93f83f8e1 encoding/ascii85: remove unused field
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/105890044
2014-06-11 22:52:01 -07:00
Rui Ueyama
f7c99f3377 net: efficient text processing
Optimize IP.String, IPMask.String and ParseIP.

benchmark                old ns/op    new ns/op    delta
BenchmarkParseIP              2216         1849  -16.56%
BenchmarkIPString             7828         2486  -68.24%
BenchmarkIPMaskString         3872          659  -82.98%

LGTM=mikioh.mikioh, dave, bradfitz
R=golang-codereviews, mikioh.mikioh, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/95750043
2014-06-11 20:40:00 -07:00
Rui Ueyama
f837078c50 net: do not call time.Now() twice
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/104080043
2014-06-11 20:33:44 -07:00
Rui Ueyama
7bcbb65d78 bytes, strings: optimize Repeat
Call copy with as large buffer as possible to reduce the
number of function calls.

benchmark                 old ns/op    new ns/op    delta
BenchmarkBytesRepeat            540          162  -70.00%
BenchmarkStringsRepeat          563          177  -68.56%

LGTM=josharian
R=golang-codereviews, josharian, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/90550043
2014-06-11 19:03:59 -07:00
Rui Ueyama
22a5d2cc96 mime/multipart: fix format
Remove unnecessary blank line.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/105040045
2014-06-11 17:39:34 -07:00
Robert Griesemer
3d68dc3325 math: remove Nextafter64 alias in favor of existing Nextafter
LGTM=adonovan
R=rsc, adonovan
CC=golang-codereviews
https://golang.org/cl/104050045
2014-06-11 14:24:16 -07:00
Rui Ueyama
afb7b67ae9 encoding/base64, encoding/base32: make DecodeString faster
Previously, an input string was stripped of newline
characters at the beginning of DecodeString and then passed
to Decode. Decode again tried to strip newline characters.
That's waste of time.

benchmark                 old MB/s     new MB/s  speedup
BenchmarkDecodeString        38.37        65.20    1.70x

LGTM=dave, bradfitz
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/91770051
2014-06-11 11:22:08 -07:00
Robert Griesemer
be91bc29a4 math/big: implement Rat.Float32
Pending CL 101750048.
For submission after the 1.3 release.

Fixes #8065.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/93550043
2014-06-11 09:10:49 -07:00
Robert Griesemer
a9035ede1b math: implement Nextafter32
Provide Nextafter64 as alias to Nextafter.
For submission after the 1.3 release.

Fixes #8117.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/101750048
2014-06-11 09:09:37 -07:00
Brad Fitzpatrick
1e6a19be64 net/http: fix double Content-Length in response
Fixes #8180

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105040043
2014-06-10 16:52:37 -07:00
Russ Cox
4534fdb144 runtime: fix panic stack during runtime.Goexit during panic
A runtime.Goexit during a panic-invoked deferred call
left the panic stack intact even though all the stack frames
are gone when the goroutine is torn down.
The next goroutine to reuse that struct will have a
bogus panic stack and can cause the traceback routines
to walk into garbage.

Most likely to happen during tests, because t.Fatal might
be called during a deferred func and uses runtime.Goexit.

This "not enough cleared in Goexit" failure mode has
happened to us multiple times now. Clear all the pointers
that don't make sense to keep, not just gp->panic.

Fixes #8158.

LGTM=iant, dvyukov
R=iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/102220043
2014-06-06 16:52:14 -04:00
Ian Lance Taylor
0e197515b6 debug/elf: support DWARF that needs relocs for 386
It's not clear how widespread this issue is, but we do have a
test case generated by a development version of clang.

I don't know whether this should go into 1.3 or not; happy to
hear arguments either way.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/96680045
2014-06-03 16:39:40 -07:00
Ian Lance Taylor
68bbf9d464 compress/gzip: allow Reset on Reader without NewReader
Fixes #8126.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/103020044
2014-06-03 15:40:12 -07:00
Brad Fitzpatrick
19fe9a2c72 crypto/tls: fix typo referencing the required Config field
Thanks to Frithjof Schulze for noticing.

LGTM=adg
R=adg
CC=agl, golang-codereviews, r
https://golang.org/cl/107740043
2014-06-03 18:11:17 +10:00
Brad Fitzpatrick
14a75ecf4a time: support version 3 zone records
Fixes #8134

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r, rsc
https://golang.org/cl/100930044
2014-06-03 11:44:17 +09:00
Russ Cox
d646040fd1 runtime: fix 1-byte return during x.(T) for 0-byte T
The 1-byte write was silently clearing a byte on the stack.
If there was another function call with more arguments
in the same stack frame, no harm done.
Otherwise, if the variable at that location was already zero,
no harm done.
Otherwise, problems.

Fixes #8139.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews, iant, r
https://golang.org/cl/100940043
2014-06-02 21:06:30 -04:00
Russ Cox
bcfe519d58 runtime: fix correctness test at end of traceback
We were requiring that the defer stack and the panic stack
be completely processed, thinking that if any were left over
the stack scan and the defer stack/panic stack must be out
of sync. It turns out that the panic stack may well have
leftover entries in some situations, and that's okay.

Fixes #8132.

LGTM=minux, r
R=golang-codereviews, minux, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/100900044
2014-06-01 13:57:46 -04:00
Keith Randall
548b15def6 runtime: mark some C globals as having no pointers.
C globals are conservatively scanned.  This helps
avoid false retention, especially for 32 bit.

LGTM=rsc
R=golang-codereviews, khr, rsc
CC=golang-codereviews
https://golang.org/cl/102040043
2014-05-31 19:21:17 -04:00
Russ Cox
14d2ee1d00 runtime: make continuation pc available to stack walk
The 'continuation pc' is where the frame will continue
execution, if anywhere. For a frame that stopped execution
due to a CALL instruction, the continuation pc is immediately
after the CALL. But for a frame that stopped execution due to
a fault, the continuation pc is the pc after the most recent CALL
to deferproc in that frame, or else 0. That is where execution
will continue, if anywhere.

The liveness information is only recorded for CALL instructions.
This change makes sure that we never look for liveness information
except for CALL instructions.

Using a valid PC fixes crashes when a garbage collection or
stack copying tries to process a stack frame that has faulted.

Record continuation pc in heapdump (format change).

Fixes #8048.

LGTM=iant, khr
R=khr, iant, dvyukov
CC=golang-codereviews, r
https://golang.org/cl/100870044
2014-05-31 10:10:12 -04:00
Russ Cox
e56dc99665 cmd/gc: fix handling of for post-condition in -race mode
Fixes #8102.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/100870046
2014-05-31 09:35:54 -04:00
Russ Cox
19c8f67e25 runtime: fix error check in freebsd/386 i386_set_ldt
Update #2675

The code here was using the error check for Linux/386,
not the one for FreeBSD/386. Most of the time it worked.

Thanks to Neel Natu (FreeBSD developer) for finding this.

The s/JCC/JAE/ a few lines later is a no-op but makes the
test match the rest of the file. Why we write JAE instead of JCC
I don't know, but the two are equivalent and the file might
as well be consistent.

LGTM=bradfitz, minux
R=golang-codereviews, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/99680044
2014-05-31 09:35:37 -04:00
Shenghou Ma
a238973949 runtime/debug: skip TestWriteHeapDumpNonempty on NaCl.
TestWriteHeap is useless on NaCl anyway.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/101980048
2014-05-31 02:30:01 -07:00
Shenghou Ma
a68b9be935 runtime: fix empty heap dump bug on windows.
Fixes #8119.

LGTM=khr, rsc
R=alex.brainman, khr, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/93640044
2014-05-31 01:09:48 -07:00
Ian Lance Taylor
aad4609c08 runtime: add zero field to rtype
The rtype struct is meant to be a copy of reflect.rtype.  The
zero field was added to reflect.rtype in 18495:6e50725ac753.

LGTM=rsc
R=khr, rsc
CC=golang-codereviews
https://golang.org/cl/93660045
2014-05-30 07:56:05 -07:00
Russ Cox
6c10e64a90 regexp: hide one-pass code from exported API
Update #8112

Hide one-pass regexp API.

This means moving the code from regexp/syntax to regexp,
but it avoids being locked into the specific API chosen for
the implementation.

It also removes a slice field from the syntax.Inst, which
should avoid bloating the memory footprint of a non-one-pass
regexp unnecessarily.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/98610046
2014-05-28 14:08:44 -04:00
Brad Fitzpatrick
ef25861222 mime: sort attributes in FormatMediaType
Map iteration order issue. Go 1.2 and earlier had stable results
for small maps.

Fixes #8115

LGTM=r, rsc
R=golang-codereviews, r
CC=dsymonds, golang-codereviews, iant, rsc
https://golang.org/cl/98580047
2014-05-28 08:16:09 -07:00
Dmitriy Vyukov
b5caa02067 runtime: fix go of nil func value
Currently runtime derefences nil with m->locks>0,
which causes unrecoverable fatal error.
Panic instead.
Fixes #8045.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/97620043
2014-05-28 00:00:01 -04:00
Keith Randall
3d1c3e1e26 runtime: stack copier should handle nil defers without faulting.
fixes #8047

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/101800043
2014-05-27 16:26:08 -07:00
Dave Cheney
8a2fb87b99 runtime: skip stack growth test on 32bit platforms
Update #8083

See discussion in https://groups.google.com/forum/#!topic/golang-dev/dh6Ra_xJomc

LGTM=khr
R=golang-codereviews, gobot, khr
CC=golang-codereviews
https://golang.org/cl/99440048
2014-05-25 08:38:59 +10:00
Keith Randall
4b3019b17c doc: mention that reflect.SetMapIndex no longer panics
when deleting from a nil map.  See issue 8051.

LGTM=r
R=golang-codereviews, r, khr
CC=golang-codereviews
https://golang.org/cl/96540051
2014-05-23 17:39:58 -07:00
Alex Brainman
05cc78d8d3 os: document that Interrupt might not work on every os
Fixes #6720.

LGTM=bradfitz
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/92340043
2014-05-23 12:29:29 +10:00
Keith Randall
cee8bcabfa runtime: provide gc maps for the reflect.callXX frames.
Update #8030

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100620045
2014-05-21 14:28:34 -07:00
Rob Pike
4464ae280f fmt: fix floating-point padding once and for all
Rewrite formatFloat to be much simpler and clearer and
avoid the tricky interaction with padding.
The issue refers to complex but the problem is just floating-point.
The new tests added were incorrectly formatted before this fix.
Fixes #8064.

LGTM=jscrockett01, rsc
R=rsc, jscrockett01
CC=golang-codereviews
https://golang.org/cl/99420048
2014-05-21 12:30:43 -07:00
Ian Lance Taylor
7d4cb4d63f database/sql/driver: correct method name in comment
Fixes #8061.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/93520046
2014-05-21 06:48:41 -07:00
Keith Randall
cb6cb42ede reflect: don't panic on delete from nil map.
Fixes #8051

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/95560046
2014-05-20 16:26:04 -07:00
Shenghou Ma
ca6be91cbc all: fix "the the" typos.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93470043
2014-05-20 14:42:07 -04:00
Shenghou Ma
8aa8348b51 runtime: revise the document of Version()
Fixes #7701. (again, differently)

LGTM=rsc
R=iant, rsc
CC=golang-codereviews
https://golang.org/cl/94560043
2014-05-20 14:41:24 -04:00
David du Colombier
b28aa1f1ec debug/plan9obj: cleanup api
- Don't export Prog structure.
- Remove ProgHeader and ExecTable structures.
- Add Magic, Bss and Entry fields in FileHeader.
- Replace ?_MAGIC variables with constants.
- Ignore final EOF from ReadAt.
- Improve documentation.

Fixes #7989.

LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/91400044
2014-05-20 10:56:50 -07:00
Russ Cox
0c2a727477 build: make nacl pass
Add nacl.bash, the NaCl version of all.bash.
It's a separate script because it builds a variant of package syscall
with a large zip file embedded in it, containing all the input files
needed for tests.

Disable various tests new since the last round, mostly the ones using os/exec.

Fixes #7945.

LGTM=dave
R=golang-codereviews, remyoudompheng, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/100590044
2014-05-20 12:10:19 -04:00
Russ Cox
82854d7b39 syscall: fix Write(nil) on NaCl
Fixes #7050.

LGTM=crawshaw, r
R=golang-codereviews, crawshaw, r
CC=golang-codereviews
https://golang.org/cl/91590043
2014-05-20 11:38:34 -04:00
Russ Cox
6aee29648f runtime: switch default stack size back to 8kB
The move from 4kB to 8kB in Go 1.2 was to eliminate many stack split hot spots.

The move back to 4kB was predicated on copying stacks eliminating
the potential for hot spots.

Unfortunately, the fact that stacks do not copy 100% of the time means
that hot spots can still happen under the right conditions, and the slowdown
is worse now than it was in Go 1.2. There is a real program in issue 8030 that
sees about a 30x slowdown: it has a reflect call near the top of the stack
which inhibits any stack copying on that segment.

Go back to 8kB until stack copying can be used 100% of the time.

Fixes #8030.

LGTM=khr, dave, iant
R=iant, khr, r, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/92540043
2014-05-20 00:30:46 -04:00
Rob Pike
431b96bdbe text/template,html/template: document that partial results may be written on error
Fixes #7445.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/94640043
2014-05-19 14:29:45 -07:00
Brad Fitzpatrick
f0bdee171f net/http: document that ProxyFromEnvironment special-cases localhost
Fixes #7256

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, rsc
https://golang.org/cl/97590043
2014-05-19 10:12:15 -07:00
Brad Fitzpatrick
7b103c555f database/sql: more docs explaining that DB is a pool
This is the main point of confusion and the emphasis of
a recent Gophercon talk.

Fixes #5886. (mostly fixed in previous commits)

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/100560043
2014-05-19 09:54:47 -07:00
Russ Cox
5aca051494 math/rand: restore Go 1.2 value stream for Float32, Float64
CL 22730043 fixed a bug in these functions: they could
return 1.0 despite documentation saying otherwise.
But the fix changed the values returned in the non-buggy case too,
which might invalidate programs depending on a particular
stream when using rand.Seed(0) or when passing their own
Source to rand.New.

The example test says:
        // These tests serve as an example but also make sure we don't change
        // the output of the random number generator when given a fixed seed.
so I think there is some justification for thinking we have
promised not to change the values. In any case, there's no point in
changing the values gratuitously: we can easily fix this bug without
changing the values, and so we should.

That CL just changed the test values too, which defeats the
stated purpose, but it was just a comment.
Add an explicit regression test, which might be
a clearer signal next time that we don't want to change
the values.

Fixes #6721. (again)
Fixes #8013.

LGTM=r
R=iant, r
CC=golang-codereviews
https://golang.org/cl/95460049
2014-05-19 12:30:25 -04:00
Russ Cox
d54b67df0c reflect: test, fix access to nil maps
Fixes #8010.

LGTM=bradfitz, khr
R=khr, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/91450048
2014-05-19 09:36:47 -04:00
Dmitriy Vyukov
e893acf184 runtime: fix freeOSMemory to free memory immediately
Currently freeOSMemory makes only marking phase of GC, but not sweeping phase.
So recently memory is not released after freeOSMemory.
Do both marking and sweeping during freeOSMemory.
Fixes #8019.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/97550043
2014-05-19 12:06:30 +04:00
Dave Cheney
ae6cbd4fcf syscall: fix arm build
Rename Seek to seek in asm file, was overlooked in CL 99320043.

LGTM=bradfitz, r
R=r, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/99320044
2014-05-17 00:06:56 +00:00
Brad Fitzpatrick
4c8de36e2b net/http: allow Content-Type on 204 responses
Accidental change from fixing Content-Length on 204s
in http://golang.org/issue/6685 earlier.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/92400047
2014-05-16 15:39:59 -07:00
Rob Pike
86bf6324c1 encoding/xml: fix format in test message
Found by go vet.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/100510044
2014-05-16 13:18:28 -07:00
Rob Pike
4cf79eb80c syscall: fix linux amd64 build
TBR=rsc

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100500047
2014-05-16 09:30:28 -07:00
Russ Cox
bf68f6623a syscall: fix a few Linux system calls
These functions claimed to return error (an interface)
and be implemented entirely in assembly, but it's not
possible to create an interface from assembly
(at least not easily).

In reality the functions were written to return an errno uintptr
despite the Go prototype saying error.
When the errno was 0, they coincidentally filled out a nil error
by writing the 0 to the type word of the interface.
If the errno was ever non-zero, the functions would
create a non-nil error that would crash when trying to
call err.Error().

Luckily these functions (Seek, Time, Gettimeofday) pretty
much never fail, so it was all kind of working.

Found by go vet.

LGTM=bradfitz, r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/99320043
2014-05-16 12:15:32 -04:00
Guillaume J. Charmes
6d63d4f3be archive/tar: Do not panic on Read if uninitialized
Calling tar.Reader.Read() used to work fine, but without this patch it panics.
Simply return EOF to indicate the tar.Reader.Next() needs to be called.

LGTM=iant, bradfitz
R=golang-codereviews, bradfitz, iant, mikioh.mikioh, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/94530043
2014-05-15 15:18:05 -07:00
Mikio Hara
40e7f6493b syscall: regenerate z-files for openbsd
This CL restores dropped constants not supported in OpenBSD 5.5
and tris to keep the promise of API compatibility.

Update #7049

LGTM=jsing, bradfitz, rsc
R=rsc, jsing, robert.hencke, minux.ma, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/96970043
2014-05-16 06:49:15 +09:00
Robert Griesemer
b2d1a2b513 container/heap: update example code
- use Init to establish heap invariant on
  a non-empty heap
- use Fix to update heap after an element's
  properties have been changed

(The old code used Init where it wasn't needed,
 and didn't use Fix because Fix was added after
 the example was written.)

LGTM=bradfitz
R=adonovan, bradfitz
CC=golang-codereviews
https://golang.org/cl/94520043
2014-05-15 13:58:13 -07:00
Russ Cox
7ad60b7283 syscall: fix stack frame sizes in assembly
for GOOS in darwin freebsd linux nacl netbsd openbsd plan9 solaris windows
do
        for GOARCH in 386 amd64 amd64p32 arm
        do
                go vet
        done
done

These are all real mistakes being corrected, but none
of them should be able to cause problems today
due to the NOSPLIT on the functions.

However, vet has also identified a few important problems.
I'm sending this CL to get rid of the trivial 'go vet' results
before attacking the real ones.

LGTM=r
R=golang-codereviews, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/95460046
2014-05-15 16:47:53 -04:00
Russ Cox
42ea2eda49 sync/atomic: fix unimportant assembly errors found by go vet
None of these are real bugs.
The variable name in the reference is not semantically meaningful,
except that 'go vet' will double check the offset against the name for you.

The stack sizes being corrected really are incorrect but they are also
in NOSPLIT functions so they typically don't matter.

Found by vet.

GOOS=linux GOARCH=amd64 go vet sync/atomic
GOOS=linux GOARCH=amd64p32 go vet sync/atomic
GOOS=linux GOARCH=386 go vet sync/atomic
GOOS=linux GOARCH=arm go vet sync/atomic
GOOS=freebsd GOARCH=arm go vet sync/atomic
GOOS=netbsd GOARCH=arm go vet sync/atomic

LGTM=r
R=r, bradfitz
CC=golang-codereviews
https://golang.org/cl/100500043
2014-05-15 16:31:20 -04:00
Russ Cox
68aaf2ccda runtime: make scan of pointer-in-interface same as scan of pointer
The GC program describing a data structure sometimes trusts the
pointer base type and other times does not (if not, the garbage collector
must fall back on per-allocation type information stored in the heap).
Make the scanning of a pointer in an interface do the same.
This fixes a crash in a particular use of reflect.SliceHeader.

Fixes #8004.

LGTM=khr
R=golang-codereviews, khr
CC=0xe2.0x9a.0x9b, golang-codereviews, iant, r
https://golang.org/cl/100470045
2014-05-15 15:53:36 -04:00
Mikio Hara
27b9897496 net/http: fix nits found by go tool vet
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/91480043
2014-05-15 12:41:45 -07:00
Russ Cox
fbd0915008 crypto/sha256, crypto/sha512: fix argument size in assembly
The function takes 32 bytes of arguments: 8 for the *block
and then 3*8 for the slice.

The 24 is not causing a bug (today at least) because the
final word is the cap of the slice, which the assembly
does not use.

Identified by 'go vet std'.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96360043
2014-05-15 15:34:25 -04:00
Guillaume J. Charmes
bf1d400d1c net: detect changes to /etc/resolv.conf.
Implement the changes as suggested by rsc.
Fixes #6670.

LGTM=josharian, iant
R=golang-codereviews, iant, josharian, mikioh.mikioh, alex, gobot
CC=golang-codereviews, rsc
https://golang.org/cl/83690045
2014-05-14 17:11:00 -07:00
Guillaume J. Charmes
51f3cbabfc archive/tar: Fix bug preventing untar
Do not use ustar format if we need the GNU one.
Change \000 to \x00 for consistency
Check for "ustar\x00" instead of "ustar\x00\x00" for conistency with tar
and compatiblity with archive generated with older code (which was ustar\x00\x20\x00)
Add test for long name + big file.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/99050043
2014-05-14 10:15:43 -07:00
Mikio Hara
d145f0f0f8 net: fix documentation for SetLinger
Fixes #7974.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95320043
2014-05-14 12:12:01 +09:00
Rob Pike
f54f790a77 regexp/syntax: don't waste time checking for one pass algorithm
The code recurs very deeply in cases like (?:x{1,1000}){1,1000}
Since if much time is spent checking whether one pass is possible, it's not
worth doing at all, a simple fix is proposed: Stop if the check takes too long.
To do this, we simply avoid machines with >1000 instructions.

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

Fixes #7608.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/92290043
2014-05-13 12:17:49 -07:00
Dmitriy Vyukov
5bc1cef869 reflect: fix map type generation
If a map variable is created with reflect.New it has incorrect type (map[unsafe.Pointer]unsafe.Pointer).
If GC follows such pointer, it scans Hmap and buckets with incorrect type.
This can lead to overscan of up to 120 bytes for map[int8]struct{}.
Which in turn can lead to crash if the memory after a bucket object is unaddressable
or false retention (buckets are scanned as arrays of unsafe.Pointer).
I don't see how it can lead to heap corruptions, though.

LGTM=khr
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/96270044
2014-05-13 09:53:47 +04:00
Dmitriy Vyukov
a12661329b runtime: fix triggering of forced GC
mstats.last_gc is unix time now, it is compared with abstract monotonic time.
On my machine GC is forced every 5 mins regardless of last_gc.

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, iant, rsc
https://golang.org/cl/91350045
2014-05-13 09:53:03 +04:00
Russ Cox
30b8af98c0 runtime: handle decommit failure gracefully on Windows
I have no test case for this at tip.
The original report included a program crashing at revision 88ac7297d2fa.
I tested this code at that revision and it does fix the crash.
However, at tip the reported code no longer crashes, presumably
because some allocation patterns have changed. I believe the
bug is still present at tip and that this code still fixes it.

Fixes #7143.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=dvyukov, golang-codereviews
https://golang.org/cl/96300046
2014-05-13 01:09:38 -04:00
Russ Cox
211618c26e io: copy slice argument in MultiReader and MultiWriter
Replaces CL 91240045.
Fixes #7809.

LGTM=bradfitz
R=golang-codereviews, minux.ma
CC=adg, bradfitz, golang-codereviews, iant, r
https://golang.org/cl/94380043
2014-05-12 23:38:35 -04:00
Russ Cox
fc1e5a8acd encoding/json: document what unmarshal of null into non-reference type does
Originally it was an error, which made perfect sense, but in issue 2540
I got talked out of this sensible behavior. I'm not thrilled with the "new"
behavior but it's been there since Go 1.1 so we're stuck with it now.

Fixes #6724.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/100430043
2014-05-12 23:38:26 -04:00
Jason Del Ponte
92440fb5bd encoding/xml: fix to allow xml declaration with EncodeToken
This changes allows the first token encoded to be a xml declaration. A ProcInst with target of xml. Any other ProcInst after that with a target of xml will fail

Fixes #7380.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/72410043
2014-05-12 23:35:56 -04:00
Brad Fitzpatrick
270848509b mime/multipart: add NewReader example
Fixes #7888

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/100420043
2014-05-12 20:26:27 -07:00
Fabrizio Milo
7e8bc474db net/http: fix flaky test
Prevent idle transport on race condition.

Fixes #7847

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/96230044
2014-05-12 09:37:36 -07:00
Brad Fitzpatrick
c91aea6c31 undo CL 92210044 / 5cb21eee2d35
<enter reason for undo>

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

Fixes #7971.

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

TBR=iant
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/96220049
2014-05-12 08:48:19 -07:00
Mikio Hara
900d49bf17 net: make use of SO_LINGER_SEC on darwin
Fixes #7971.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/92210044
2014-05-13 00:38:36 +09:00
Russ Cox
ee7bb07a53 runtime: add copy of math.sqrt for use by arm softfloat
If it's not used (such as on other systems or if softfloat
is disabled) the linker will discard it.

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

Fixes #6994.

LGTM=bradfitz, dave
R=golang-codereviews, bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/95290043
2014-05-12 10:55:33 -04:00
Péter Surányi
176041e4c6 unicode: fix doc typo
LGTM=robert.hencke, iant
R=golang-codereviews, robert.hencke, iant
CC=golang-codereviews
https://golang.org/cl/96230043
2014-05-11 22:06:00 -07:00
David Crawshaw
82ca308743 net/rpc: do not leak client socket on closed connection
Fixes #6897.

LGTM=bradfitz
R=golang-codereviews, bradfitz, r, rsc
CC=golang-codereviews
https://golang.org/cl/91230045
2014-05-11 14:46:44 -07:00
Brad Fitzpatrick
b600de755d undo CL 100330043 / e4248ed0037c
<enter reason for undo>

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

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

»»»

TBR=minux
R=minux.ma
CC=golang-codereviews
https://golang.org/cl/96200044
2014-05-09 17:31:35 -07:00
Bill Neubauer
42c9eaaa49 runtime/race: fix the link for the race detector.
LGTM=bradfitz
R=golang-dev, bradfitz
CC=golang-codereviews
https://golang.org/cl/100330043
2014-05-09 16:33:23 -07:00
Keith Randall
711d1ad7ee runtime: be a lot more lenient on smhasher avalanche test.
Fixes #7943

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98170043
2014-05-09 15:50:57 -07:00
Ian Lance Taylor
e3eee85b0d net/url: correct documentation of Values.Add
Fixes #7816.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/98160043
2014-05-09 15:49:21 -07:00
Rui Ueyama
cdabca325e bytes: fix typos
LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/94240045
2014-05-10 07:13:42 +09:00
Ian Lance Taylor
c00804c55c encoding/binary: document that Read requires exported struct fields
Add a test for the current behaviour.

Fixes #7482.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/95160043
2014-05-09 14:19:21 -07:00
Russ Cox
2182d5786b math/cmplx: specify which square root Sqrt returns
Fixes #7851.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93200043
2014-05-09 16:04:03 -04:00
Russ Cox
3e8ed96c63 crypto/aes: fix overrun in assembly encrypt/decrypt
Fixes #7928.

LGTM=bradfitz
R=golang-codereviews
CC=agl, bradfitz, golang-codereviews
https://golang.org/cl/91320043
2014-05-09 15:40:55 -04:00
Russ Cox
21e75b3251 testing: write profiles on failure
Fixes #7901.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/90930044
2014-05-09 12:18:50 -04:00
Mikio Hara
f40f0b26b6 net: drop flakey TestDialFailPDLeak
TestDialFailPDLeak was created for testing runtime-integrated netwrok
poller stuff and used during Go 1.2 development cycle. Unfortunately
it's still flakey because it depends on MemStats of runtime, not
pollcache directly, and MemStats accounts and revises its own stats
occasionally.

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

Fixes #6553.

LGTM=josharian, iant
R=iant, josharian
CC=golang-codereviews
https://golang.org/cl/98080043
2014-05-09 09:38:29 +09:00
Keith Randall
65c63dc4aa runtime: write memory profile statistics to the heap dump.
LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/97010043
2014-05-08 08:35:49 -07:00