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

16095 Commits

Author SHA1 Message Date
Rob Pike
d396b9df10 go/build: do not consider "android.go" to be android-specific
A file name must have a non-empty underscore-separated
prefix before its suffix matches GOOS. This is what the
documentation already said but is not what the code did.

Fixes #8838.

This needs to be called out in the release notes.
The he single affected file
        code.google.com/p/go.text/collate/tools/colcmp/darwin.go
could use a renaming but works because it has a build tag inside.

LGTM=adg, rsc
R=golang-codereviews, adg, rsc
CC=golang-codereviews
https://golang.org/cl/147690043
2014-10-06 14:50:58 -07:00
Evan Kroske
55df81d37f cmd/gc: prohibit short variable declarations containing duplicate symbols
Fixes #6764.
Fixes #8435.

LGTM=rsc
R=golang-codereviews, r, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/116440046
2014-10-06 17:16:39 -04:00
Russ Cox
1eea5caa30 os: recomment MkdirAll
The internal comments are not completely precise about
what is going on, and they are causing confusion.

Fixes #8283.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/151460043
2014-10-06 15:49:33 -04:00
Russ Cox
d21b37bbe7 os: make Process.Signal 'process finished' error consistent on Unix
While we're here, fix the implementation of Release on both
Unix and Windows: Release is supposed to make Signal an error.

While we're here, make sure we never Signal pid 0.
(Don't try this at home.)

Fixes #7658.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/152240043
2014-10-06 15:49:19 -04:00
Russ Cox
5b829cca12 net/url: document result of String
Fixes #8742.

LGTM=bradfitz
R=golang-codereviews
CC=adg, bradfitz, golang-codereviews, iant
https://golang.org/cl/155910043
2014-10-06 15:49:07 -04:00
Russ Cox
8fd56bf8c4 encoding/json: document that embedded interfaces look like non-embedded ones
Fixes #8386.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/149570043
2014-10-06 15:48:17 -04:00
Russ Cox
85fd0fd7c4 regexp/syntax: regenerate doc.go from re2 syntax
Generated using re2/doc/mksyntaxgo.

Fixes #8505.

LGTM=iant
R=r, iant
CC=golang-codereviews
https://golang.org/cl/155890043
2014-10-06 15:32:11 -04:00
Russ Cox
7e6e502f9b cmd/go: fix 'go vet' of package with external tests
For example, fixes 'go vet syscall', which has source
files in package syscall_test.

Fixes #8511.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/152220044
2014-10-06 14:49:22 -04:00
Russ Cox
9a5b055b95 runtime: update docs, code for SetFinalizer
At last minute before 1.3 we relaxed SetFinalizer to avoid
crashes when you pass the result of a global alloc to it.
This avoids the crash but makes SetFinalizer a bit too relaxed.

Document that the finalizer of a global allocation may not run.

Tighten the SetFinalizer check to ignore a global allocation but
not ignore everything else.

Fixes #7656.

LGTM=r, iant
R=golang-codereviews, iant, r
CC=dvyukov, golang-codereviews, khr, rlh
https://golang.org/cl/145930043
2014-10-06 14:18:09 -04:00
Russ Cox
609d996fac cmd/8l: accept R_386_GOT32 in push instruction
Fixes #8382.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149540045
2014-10-06 14:17:48 -04:00
Russ Cox
83001ffaaf net: disable TestDualStackUDPListener in short mode
This test is flaky, just like TestDualStackTCPListener.
That one was disabled. Disable this one too.

Update #5001

LGTM=bradfitz
R=rlh, bradfitz
CC=golang-codereviews
https://golang.org/cl/154950043
2014-10-06 13:09:14 -04:00
Alex Brainman
ee8e28d328 syscall: another attempt to keep windows syscall pointers live
This approach was suggested in
https://golang.org/cl/138250043/#msg15.
Unlike current version of mksyscall_windows.go,
new code could be used in go.sys and other external
repos without help from asm.

LGTM=iant
R=golang-codereviews, iant, r
CC=golang-codereviews
https://golang.org/cl/143160046
2014-10-05 13:15:13 +11:00
Rob Pike
a0c5adc35c fmt: print &map like &slice and &struct
It was inconsistent.
Also test these better.
Also document the default format for types.
This wasn't written down.

Fixes #8470.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154870043
2014-10-03 20:27:08 -07:00
Dave Cheney
19104dc532 crypto/x509: add OpenELEC system root location.
Fixes #8349.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/147320043
2014-10-04 08:09:39 +10:00
Rob Pike
a22424567c fmt: part 2 of the great flag rebuild: make %+v work in formatters
Apply a similar transformation to %+v that we did to %#v, making it
a top-level setting separate from the + flag itself. This fixes the
appearance of flags in Formatters and cleans up the code too,
probably making it a little faster.

Fixes #8835.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/154820043
2014-10-03 13:23:35 -07:00
Russ Cox
13da360845 runtime: clear sg.selectdone before saving in SudoG cache
Removes another dangling pointer that might
cause a memory leak in 1.4 or crash the GC in 1.5.

LGTM=rlh
R=golang-codereviews
CC=golang-codereviews, iant, khr, r, rlh
https://golang.org/cl/150520043
2014-10-03 15:33:29 -04:00
Russ Cox
0120f8378d runtime: clear stale values from G.param and SudoG.elem
This change was necessary on the dev.garbage branch
to keep the garbage collector from seeing pointers into
invalid heap areas.

On this default (Go 1.4) branch, the change removes
some possibility for memory leaks.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant, r, rlh
https://golang.org/cl/155760043
2014-10-03 13:36:48 -04:00
Russ Cox
3ffd29fb2c cmd/cc, runtime: disallow structs without tags
Structs without tags have no unique name to use in the
Go definitions generated from the C types.
This caused issue 8812, fixed by CL 149260043.
Avoid future problems by requiring struct tags.

Update runtime as needed.
(There is no other C code in the tree.)

LGTM=bradfitz, iant
R=golang-codereviews, bradfitz, dave, iant
CC=golang-codereviews, khr, r
https://golang.org/cl/150360043
2014-10-03 12:44:20 -04:00
Alex Brainman
c65a47f890 undo CL 138250043 / 4eda5e4001fd
I will use different approach to solve this problem.
See CL 143160046 for details.

««« original CL description
syscall: keep Windows syscall pointers live too

Like https://golang.org/cl/139360044

LGTM=rsc, alex.brainman
R=alex.brainman, rsc
CC=golang-codereviews
https://golang.org/cl/138250043
»»»

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/147440043
2014-10-03 10:36:54 +10:00
Rob Pike
7c8e057ad3 fmt: make the %#v verb a special flag
The %#v verb is special: it says all values below need to print as %#v.
However, for some situations the # flag has other meanings and this
causes some issues, particularly in how Formatters work. Since %#v
dominates all formatting, translate it into actual state of the formatter
and decouple it from the # flag itself within the calculations (although
it must be restored when methods are doing the work.)
The result is cleaner code and correct handling of # for Formatters.
TODO: Apply the same thinking to the + flag in a followup CL.

Also, the wasString return value in handleMethods is always false,
so eliminate it.

Update #8835

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/146650043
2014-10-02 14:16:58 -07:00
Robert Griesemer
28ddfb090c math/big: math.Exp should return result >= 0 for |m| > 0
The documentation states that Exp(x, y, m)
computes x**y mod |m| for m != nil && m > 0.
In math.big, Mod is the Euclidean modulus,
which is always >= 0.

Fixes #8822.

LGTM=agl, r, rsc
R=agl, r, rsc
CC=golang-codereviews
https://golang.org/cl/145650043
2014-10-02 13:02:25 -07:00
Robert Griesemer
1dba6eb464 encoding/binary: fix error message
In the process, simplified internal sizeOf and
dataSize functions. Minor positive impact on
performance. Added test case.

benchmark                         old ns/op     new ns/op     delta
BenchmarkReadSlice1000Int32s      14006         14122         +0.83%
BenchmarkReadStruct               2508          2447          -2.43%
BenchmarkReadInts                 921           928           +0.76%
BenchmarkWriteInts                2086          2081          -0.24%
BenchmarkWriteSlice1000Int32s     13440         13497         +0.42%
BenchmarkPutUvarint32             28.5          26.3          -7.72%
BenchmarkPutUvarint64             81.3          76.7          -5.66%

benchmark                         old MB/s     new MB/s     speedup
BenchmarkReadSlice1000Int32s      285.58       283.24       0.99x
BenchmarkReadStruct               27.90        28.60        1.03x
BenchmarkReadInts                 32.57        32.31        0.99x
BenchmarkWriteInts                14.38        14.41        1.00x
BenchmarkWriteSlice1000Int32s     297.60       296.36       1.00x
BenchmarkPutUvarint32             140.55       151.92       1.08x
BenchmarkPutUvarint64             98.36        104.33       1.06x

Fixes #6818.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/149290045
2014-10-02 12:53:51 -07:00
Mrunal Patel
f9d7e13955 syscall: support UID/GID map files for Linux user namespaces
Fixes #8447.

LGTM=iant
R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/126190043
2014-10-02 11:37:06 -07:00
Nicolas Owens
e9d5fca9f3 syscall: fix Setenv for plan 9
envi needs to be updated during Setenv so the key can be correctly deleted later with Unsetenv.

Update #8849.

LGTM=0intro
R=bradfitz, 0intro
CC=golang-codereviews
https://golang.org/cl/149300046
2014-10-02 10:25:56 +02:00
Alex Brainman
714461740c run.bat: comment text properly
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/153830044
2014-10-02 16:15:36 +10:00
Robert Griesemer
bc89e8c575 time: A Timer must be properly created before use (documentation).
Fixes #8776.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/145710043
2014-10-01 16:44:52 -07:00
Robert Griesemer
7e8218aedd encoding/json: don't panic on incorrect map argument
Fixes #8305.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/145680044
2014-10-01 16:24:17 -07:00
Robert Griesemer
94f3d8cfed encoding/binary: slightly better documentation
Fixes #7306.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/153820044
2014-10-01 16:09:55 -07:00
Rob Pike
9f4084278f fmt: fix internal unknownType function
This thing should never be called, but before
151960044 it was being called, incorrectly.
This is now just a precaution but let's pretend it
Fixes #8843
even though that was fixed by 151960044.
The test case was already there and ran, another mystery.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/151970043
2014-10-01 21:35:12 +00:00
Russ Cox
62d3202aaa reflect: fix IsValid vs Kind mismatch after Elem of nil interface
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/151960044
2014-10-01 16:51:32 -04:00
Robert Griesemer
5edff32704 testing: clearer comment
Fixes #8797.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/146680043
2014-10-01 13:19:40 -07:00
Rob Pike
cd5b785efe net/rpc: shut down connection if gob has error
The nicest solution would be to buffer the message and only write
it if it encodes correctly, but that adds considerable memory and
CPU overhead for a very rare condition. Instead, we just shut
down the connection if this happens.
Fixes #7689.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/146670043
2014-10-01 13:18:44 -07:00
Brad Fitzpatrick
85cdc49e8a os, syscall: add Unsetenv
Also address a TODO, making Clearenv pass through to cgo.

Based largely on Minux's earlier https://golang.org/cl/82040044

Fixes #6423

LGTM=iant, alex.brainman, r, rsc
R=rsc, iant, r, alex.brainman
CC=golang-codereviews
https://golang.org/cl/148370043
2014-10-01 11:17:15 -07:00
Paul van Brouwershaven
e7488b2189 x509: Fixed ASN.1 encoding in CRL Distribution Points extension
The ASN.1 encoding of the CRL Distribution Points extension showed an invalid false 'IsCompound' which caused a display problem in the Windows certificate viewer.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/143320043
2014-09-30 13:38:48 -07:00
Alan Donovan
74b8693c54 cmd/cgo: add missing ast.SliceExpr.Max case to AST traversal.
+ static test

NB: there's a preexisting (dynamic) failure of test issue7978.go.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144650045
2014-09-30 16:08:04 -04:00
Robert Griesemer
146713b67a go/format, cmd/gofmt: added missing comments, minor internal cleanup
This is a minor cleanup following CL 142360043:

The internal parse and format functions in both packages
were almost identical - made them identical by adding an
extra parameter, and documented them as identical.

Eventually we should find a nice way to factor these functions
out, but we cannot do this now while in prep for 1.4.

No functionality change.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/146520043
2014-09-30 12:26:38 -07:00
Brad Fitzpatrick
4a532c664d net/http/httputil: ensure DumpRequestOut dumps all of Body
Bodies larger than 8KB (the default bufio reader size) weren't
being dumped.  Force a read of the body so they're teed into
the response buffer.

Thanks to Steven Hartland for identifying the problem.

Fixes #8089

LGTM=r
R=golang-codereviews, r
CC=adg, golang-codereviews
https://golang.org/cl/144650044
2014-09-30 12:09:34 -07:00
Adam Langley
1b89cd1658 encoding/asn1: fix unmarshaling of implicitly tagged UTF-8 strings.
Fixes #8541.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/153770043
2014-09-30 11:49:15 -07:00
Russ Cox
c017a4e118 cmd/go: sometimes name tmp test binary test.test.exe on Windows
Right now it is always pkgname.test.exe, but if pkgname is
patch or install or setup or update, Windows thinks that
running it will install new software, so it pops up a dialog
box asking for more permission.
Renaming the binary avoids the Windows security check.

This only applies to the binary that the Go command writes
to its temporary work directory. If the user runs 'go test -c'
or any of the other ways to generate a test binary, it will
continue to use pkgname.test.exe.

Fixes #8711.

LGTM=bradfitz
R=golang-codereviews, r
CC=alex.brainman, bradfitz, golang-codereviews, iant
https://golang.org/cl/146580043
2014-09-30 14:30:40 -04:00
Russ Cox
8b5221a57b cmd/pprof: add Go implementation
Update #8798

This is a new implementation of pprof,
written in Go instead of in Perl.
It was written primarily by Raul Silvera and
is in use for profiling programs of all languages
inside Google.

The internal structure is a bit package-heavy,
but it matches the copy used inside Google, and
since it is in an internal directory, we can make
changes to it later if we need to.

The only "new" file here is src/cmd/pprof/pprof.go,
which stitches together the Google pprof and the
Go command libraries for object file access.

I am explicitly NOT interested in style or review
comments on the rest of the files
(that is, src/cmd/pprof/internal/...).
Those are intended to stay as close to the Google
copies as possible, like we did with the pprof Perl script.

Still to do:

- Basic tests.
- Real command documentation.
- Hook up disassemblers.

LGTM=r
R=r, bradfitz, alex.brainman, dave
CC=golang-codereviews
https://golang.org/cl/153750043
2014-09-30 13:41:54 -04:00
Russ Cox
454d1b0e8b cmd/gc: fix call order in array literal of slice literal of make chan
Fixes #8761.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/144530045
2014-09-30 12:48:47 -04:00
Russ Cox
a6abe22eb6 compress/*: note that NewReader may introduce buffering
Fixes #8309.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/147380043
2014-09-30 12:31:18 -04:00
Russ Cox
0239595306 compress/zlib: mention that NewReaderDict can return ErrDictionary
Fixes #7935.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, ruiu
https://golang.org/cl/147390043
2014-09-30 12:30:31 -04:00
Russ Cox
5a1906dc47 log/syslog: try /var/run/log, for FreeBSD
Fixes #8449.

LGTM=iant
R=golang-codereviews, iant
CC=bradfitz, golang-codereviews
https://golang.org/cl/145600044
2014-09-30 12:30:16 -04:00
Russ Cox
c75f81f0ed cmd/objdump: move armasm, x86asm into internal packages
For Go 1.3 these external packages were collapsed into
large single-file implementations stored in the cmd/objdump
directory.

For Go 1.4 we want pprof to be able to link against them too,
so move them into cmd/internal, where they can be shared.

The new files are copied from the repo in the file path (rsc.io/...).
Those repos were code reviewed during development
(mainly by crawshaw and minux), because we knew the
main repo would use them.

Update #8798

LGTM=bradfitz
R=crawshaw, bradfitz
CC=golang-codereviews
https://golang.org/cl/153750044
2014-09-30 12:28:24 -04:00
Russ Cox
9b2b0c8c16 regexp/syntax: reject large repetitions created by nesting small ones
Fixes #7609.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/150270043
2014-09-30 12:08:09 -04:00
Keith Randall
ac9218f5f0 runtime: fix scanning of gc work buffer
GC types were not being generated for the garbage collector
work buffer.  The markfor object was being collected as a result.
This broke amd64p32 and maybe plan9 builds.  Why it didn't break
every build I'm not sure...

Fixes #8812

LGTM=0intro, rsc
R=golang-codereviews, dave, khr, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/149260043
2014-09-30 08:51:02 -07:00
Dmitriy Vyukov
12308d5a0b runtime: fix throwsplit check
Newstack runs on g0, g0->throwsplit is never set.

LGTM=rsc
R=rsc
CC=golang-codereviews, khr
https://golang.org/cl/147370043
2014-09-30 19:34:33 +04:00
Keith Randall
70b2da98ca runtime: initialize traceback variables earlier
Our traceback code needs to know the PC of several special
functions, including goexit, mcall, etc.  Make sure that
these PCs are initialized before any traceback occurs.

Fixes #8766

LGTM=rsc
R=golang-codereviews, rsc, khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/145570043
2014-09-29 21:21:36 -07:00
Brad Fitzpatrick
f13cec9f57 net/http: make Transport.CloseIdleConnections also close pending dials
See comment 4 of https://code.google.com/p/go/issues/detail?id=8483#c4:

"So if a user creates a http.Client, issues a bunch of
requests and then wants to shutdown it and all opened connections;
what is she intended to do? The report suggests that just waiting for
all pending requests and calling CloseIdleConnections won't do, as
there can be new racing connections. Obviously she can't do what
you've done in the test, as it uses the unexported function.  If this
happens periodically, it can lead to serious resource leaks (the
transport is also preserved alive).  Am I missing something?"

This CL tracks the user's intention to close all idle
connections (CloseIdleConnections sets it true; and making a
new request sets it false). If a pending dial finishes and
nobody wants it, before it's retained for a future caller, the
"wantIdle" bool is checked and it's closed if the user has
called CloseIdleConnections without a later call to make a new
request.

Fixes #8483

LGTM=adg
R=golang-codereviews, dvyukov, adg
CC=golang-codereviews, rsc
https://golang.org/cl/148970043
2014-09-29 18:16:15 -07:00
Dmitri Shuralyov
912ec1990b go/format, cmd/gofmt: fix issues with partial Go code with indent
Fixes #5551.
Fixes #4449.

Adds tests for both issues.

Note that the two issues occur only when formatting partial Go code
with indent.

The best way to understand the change is as follows: I took the code
of cmd/gofmt and go/format, combined it into one unified code that
does not suffer from either 4449 nor 5551, and then applied that code
to both cmd/gofmt and go/format.

As a result, there is now much more identical code between the two
packages, making future code deduplication easier (it was not possible
to do that now without adding public APIs, which I was advised not to
do at this time).

More specifically, I took the parse() of cmd/gofmt which correctly
preserves comments (issue 5551) and modified it to fix issue where
it would sometimes modify literal values (issue 4449).

I ended up removing the matchSpace() function because it no longer
needed to do some of its work (insert indent), and a part of its work
had to be done in advance (determining the indentation of first code
line), because that calculation is required for cfg.Fprint() to run.

adjustIndent is used to adjust the indent of cfg.Fprint() to compensate
for the body of wrapper func being indented by one level. This allows
to get rid of the bytes.Replace text manipulation of inner content,
which was problematic and sometimes altered raw string literals (issue
4449). This means that sometimes the value of cfg.Indent is negative,
but that works as expected.

So now the algorithm for formatting partial Go code is:

1. Determine and prepend leading space of original source.
2. Determine and prepend indentation of first code line.
3. Format and write partial Go code (with all of its leading &
   trailing space trimmed).
4. Determine and append trailing space of original source.

LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/142360043
2014-09-29 17:04:48 -07:00
Dave Cheney
0b36211cfb liblink: generate MRC replacement in liblink, not tls_arm
Fixes #8690.

This CL moves the save of LR around BL runtime.read_tls_fallback to liblink as it is not needed when MRC is not replaced.

LGTM=rsc, minux
R=rsc, khr, minux
CC=golang-codereviews
https://golang.org/cl/147310043
2014-09-30 10:03:10 +10:00
Tom Linford
5368e63b57 x509: add root certs for android.
On android, root certificates appear to be stored in the folder
/system/etc/security/cacerts, which has many certs in several
different files. This change adds a new array of directories in
which certs can be found.

To test this, I simply tried making a request with the http
library to an HTTPS URL on an android emulator and manually
verified that it worked.

LGTM=crawshaw
R=golang-codereviews, gobot, crawshaw
CC=golang-codereviews
https://golang.org/cl/151800043
2014-09-30 09:51:49 +10:00
Keith Randall
b4380a3ba2 runtime: delete unused variables.
We're not comparing with code addresses any more.  Instead,
we use nil algorithm functions to mark uncomparable types.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/151040044
2014-09-29 14:05:33 -07:00
James Tucker
2da734189d net/http: enable Transfer-Encoding: identity without Content-Length for HTTP 1.1.
Use case is SSE recommended configuration: http://www.w3.org/TR/eventsource/#notes
Removes a TODO.

LGTM=bradfitz
R=golang-codereviews, bradfitz, tommi.virtanen
CC=golang-codereviews
https://golang.org/cl/100000044
2014-09-29 13:53:42 -07:00
Brad Fitzpatrick
705c1f5cd4 net/http: clarify Request.FormValue docs
Fixes #8067

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/146480043
2014-09-29 13:42:33 -07:00
Ian Lance Taylor
fe2bc11e1f cmd/yacc: fix handling of tokens that don't start with letters
CL 149110043 changed yacc to no longer keep a leading space
for quoted tokens.  That is OK by itself but unfortunately
yacc was relying on that leading space to notice which tokens
it should not output as const declarations.

Add a few such tokens to expr.y, although it won't make any
immediate difference as we seem to have no tests for yacc.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/152720043
2014-09-29 13:32:14 -07:00
Brad Fitzpatrick
1cfa5958f0 undo CL 141840043 / 65e21380cb2a
Unnecessary; covered by https://golang.org/cl/141690043

Verified by jonathan@titanous.com on golang-dev.

««« original CL description
cmd/ld: close outfile before cleanup

This prevents the temporary directory from being leaked when
the linker is run on a FUSE filesystem.

Fixes #8684.

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

»»»

LGTM=jonathan, iant
R=iant, jonathan
CC=golang-codereviews
https://golang.org/cl/150250045
2014-09-29 13:28:08 -07:00
Adam Langley
dfddd802ac crypto/x509: accept CRLs without an expiry.
RFC5280 says that the nextUpdate field is optional.

Fixes #8085.

R=bradfitz
CC=golang-codereviews
https://golang.org/cl/149770044
2014-09-29 12:26:51 -07:00
Brad Fitzpatrick
dca460574f net: fix misleading package comment example
Fixes #8607

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/146470043
2014-09-29 12:24:06 -07:00
Adam Langley
bd72d2c650 go/build: add go1.4 tag.
LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/138000044
2014-09-29 12:23:43 -07:00
Jonathan Rudenberg
e7e3b3ec10 cmd/ld: close outfile before cleanup
This prevents the temporary directory from being leaked when
the linker is run on a FUSE filesystem.

Fixes #8684.

LGTM=bradfitz
R=golang-codereviews, rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/141840043
2014-09-29 12:13:22 -07:00
Keith Randall
e1364a6d0e runtime: fix cgo_topofstack to save clobbered registers
Fixes #8816

At least, I hope it does.

TBR=rsc
CC=golang-codereviews
https://golang.org/cl/153730043
2014-09-28 23:52:08 -07:00
Ian Lance Taylor
f6fc14094a cmd/ld: don't automatically mark symbols created by -X as reachable
This fixes the bug in which the linker reports "missing Go
type information" when a -X option refers to a symbol that is
not used.

Fixes #8821.

LGTM=rsc
R=rsc, r
CC=golang-codereviews
https://golang.org/cl/151000043
2014-09-28 08:27:05 -07:00
Russ Cox
4a8cb4a49c math: avoid assumption of denormalized math mode in Sincos
The extra-clever code in Sincos is trying to do

        if v&2 == 0 {
                mask = 0xffffffffffffffff
        } else {
                mask = 0
        }

It does this by turning v&2 into a float64 X0 and then using

        MOVSD $0.0, X3
        CMPSD X0, X3, 0

That CMPSD is defined to behave like:

        if X0 == X3 {
                X3 = 0xffffffffffffffff
        } else {
                X3 = 0
        }

which gives the desired mask in X3. The goal in using the
CMPSD was to avoid a conditional branch.

This code fails when called from a PortAudio callback.
In particular, the failure behavior is exactly as if the
CMPSD always chose the 'true' execution.

Notice that the comparison X0 == X3 is comparing as
floating point values the 64-bit pattern v&2 and the actual
floating point value zero. The only possible values for v&2
are 0x0000000000000000 (floating point zero)
and 0x0000000000000002 (floating point 1e-323, a denormal).
If they are both comparing equal to zero, I conclude that
in a PortAudio callback (whatever that means), the processor
is running in "denormals are zero" mode.

I confirmed this by placing the processor into that mode
and running the test case in the bug; it produces the
incorrect output reported in the bug.

In general, if a Go program changes the floating point math
modes to something other than what Go expects, the math
library is not going to work exactly as intended, so we might
be justified in not fixing this at all.

However, it seems reasonable that the client code might
have expected "denormals are zero" mode to only affect
actual processing of denormals. This code has produced
what is in effect a gratuitous denormal by being extra clever.
There is nothing about the computation being requested
that fundamentally requires a denormal.

It is also easy to do this computation in integer math instead:

        mask = ((v&2)>>1)-1

Do that.

For the record, the other math tests that fail if you put the
processor in "denormals are zero" mode are the tests for
Frexp, Ilogb, Ldexp, Logb, Log2, and FloatMinMax, but all
fail processing denormal inputs. Sincos was the only function
for which that mode causes incorrect behavior on non-denormal inputs.

The existing tests check that the new assembly is correct.
There is no test for behavior in "denormals are zero" mode,
because I don't want to add assembly to change that.

Fixes #8623.

LGTM=josharian
R=golang-codereviews, josharian
CC=golang-codereviews, iant, r
https://golang.org/cl/151750043
2014-09-26 17:13:24 -04:00
Russ Cox
754cd5419a cmd/go: always build _test.go files and link into test
go test's handling of _test.go files when the entire
package's set of files has no Test functions has varied
over the past few releases. There are a few interesting
cases (all contain no Test functions):
        (1) x_test.go has syntax errors
        (2) x_test.go has type errors
        (3) x_test.go has runtime errors (say, a func init that panics)

In Go 1.1, tests with (1) or (2) failed; (3) passed.
In Go 1.2, tests with (1) or (2) failed; (3) passed.
In Go 1.3, tests with (1) failed; (2) or (3) passed.
After this CL, tests with (1), (2), or (3) all fail.

This is clearly a corner case, but it seems to me that
the behavior of the test should not change if you
add or remove a line like

        func TestAlwaysPasses(t *testing.T) {}

That implies that the _test.go files must always
be built and always be imported into the test binary.
Doing so means that (1), (2), and (3) must all fail.

Fixes #8337.

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews, r
https://golang.org/cl/150980043
2014-09-26 17:09:11 -04:00
Russ Cox
bfebf9ea80 cmd/yacc: fix parsing of character tokens
From issue 7967 I learned:

1) yacc accepts either 'x' or "x" to mean token value 0x78
2) yacc also accepts 'xyz' and "XYZ" to mean token value 0x78

Use strconv.Unquote to simplify the handling of quoted
strings and check that each has only one rune.

Although this does clean things up, it makes 'x' and "x"
treated as different internally (now they are stored as
`'x'` and `"x"`; before they were both ` x`). Grammars that
use both interchangeably will now die with an error
similar to the one from issue 7967:

        yacc bug -- cannot have 2 different Ts with same value
                "+" and '+'

The echoing of the quotes should make clear what is going on.

The other semantic change caused by using strconv.Unquote
is that '\"' and "\'" are no longer valid. Like in Go, they must be
spelled without the backslash: '"' and "'".

On the other hand, now yacc and Go agree about what character
and string literals mean.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/149110043
2014-09-26 17:03:31 -04:00
Rob Pike
b2487ef6a3 flag: allow CommandLine's Usage function to be set
Fixes #7779.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/147210043
2014-09-26 12:33:05 -07:00
Russ Cox
1bf18b42f8 cmd/go: fix -a
The one line that you can't test easily was broken.
This manifested as a failure of a pre-existing test
in test.bash but I didn't notice it (there are a few other
long-standing failures that need to be fixed).

TBR=r
CC=golang-codereviews
https://golang.org/cl/146340044
2014-09-26 15:15:48 -04:00
Russ Cox
8c3005c492 cmd/go: make build -a skip standard packages in Go releases
Today, 'go build -a my/pkg' and 'go install -a my/pkg'
recompile not just my/pkg and all its dependencies that
you wrote but also the standard library packages.
Recompiling the standard library is problematic on
some systems because the installed copy is not writable.

The -a behavior means that you can't use 'go install -a all'
or 'go install -a my/...' to rebuild everything after a Go
release - the rebuild stops early when it cannot overwrite
the installed standard library.

During development work, however, you do want install -a
to rebuild everything, because anything might have changed.

Resolve the conflict by making the behavior of -a depend
on whether we are using a released copy of Go or a devel copy.
In the release copies, -a no longer applies to the standard library.
In the devel copies, it still does.

This is the latest in a long line of refinements to the
"do I build this or not" logic. It is surely not the last.

Fixes #8290.

LGTM=r
R=golang-codereviews, r, tracey.brendan
CC=adg, golang-codereviews, iant
https://golang.org/cl/151730045
2014-09-26 14:41:26 -04:00
Alex Brainman
0b8bc7cee9 cmd/go: handle paths like \x.go on windows
Fixes #8130.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/143200043
2014-09-26 14:36:49 -04:00
Russ Cox
df781cc4ab liblink: fix cmd/ld -X flag
This fixes the test/linkx.go test, which does not run by default.
(Issue 4139 is about fixing that.)

Fixes #8806.

LGTM=r
R=golang-codereviews, r
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/145420043
2014-09-26 13:50:53 -04:00
Russ Cox
6d760fb082 cmd/go: document that testdata directories are ignored
Also rebuild doc.go; was stale, so contains extra changes.

Fixes #8677.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/148170043
2014-09-26 13:50:39 -04:00
Russ Cox
ce143f25e6 cmd/go: add test -o flag to control where test binary is written
While we are here, remove undocumented, meaningless test -file flag.

Fixes #7724.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/149070043
2014-09-26 13:50:02 -04:00
Russ Cox
13a2c1ca78 cmd/go: display program name when reporting crash
Fix by atom (from CL 89190044), comment and test by me.

Fixes #6823.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=0xe2.0x9a.0x9b, adg, golang-codereviews, iant, r
https://golang.org/cl/148180043
2014-09-26 13:48:30 -04:00
Russ Cox
b86105e80d cmd/go: make malformed import path message more precise
If you say 'go get -v' you get extra information when import
paths are not of the expected form.

If you say 'go get -v src/rsc.io/pdf' the message says that
src/rsc.io/pdf does not contain a hostname, which is incorrect.
The problem is that it does not begin with a hostname.

Fixes #7432.

LGTM=r
R=golang-codereviews, r
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/144650043
2014-09-26 13:47:51 -04:00
Russ Cox
f3a98dee27 cmd/go: re-resolve and check vcs roots during go get -u
If you do 'go get -u rsc.io/pdf' and then rsc.io/pdf's redirect
changes to point somewhere else, after this CL a later
'go get -u rsc.io/pdf' will tell you that.

Fixes #8548.

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews, n13m3y3r, r
https://golang.org/cl/147170043
2014-09-26 12:10:13 -04:00
Russ Cox
7fa96f08a4 cmd/go: fix 'go get vanity/repo/...' in clean GOPATH
The pattern was only working if the checkout had
already been done, but the code was trying to make
it work even the first time. Test and fix.

Fixes #8335.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/146310043
2014-09-26 12:09:27 -04:00
Adam Langley
64df53ed7f crypto/tls: ensure that we don't resume when tickets are disabled.
LGTM=r
R=r, adg, rsc
https://golang.org/cl/148080043
2014-09-26 11:02:09 +10:00
Rob Pike
868948badf encoding/gob: fix 386 build
LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/146320043
2014-09-25 17:16:27 -07:00
Rob Pike
9c3fc838ba encoding/gob: error rather than panic when decoding enormous slices
Fixes #8084.

LGTM=ruiu
R=golang-codereviews, ruiu
CC=golang-codereviews
https://golang.org/cl/142710043
2014-09-25 15:18:25 -07:00
Russ Cox
dd84cf4ea0 cmd/go: install dependencies for 'go build -i' on a command
Fixes #8242.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant
https://golang.org/cl/147150043
2014-09-25 15:57:52 -04:00
Rob Pike
74c0de8fb6 bufio: fix handling of empty tokens at end of line/file
Fixes #8672.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/145390043
2014-09-25 12:45:21 -07:00
Rob Pike
cfae41ff36 time: make it clear that time.Time values do not compare with ==
LGTM=bradfitz, josharian, adg, rsc
R=golang-codereviews, bradfitz, josharian, rsc, adg
CC=golang-codereviews
https://golang.org/cl/141340043
2014-09-25 10:52:02 -07:00
Russ Cox
870f4e190c cmd/gc: emit error for out-of-bounds slice of constant string
Fixes #7200.

LGTM=gri, iant
R=golang-codereviews, gri, iant
CC=golang-codereviews, r
https://golang.org/cl/150020044
2014-09-25 13:24:43 -04:00
Russ Cox
52e9bcafe1 cmd/gc: print x++ (not x += 1) in errors about x++
Fixes #8311.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/146270043
2014-09-25 13:13:02 -04:00
Russ Cox
53c66543e0 cmd/gc: avoid infinite recursion on invalid recursive type
Fixes #8507.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/144560043
2014-09-25 13:08:37 -04:00
Keith Randall
1aa65fe8d4 runtime: add load_g call in arm callback.
Need to restore the g register.  Somehow this line vaporized from
CL 144130043.  Also cgo_topofstack -> _cgo_topofstack, that vaporized also.

TBR=rsc
CC=golang-codereviews
https://golang.org/cl/150940044
2014-09-25 08:37:04 -07:00
Keith Randall
1b6807bb06 cgo: adjust return value location to account for stack copies.
During a cgo call, the stack can be copied.  This copy invalidates
the pointer that cgo has into the return value area.  To fix this
problem, pass the address of the location containing the stack
top value (which is in the G struct).  For cgo functions which
return values, read the stktop before and after the cgo call to
compute the adjustment necessary to write the return value.

Fixes #8771

LGTM=iant, rsc
R=iant, rsc, khr
CC=golang-codereviews
https://golang.org/cl/144130043
2014-09-25 07:59:01 -07:00
Brad Fitzpatrick
dfaf1f71e6 net/http: update ProxyFromEnvironment docs for HTTPS_PROXY addition
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142650043
2014-09-24 17:39:00 -07:00
Nigel Tao
e59ad69a44 net/http: allow double-quotes only on cookie values, not cookie
attribute values, a la RFC 6265 section 4.1.1 "Syntax".

Fixes #7751.

LGTM=dr.volker.dobler
R=dr.volker.dobler
CC=bradfitz, golang-codereviews
https://golang.org/cl/148890043
2014-09-25 10:21:52 +10:00
Brad Fitzpatrick
446524269e net/http: check for CloseWrite interface, not TCPConn implementation
Fixes #8724

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/148040043
2014-09-24 17:01:54 -07:00
Brad Fitzpatrick
e6f21be3f4 net/http: support https_proxy in ProxyFromEnvironment
Fixes #6181

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/148980043
2014-09-24 16:55:39 -07:00
Russ Cox
6077f0fc32 cmd/go: fix bytes and net the right way
Not sure why they used empty.s and all these other
packages were special cased in cmd/go instead.
Add them to the list.

This avoids problems with net .s files being compiled
with gcc in cgo mode and gcc not supporting // comments
on ARM.

Not a problem with bytes, but be consistent.

The last change fixed the ARM build but broke the Windows build.
Maybe *this* will make everyone happy. Sigh.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/144530046
2014-09-24 19:18:01 -04:00
Russ Cox
d2b84dd941 net: only "build" empty.s in non-cgo mode
In cgo mode it gets passed to gcc, and on ARM
it appears that gcc does not support // comments.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142640043
2014-09-24 19:09:43 -04:00
Russ Cox
3c94b1d305 runtime: more NOPTR
Fixes linux builds (_vdso); may fix others.
I can at least cross-compile cmd/go for every
implemented system now.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142630043
2014-09-24 19:04:06 -04:00
Brad Fitzpatrick
665a416665 os: fix Args setup on Windows
Should fix the Windows build. Untested.

on Windows, args are made by src/os/exec_windows.go, not package runtime.
runtime·goargs has if(Windows) return;

The two init funcs in pkg os were conflicting, with the second
overwriting Args back to an empty slice.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/143540044
2014-09-24 18:50:54 -04:00
Russ Cox
75cca0526d runtime: more NOPTR
Fixes (or makes better) various builds.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/146280043
2014-09-24 17:50:44 -04:00
Dmitriy Vyukov
39cd39b023 cmd/go: strip -fsanitize= flags when building cgo object
Fixes #8788.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/142470043
2014-09-25 01:49:04 +04:00
Russ Cox
117a6973cb build: fix elf builds
Corrections due to new strict type rules for data+bss.
Also disable misc/cgo/cdefstest since you can't compile C code anymore.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/148050044
2014-09-24 14:45:11 -07:00
Rob Pike
54111a5893 fmt: document and fix the handling of precision for strings and byte slices
Previous behavior was undocumented and inconsistent. Now it is documented
and consistent and measures the input size, since that makes more sense
when talking about %q and %x. For %s the change has no effect.

Fixes #8151.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/144540044
2014-09-24 14:33:30 -07:00
Russ Cox
193daab988 cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
In linker, refuse to write conservative (array of pointers) as the
garbage collection type for any variable in the data/bss GC program.

In the linker, attach the Go type to an already-read C declaration
during dedup. This gives us Go types for C globals for free as long
as the cmd/dist-generated Go code contains the declaration.
(Most runtime C declarations have a corresponding Go declaration.
Both are bss declarations and so the linker dedups them.)

In cmd/dist, add a few more C files to the auto-Go-declaration list
in order to get Go type information for the C declarations into the linker.

In C compiler, mark all non-pointer-containing global declarations
and all string data as NOPTR. This allows them to exist in C files
without any corresponding Go declaration. Count C function pointers
as "non-pointer-containing", since we have no heap-allocated C functions.

In runtime, add NOPTR to the remaining pointer-containing declarations,
none of which refer to Go heap objects.

In runtime, also move os.Args and syscall.envs data into runtime-owned
variables. Otherwise, in programs that do not import os or syscall, the
runtime variables named os.Args and syscall.envs will be missing type
information.

I believe that this CL eliminates the final source of conservative GC scanning
in non-SWIG Go programs, and therefore...

Fixes #909.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/149770043
2014-09-24 16:55:26 -04:00
Russ Cox
5917692b98 debug/dwarf: correct name for clang-generated complex type
Fixes #8694.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/143570043
2014-09-24 16:53:47 -04:00
Russ Cox
43c4287b25 cmd/gc: fix import of package with var func returning _
Fixes #8280.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/146240043
2014-09-24 16:53:34 -04:00
Brad Fitzpatrick
fb4e185a99 src: pass GO_GCFLAGS down to go test std
Update #8725

LGTM=rsc, josharian
R=rsc, josharian
CC=golang-codereviews
https://golang.org/cl/149000043
2014-09-24 12:42:47 -07:00
Russ Cox
00d2f916ad cmd/gc: run escape analysis always (even in -N mode)
Fixes #8585.
Removes some little-used code paths.

LGTM=josharian
R=golang-codereviews, minux, josharian
CC=golang-codereviews, iant, r
https://golang.org/cl/132970043
2014-09-24 15:20:03 -04:00
Russ Cox
a0785a53ad cmd/go: prohibit C sources files unless using cgo
Those C files would have been compiled with 6c.
It's close to impossible to use C correctly anymore,
and the C compilers are going away eventually.
Make them unavailable now.

go1.4.txt change in CL 145890046

LGTM=iant
R=iant
CC=golang-codereviews, r
https://golang.org/cl/149720043
2014-09-24 15:10:38 -04:00
Russ Cox
6f219e8b84 runtime: fix LastGC comment
I have no idea what "absolute time" means.

LGTM=dvyukov, r
R=r, dvyukov
CC=golang-codereviews
https://golang.org/cl/144320043
2014-09-24 14:18:25 -04:00
Hector Martin Cantero
7283e08cbf runtime: keep g->syscallsp consistent after cgo->Go callbacks
Normally, the caller to runtime.entersyscall() must not return before
calling runtime.exitsyscall(), lest g->syscallsp become a dangling
pointer. runtime.cgocallbackg() violates this constraint. To work around
this, save g->syscallsp and g->syscallpc around cgo->Go callbacks, then
restore them after calling runtime.entersyscall(), which restores the
syscall stack frame pointer saved by cgocall. This allows the GC to
correctly trace a goroutine that is currently returning from a
Go->cgo->Go chain.

This also adds a check to proc.c that panics if g->syscallsp is clearly
invalid. It is not 100% foolproof, as it will not catch a case where the
stack was popped then pushed back beyond g->syscallsp, but it does catch
the present cgo issue and makes existing tests fail without the bugfix.

Fixes #7978.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, minux, bradfitz, iant, gobot, rsc
CC=golang-codereviews, rsc
https://golang.org/cl/131910043
2014-09-24 13:20:25 -04:00
Rob Pike
1193993c1d cmd/pack: fix c command for existing file
There were at least two bugs:
1) It would overwrite a non-archive.
2) It would truncate a non-archive and then fail.
In general the file handling was too clever to be correct.
Make it more straightforward, doing the creation
separately from archive management.

Fixes #8369.

LGTM=adg, iant
R=golang-codereviews, adg, iant
CC=golang-codereviews
https://golang.org/cl/147010046
2014-09-23 18:24:35 -07:00
Brad Fitzpatrick
db492b8df4 os: add a comment inside RemoveAll
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/149950043
2014-09-23 14:55:19 -07:00
Brad Fitzpatrick
82ddcc05f4 os: fix another case where RemoveAll should return nil
This hopefully fixes issue 8793.

Fixes #8793

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/150860046
2014-09-23 14:26:20 -07:00
Dave Cheney
c486d4130d runtime: fix runtime.Breakpoint on ARMv5
Fixes #8775.

Use the illegal instruction suggested by Ian in https://golang.org/cl/144180043/#msg4 on all arm arches.

LGTM=minux
R=golang-codereviews, gobot, rsc
CC=golang-codereviews, iant, minux
https://golang.org/cl/146130043
2014-09-23 15:34:38 +10:00
Dmitriy Vyukov
dcb594ec30 runtime: remove unused function declaration
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/145970043
2014-09-22 19:51:53 -07:00
Rob Pike
5d5e73b14a text/template: type-check chained node as argument
Was just a missing case (literally) in the type checker.

Fixes #8473.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/142460043
2014-09-22 17:48:13 -07:00
Rob Pike
892b5074f5 fmt: document that self-recursive data structures can be fatal
Fixes #8241.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/144420043
2014-09-22 15:35:25 -07:00
Rob Pike
78b5321e82 fmt: make printing of ints 25-35% faster
Inspired by a remark by Leonard Holz, use constants for division

BenchmarkSprintfEmpty           130           132           +1.54%
BenchmarkSprintfString          438           437           -0.23%
BenchmarkSprintfInt             417           414           -0.72%
BenchmarkSprintfIntInt          663           691           +4.22%
BenchmarkSprintfPrefixedInt     791           774           -2.15%
BenchmarkSprintfFloat           701           686           -2.14%
BenchmarkManyArgs               2584          2469          -4.45%
BenchmarkFprintInt              488           357           -26.84%
BenchmarkFprintIntNoAlloc       402           265           -34.08%
BenchmarkScanInts               1244346       1267574       +1.87%
BenchmarkScanRecursiveInt       1748741       1724138       -1.41%

Update #3463

LGTM=josharian, rsc
R=golang-codereviews, josharian, rsc
CC=golang-codereviews
https://golang.org/cl/144250043
2014-09-22 11:58:15 -07:00
Rob Pike
db56d4d5eb text/template: allow comparison functions to work between any integers
Previously, signed and unsigned integers could not be compared, but
this has problems with things like comparing 'x' with a byte in a string.
Since signed and unsigned integers have a well-defined ordering,
even though their types are different, and since we already allow
comparison regardless of the size of the integers, why not allow it
regardless of the sign?

Integers only, a fine place to draw the line.

Fixes #7489.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/149780043
2014-09-22 11:46:02 -07:00
Marko Tiikkaja
5f739d9dcd database/sql: Close per-tx prepared statements when the associated tx ends
LGTM=bradfitz
R=golang-codereviews, bradfitz, mattn.jp
CC=golang-codereviews
https://golang.org/cl/131650043
2014-09-22 09:19:27 -04:00
Brad Fitzpatrick
93e5cc224e net/http: replace z_last_test hack with testing.Main
LGTM=adg
R=rsc, adg
CC=golang-codereviews
https://golang.org/cl/144240043
2014-09-22 09:13:09 -04:00
Nigel Tao
0be3176a8b image/gif: don't let the per-frame transparent index modify the global
palette.

Fixes #7993.

LGTM=r
R=r
CC=golang-codereviews, james.jdunne
https://golang.org/cl/138600043
2014-09-22 14:29:45 +10:00
Keith Randall
3b2577ced3 runtime: be very careful with bad pointer tests
Saw this on a test:

runtime: bad pointer in frame runtime_test.testSetPanicOnFault at 0xc20801c6b0: 0xfff
fatal error: bad pointer!

runtime stack:
...
copystack(0xc2081bf7a0, 0x1000)
        /root/work/solaris-amd64-smartos-2dde8b453d26/go/src/runtime/stack.c:621 +0x173 fp=0xfffffd7ffd5ffee0 sp=0xfffffd7ffd5ffe20
runtime.newstack()
        /root/work/solaris-amd64-smartos-2dde8b453d26/go/src/runtime/stack.c:774 +0x552 fp=0xfffffd7ffd5fff90 sp=0xfffffd7ffd5ffee0
runtime.morestack()
        /root/work/solaris-amd64-smartos-2dde8b453d26/go/src/runtime/asm_amd64.s:324 +0x90 fp=0xfffffd7ffd5fff98 sp=0xfffffd7ffd5fff90

goroutine 163354 [stack growth]:
...
runtime.convT2E(0x587000, 0xc20807bea8, 0x0, 0x0)
        /root/work/solaris-amd64-smartos-2dde8b453d26/go/src/runtime/iface.go:141 +0xd2 fp=0xc20801c678 sp=0xc20801c640
runtime_test.testSetPanicOnFault(0xc20822c510, 0xfff, 0xc20801c748)
        /root/work/solaris-amd64-smartos-2dde8b453d26/go/src/runtime/runtime_test.go:211 +0xc6 fp=0xc20801c718 sp=0xc20801c678
...

This test is testing bad pointers.  It loads the bad pointer into a pointer variable,
but before it gets a chance to dereference it, calls convT2E.  That call causes a stack copy,
which exposes that live but bad pointer variable.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/146880043
2014-09-20 23:31:11 -07:00
Keith Randall
0306478fe5 runtime: Fix interaction between Goexit and defers
When running defers, we must check whether the defer
has already been marked as started so we don't run it twice.

Fixes #8774.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/142280044
2014-09-19 16:33:14 -07:00
Sameer Ajmani
0e1a07167b cmd/go: fix typo
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/138700043
2014-09-19 15:59:47 -04:00
Russ Cox
2c15d45131 net/http: document server recovering panics
Fixes #8594.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/145760043
2014-09-19 13:53:33 -04:00
Russ Cox
5c795632d6 runtime: add runtime· prefix to some static variables
Pure renaming. This will make an upcoming CL have smaller diffs.

LGTM=dvyukov, iant
R=iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/142280043
2014-09-19 13:51:23 -04:00
Russ Cox
182d1316dd cmd/go, testing: add TestMain support
Fixes #8202.

LGTM=r, bradfitz
R=r, josharian, bradfitz
CC=golang-codereviews
https://golang.org/cl/148770043
2014-09-19 13:51:06 -04:00
John Tuley
0c47bd1e61 net/http: ensured that proxy errors are returned by Transport.RoundTrip.
Fixes #8755.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, jtuley
https://golang.org/cl/136710044
2014-09-19 11:28:38 -04:00
Russ Cox
c7f6bd795a runtime: rename SchedType to SchedT
CL 144940043 renamed it from Sched to SchedType
to avoid a lowercasing conflict in the Go code with
the variable named sched.
We've been using just T resolve those conflicts, not Type.

The FooType pattern is already taken for the kind-specific
variants of the runtime Type structure: ChanType, MapType,
and so on. SchedType isn't a Type.

LGTM=bradfitz, khr
R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/145180043
2014-09-18 23:51:22 -04:00
Russ Cox
a07a57b00e syscall: mark ECONNRESET, ECONNABORTED as temporary network errors
Fixes #6163.

LGTM=adg
R=golang-codereviews, adg, dvyukov
CC=golang-codereviews
https://golang.org/cl/141600043
2014-09-18 23:07:36 -04:00
Russ Cox
88d53ddb17 runtime: release Windows thread handle in unminit
Fixes #8517.

LGTM=dvyukov, alex.brainman
R=golang-codereviews, dvyukov, alex.brainman
CC=golang-codereviews
https://golang.org/cl/145890044
2014-09-18 22:33:49 -04:00
Dave Cheney
66795e8ba1 runtime: fix GOARM<7 build
Update #8690

If liblink determines that the host doesn't support TLS it replaces the MRC call with a BL runtime.tls_read_fallback. The problem is save_g doesn't expect anyone to make any BL calls and hasn't setup its own link register properly so when runtime.tls_read_fallback returns the LR points to save_g, not save_g's caller so the RET at the end of the function turns into an infinite loop.

This fix is only a proof of concept, I think the real fix should go into liblink as its MRC substitution is not as transparent as expected.

LGTM=rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/143050043
2014-09-19 02:02:21 +00:00
Russ Cox
54b63f0647 path/filepath: document that Glob ignores i/o errors
Fixes #8008.

LGTM=adg
R=golang-codereviews, nightlyone, adg
CC=golang-codereviews
https://golang.org/cl/138630045
2014-09-18 21:50:22 -04:00
Russ Cox
5fdea3430a runtime: revise TestSetPanicOnFault
We can't assume all those addresses are unmapped.
But at least one should be.

What we're really testing is that the program doesn't crash.

Fixes #8542.

LGTM=iant
R=golang-codereviews, iant, minux
CC=golang-codereviews
https://golang.org/cl/144120043
2014-09-18 21:43:09 -04:00
Alex Brainman
2ed209eaf5 runtime: allow OutputDebugString to be sent to debugger
We mark DBG_PRINTEXCEPTION_C messages in VEH handler
as handled, thus preventing debugger from seeing them.
I don't see reason for doing that. The comment warns
of crashes, but I added test and don't see any crashes.

This is also simplify VEH handler before making
changes to fix issue 8006.

Update #8006

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/146800043
2014-09-19 11:38:48 +10:00
Russ Cox
dd8f29e3fe reflect: adjust Value.String to give correct answer for methods
Fixes #7859.

LGTM=r
R=adonovan, r
CC=golang-codereviews
https://golang.org/cl/136710043
2014-09-18 21:19:18 -04:00
David du Colombier
2debfeb936 os: handle 'has been removed' error as IsNotExist on Plan 9
It fixes the TestRemoveAllRace test introduced
in CL 145860043.

LGTM=bradfitz
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/147820044
2014-09-18 21:16:01 -04:00
Alex Brainman
f8474fa01d runtime: remove useless code around of EXCEPTION_BREAKPOINT
This is to simplify VEH handler before making
changes to fix issue 8006.

Update #8006

LGTM=adg, rsc
R=golang-codereviews, adg, rsc
CC=golang-codereviews
https://golang.org/cl/138630043
2014-09-19 11:14:51 +10:00
Russ Cox
048692e5de runtime: fix Windows SysUsed
Same fix as for SysUnused.
Fixes #8038.

LGTM=iant, alex.brainman
R=golang-codereviews, iant, alex.brainman
CC=golang-codereviews
https://golang.org/cl/147820043
2014-09-18 20:41:00 -04:00
Russ Cox
54245cba1f runtime: show frames for exported runtime functions
The current Windows build failure happens because by
default runtime frames are excluded from stack traces.
Apparently the Windows breakpoint path dies with an
ordinary panic, while the Unix path dies with a throw.
Breakpoint is a strange function and I don't mind that it's
a little different on the two operating systems.

The panic squelches runtime frames but the throw shows them,
because throw is considered something that shouldn't have
happened at all, so as much detail as possible is wanted.

The runtime exclusion is meant to prevents printing too much noise
about internal runtime details. But exported functions are
not internal details, so show exported functions.
If the program dies because you called runtime.Breakpoint,
it's okay to see that frame.
This makes the Breakpoint test show Breakpoint in the
stack trace no matter how it is handled.

Should fix Windows build.
Tested on Unix by changing Breakpoint to fault instead
of doing a breakpoint.

TBR=brainman
CC=golang-codereviews
https://golang.org/cl/143300043
2014-09-18 20:35:36 -04:00
Ian Lance Taylor
5a40b568d0 lib9, cmd/ld: fixes for cross-linking on a Windows host
This fixes a couple of problems that occur when the linker
removes its temporary directory on Windows.  The linker only
creates and removes a temporary directory when doing external
linking.  Windows does not yet support external linking.
Therefore, these problems are only seen when using a
cross-compiler hosted on Windows.

In lib9, FindFirstFileW returns just the file name, not the
full path name.  Don't assume that we will find a slash.
Changed the code to work either way just in case.

In ld, Windows requires that files be closed before they are
removed, so close the output file before we might try to
remove it.

Fixes #8723.

LGTM=alex.brainman
R=golang-codereviews, alex.brainman
CC=golang-codereviews
https://golang.org/cl/141690043
2014-09-18 17:27:26 -07:00
Russ Cox
84f9c42bbb os: skip TestRemoveAllRace on Windows
It's just fundamentally incompatible with
Windows' pickiness about removing things
that are in use.

TBR=brainman
CC=golang-codereviews
https://golang.org/cl/142270043
2014-09-18 20:13:07 -04:00
Robert Griesemer
e4fa1e4035 go/doc: document rationale for recent change
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/143290043
2014-09-18 16:53:35 -07:00
Russ Cox
e9ec8e7a26 bytes, strings: document that FieldsFunc f must not be stateful
Fixes #8738.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143260045
2014-09-18 19:40:31 -04:00
Russ Cox
ab76638cdc syscall: fix infinite recursion in itoa
Fixes #8332.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/138650044
2014-09-18 19:40:06 -04:00
Josh Bleecher Snyder
2b59c9d352 go/doc: treat _ consts as exported
Fixes #5397.

LGTM=adg
R=gri, adg
CC=golang-codereviews, rsc
https://golang.org/cl/144110044
2014-09-18 15:43:06 -07:00
David du Colombier
45143aeca4 runtime: fix handling of GOTRACEBACK
Since CL 130990043, the GOTRACEBACK variable is
only used when the GODEBUG variable is set.
This change restores the original behavior.

LGTM=rsc
R=golang-codereviews, aram, gobot, r, rsc
CC=golang-codereviews
https://golang.org/cl/132520043
2014-09-18 23:25:11 +02:00
Russ Cox
c3b5db895b runtime: delete panicstring; move its checks into gopanic
In Go 1.3 the runtime called panicstring to report errors like
divide by zero or memory faults. Now we call panic (gopanic)
with pre-allocated error values. That new path is missing the
checking that panicstring did, so add it there.

The only call to panicstring left is in cnew, which is problematic
because if it fails, probably the heap is corrupt. In that case,
calling panicstring creates a new errorCString (no allocation there),
but then panic tries to print it, invoking errorCString.Error, which
does a string concatenation (allocating), which then dies.
Replace that one panicstring with a throw: cnew is for allocating
runtime data structures and should never ask for an inappropriate
amount of memory.

With panicstring gone, delete newErrorCString, errorCString.
While we're here, delete newErrorString, not called by anyone.
(It can't be: that would be C code calling Go code that might
block or grow the stack.)

Found while debugging a malloc corruption.
This resulted in 'panic during panic' instead of a more useful message.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/138290045
2014-09-18 14:49:24 -04:00
Russ Cox
98a5f52ef0 os: avoid error result when dir is removed out from under RemoveAll
Fixes #7776.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews, r
https://golang.org/cl/145860043
2014-09-18 14:48:47 -04:00
Russ Cox
76c7548162 net: disable TestDialMultiFDLeak
It fails about 25% of the time on OS X.
I don't know what it's trying to do.
Created issue 8764 to correct this, but for now disable.

LGTM=bradfitz, mikioh.mikioh
R=bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/144070044
2014-09-18 14:48:26 -04:00
Dmitriy Vyukov
dfd4123edc encoding/gob: speedup encoding
Replace typeLock with copy-on-write map using atomic.Value.

benchmark                               old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                   7722          7709          -0.17%
BenchmarkEndToEndPipe-2                 5114          4344          -15.06%
BenchmarkEndToEndPipe-4                 3192          2429          -23.90%
BenchmarkEndToEndPipe-8                 1833          1438          -21.55%
BenchmarkEndToEndPipe-16                1332          983           -26.20%
BenchmarkEndToEndPipe-32                1444          675           -53.25%
BenchmarkEndToEndByteBuffer             6474          6019          -7.03%
BenchmarkEndToEndByteBuffer-2           4280          2810          -34.35%
BenchmarkEndToEndByteBuffer-4           2264          1774          -21.64%
BenchmarkEndToEndByteBuffer-8           1275          979           -23.22%
BenchmarkEndToEndByteBuffer-16          1257          753           -40.10%
BenchmarkEndToEndByteBuffer-32          1342          644           -52.01%
BenchmarkEndToEndArrayByteBuffer        727725        671349        -7.75%
BenchmarkEndToEndArrayByteBuffer-2      394079        320473        -18.68%
BenchmarkEndToEndArrayByteBuffer-4      211785        178175        -15.87%
BenchmarkEndToEndArrayByteBuffer-8      141003        118857        -15.71%
BenchmarkEndToEndArrayByteBuffer-16     139249        86367         -37.98%
BenchmarkEndToEndArrayByteBuffer-32     144128        73454         -49.04%

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/147720043
2014-09-18 10:13:15 -07:00
Josh Bleecher Snyder
73a82db1c8 fmt: fix allocation tests
Converting an integer to an interface{} allocates as of CL 130240043.

Fixes #8617.

LGTM=r
R=r
CC=golang-codereviews, khr
https://golang.org/cl/141700043
2014-09-18 09:45:58 -07:00
Mikio Hara
484cc67151 net: separate NaCl dependent placeholders from BSD's
To clarify the dependency of NaCl platform.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143830044
2014-09-18 19:17:55 +09:00
Dmitriy Vyukov
8c2484ec11 sync/atomic: remove unnecessary race instrumentation in Value
It is left from the time when Value was implemented in assembly.
Now it is implemented in Go and race detector understands Go.
In particular the atomic operations must provide
all necessary synchronization.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews, khr, rsc
https://golang.org/cl/145880043
2014-09-17 21:22:11 -07:00
Dmitriy Vyukov
ed7db89b90 runtime: output number of goroutines in GC trace
Example output:
gc26(1): 1+0+1038+0 us, 0 -> 1 MB, 19074 (88777-69703) objects, 5 gs, 184/0/0 sweeps, 0(0) handoff, 0(0) steal, 0/0/0 yields
It's useful to understand long scan times,
because goroutine traceback is slow.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/136310044
2014-09-17 20:38:50 -07:00
Nigel Tao
a2910958a2 image/gif: fix GIF encoding of sub-images.
benchmark                    old ns/op     new ns/op     delta
BenchmarkEncode              8641055       8646829       +0.07%

Fixes #7792.

LGTM=r
R=r
CC=dbathgate, golang-codereviews
https://golang.org/cl/147730043
2014-09-18 12:43:01 +10:00
Keith Randall
92eb1e1600 runtime: free stacks of Gdead goroutines at GC time
We could probably free the G structures as well, but
for the allg list.  Leaving that for another day.

Fixes #8287

LGTM=rsc
R=golang-codereviews, dvyukov, khr, rsc
CC=golang-codereviews
https://golang.org/cl/145010043
2014-09-17 13:25:46 -07:00
Russ Cox
6fb9d50d15 runtime: print more detail in adjustframe crash
The logic here is copied from mgc0.c's scanframe.
Mostly it is messages although the minsize code is new
(and I believe necessary).

I am hoping to get more information about the current
arm build failures (or, if it's the minsize thing, fix them).

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143180043
2014-09-17 16:12:17 -04:00
Russ Cox
735289ff76 sync/atomic: add more missing Go prototype
Should fix nacl/arm build.

TBR=minux
CC=golang-codereviews
https://golang.org/cl/145070043
2014-09-17 15:30:48 -04:00
Russ Cox
e19d8a47d1 runtime: account for tiny allocs, for testing.AllocsPerRun
Fixes #8734.

LGTM=r, bradfitz, dvyukov
R=bradfitz, r, dvyukov
CC=golang-codereviews, iant, khr
https://golang.org/cl/143150043
2014-09-17 14:49:32 -04:00
Keith Randall
6c934238c9 runtime: change minimum stack size to 2K.
It will be 8K on windows because it needs 4K for the OS.
Similarly, plan9 will be 4K.

On linux/amd64, reduces size of 100,000 goroutines
from ~819MB to ~245MB.

Update #7514

LGTM=dvyukov
R=golang-codereviews, dvyukov, khr, aram
CC=golang-codereviews
https://golang.org/cl/145790043
2014-09-17 08:32:15 -07:00
Dave Cheney
72a2539c38 sync: fix linux/arm build
For real this time.

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/141640043
2014-09-17 05:44:42 +00:00
Dmitriy Vyukov
98a1e207e2 sync/atomic: add Value
A Value provides an atomic load and store of a consistently typed value.
It's intended to be used with copy-on-write idiom (see the example).

Performance:
BenchmarkValueRead	50000000	        21.7 ns/op
BenchmarkValueRead-2	200000000	         8.63 ns/op
BenchmarkValueRead-4	300000000	         4.33 ns/op

TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/136710045
2014-09-16 19:54:26 -07:00
Russ Cox
cbf97d9103 liblink, sync/atomic: fix arm build
The liblink code to insert the FUNCDATA for a stack map
from the Go prototype was not correct for ARM
(different data structure layout).

Also, sync/atomic was missing some Go prototypes
for ARM-specific functions.

TBR=r
CC=golang-codereviews
https://golang.org/cl/143160045
2014-09-16 20:53:38 -04:00
Keith Randall
da8cf5438a runtime: always run semacquire on the G stack
semacquire might need to park the currently running G.  It can
only park if called from the G stack (because it has no way of
saving the M stack state).  So all calls to semacquire must come
from the G stack.

The three violators are GOMAXPROCS, ReadMemStats, and WriteHeapDump.
This change moves the semacquire call earlier, out of their C code
and into their Go code.

This seldom caused bugs because semacquire seldom actually had
to park the caller.  But it did happen intermittently.

Fixes #8749

LGTM=dvyukov
R=golang-codereviews, dvyukov, bradfitz
CC=golang-codereviews
https://golang.org/cl/144940043
2014-09-16 17:26:16 -07:00
Ahmed Waheed Moanes
4caf377e6e cmd/go: use pkg-config include pathes in swig and don't double compile c++ files.
Fixes #8566.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/126210045
2014-09-16 15:06:52 -07:00
Russ Cox
4bf4d9f86e runtime: reenable TestStackGrowth on 32-bit systems
If this needs to be turned back off, it should be done
just before the '// in finalizer' comment, not at the top
of the function.

GC is more precise now than it was (the only imprecise
stuff left is some global variables), so maybe the finalizer
test will work now on 32-bit systems.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144030043
2014-09-16 17:46:25 -04:00
Russ Cox
06e4b06893 net/mail: allow us-ascii encoding
Fixes #6611.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/14990045
2014-09-16 17:40:33 -04:00
Russ Cox
a325f4f2b3 reflect: add Type.Comparable
Like most of the Type methods, the definition of Comparable
is what the Go spec says it is.

Fixes #7911.

LGTM=gri
R=gri, r
CC=golang-codereviews
https://golang.org/cl/144020043
2014-09-16 17:40:10 -04:00
Russ Cox
653fb6d872 liblink: make GO_ARGS the default for functions beginning with ·
If there is a leading ·, assume there is a Go prototype and
attach the Go prototype information to the function.
If the function is not called from Go and does not need a
Go prototype, it can be made file-local instead (using name<>(SB)).

This fixes the current BSD build failures, by giving functions like
sync/atomic.StoreUint32 argument stack map information.

Fixes #8753.

LGTM=khr, iant
R=golang-codereviews, iant, khr, bradfitz
CC=golang-codereviews, r, rlh
https://golang.org/cl/142150043
2014-09-16 17:39:55 -04:00
Josh Bleecher Snyder
f1abe0d06b sync: simplify TestOncePanic
Follow-up to CL 137350043.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/141620043
2014-09-16 14:22:33 -07:00
Rob Pike
b22dc6385d sync/once: panicking functions still marked as complete
This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes #8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043
2014-09-16 14:00:01 -07:00
Keith Randall
15274e5c9b runtime: make it clear that Goexit cannot be recover'd.
LGTM=r
R=r, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/136660044
2014-09-16 12:50:05 -07:00
Russ Cox
c1e332020d os/signal: increase timeout from 10ms to 100ms
Might make test less flaky.
Fixes #8682.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/143160043
2014-09-16 15:26:00 -04:00
Russ Cox
95c899f03c net: make TestSelfConnect less fragile
We believe TestSelfConnect can accidentally connect to
something else listening on or dialing from that port.

Fixes #8680.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rlh
https://golang.org/cl/136700043
2014-09-16 14:02:59 -04:00
Russ Cox
c1c5d479bd cmd/5g, cmd/8g: make 'out of registers' a fatal error
There's no point in continuing. We will only get confused.
6g already makes this fatal.

LGTM=dave, minux, iant
R=iant, dave, minux
CC=golang-codereviews
https://golang.org/cl/140660043
2014-09-16 13:16:43 -04:00
Russ Cox
99e8f40488 runtime: fix 386 build
mark finalizer1 as having no pointers

TBR=iant
CC=golang-codereviews
https://golang.org/cl/141570045
2014-09-16 11:43:35 -04:00
Russ Cox
d208361cde runtime: remove uses of ScanConservatively
Along with CLs 139610043 and 141490043,
this removes all conservative scanning during
garbage collection, except _cgo_allocate,
which is SWIG-only.

LGTM=rlh, khr
R=golang-codereviews, dvyukov, rlh, khr
CC=golang-codereviews, iant
https://golang.org/cl/144860043
2014-09-16 11:09:58 -04:00
Russ Cox
fc46931442 runtime: remove untyped allocation of ParFor
Now it's two allocations. I don't see much downside to that,
since the two pieces were in different cache lines anyway.

Rename 'conservative' to 'cgo_conservative_type' and make
clear that _cgo_allocate is the only allowed user.

This depends on CL 141490043, which removes the other
use of conservative (in defer).

LGTM=dvyukov, iant
R=khr, dvyukov, iant
CC=golang-codereviews, rlh
https://golang.org/cl/139610043
2014-09-16 11:03:11 -04:00
Russ Cox
f95beae61d runtime: use traceback to traverse defer structures
This makes the GC and the stack copying agree about how
to interpret the defer structures. Previously, only the stack
copying treated them precisely.
This removes an untyped memory allocation and fixes
at least three copystack bugs.

To make sure the GC can find the deferred argument
frame until it has been copied, keep a Defer on the defer list
during its execution.

In addition to making it possible to remove the untyped
memory allocation, keeping the Defer on the list fixes
two races between copystack and execution of defers
(in both gopanic and Goexit). The problem is that once
the defer has been taken off the list, a stack copy that
happens before the deferred arguments have been copied
back to the stack will not update the arguments correctly.
The new tests TestDeferPtrsPanic and TestDeferPtrsGoexit
(variations on the existing TestDeferPtrs) pass now but
failed before this CL.

In addition to those fixes, keeping the Defer on the list
helps correct a dangling pointer error during copystack.
The traceback routines walk the Defer chain to provide
information about where a panic may resume execution.
When the executing Defer was not on the Defer chain
but instead linked from the Panic chain, the traceback
had to walk the Panic chain too. But Panic structs are
on the stack and being updated by copystack.
Traceback's use of the Panic chain while copystack is
updating those structs means that it can follow an
updated pointer and find itself reading from the new stack.
The new stack is usually all zeros, so it sees an incorrect
early end to the chain. The new TestPanicUseStack makes
this happen at tip and dies when adjustdefers finds an
unexpected argp. The new StackCopyPoison mode
causes an earlier bad dereference instead.
By keeping the Defer on the list, traceback can avoid
walking the Panic chain at all,  making it okay for copystack
to update the Panics.

We'd have the same problem for any Defers on the stack.
There was only one: gopanic's dabort. Since we are not
taking the executing Defer off the chain, we can use it
to do what dabort was doing, and then there are no
Defers on the stack ever, so it is okay for traceback to use
the Defer chain even while copystack is executing:
copystack cannot modify the Defer chain.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, rlh
https://golang.org/cl/141490043
2014-09-16 10:36:38 -04:00
Russ Cox
d2574e2adb runtime: remove duplicated Go constants
The C header files are the single point of truth:
every C enum constant Foo is available to Go as _Foo.
Remove or redirect duplicate Go declarations so they
cannot be out of sync.

Eventually we will need to put constants in Go, but for now having
them be out of sync with C is too risky. These predate the build
support for auto-generating Go constants from the C definitions.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/141510043
2014-09-16 10:22:15 -04:00
Russ Cox
8d61334dd5 cmd/gc: say 'non-constant array bound' instead of 'invalid array bound'
Fixes #8196.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/141510044
2014-09-16 10:21:54 -04:00
Russ Cox
3d2321f639 io: clarify Reader returning 0, nil
Fixes #8317.

LGTM=bradfitz
R=bradfitz, iant, r
CC=golang-codereviews
https://golang.org/cl/143100043
2014-09-16 10:01:28 -04:00
Russ Cox
337fe4134f cmd/gc: make runtime escape an error, not a fatal error
It is more useful to report all the errors instead of just the first.

LGTM=dave, khr
R=khr, dave
CC=golang-codereviews
https://golang.org/cl/143940043
2014-09-16 09:58:17 -04:00
Josh Bleecher Snyder
c3dbf56a14 cmd/ld: document that -X overwrites initialized variables
Fixes #7626.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144870045
2014-09-15 18:16:45 -07:00
Robert Griesemer
2bb0a5e085 cmd/api: internal debugging supprt
Document that the package cache has
an issue (8425) to speed up future
debugging.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/143980043
2014-09-15 16:40:43 -07:00
Keith Randall
7e62316b84 runtime: test Goexit/defer iteraction.
Make sure Goexit runs defers.
Make sure recover() during a Goexit defer returns nil.

LGTM=dvyukov, bradfitz
R=golang-codereviews, dvyukov, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/140650043
2014-09-15 15:09:17 -07:00
Keith Randall
1e4f86e485 runtime: try harder to get different iteration orders.
Fixes #8736.

LGTM=iant, josharian
R=golang-codereviews, iant, josharian
CC=golang-codereviews
https://golang.org/cl/144910044
2014-09-15 12:30:57 -07:00
Rémy Oudompheng
e024ed5ca4 cmd/gc: don't walk static nodes generated by anylit.
During anylit run, nodes such as SLICEARR(statictmp, [:])
may be generated and are expected to be found unchanged by
gen_as_init.

In some walks (in particular walkselect), the statement
may be walked again and lowered to its usual form, leading to a
crash.

Fixes #8017.
Fixes #8024.
Fixes #8058.

LGTM=rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/112080043
2014-09-15 18:31:47 +02:00
Rémy Oudompheng
8d47b08255 cmd/gc: generate type alg after calling dowidth.
Previously it might happen before calling dowidth and
result in a compiler crash.

Fixes #8060.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/110980044
2014-09-15 18:24:16 +02:00
Brad Fitzpatrick
bb431245cc net/http: don't call FileSystem.Open with unclean index.html path
Fixes #8722

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142090043
2014-09-15 07:14:33 -04:00
Alex Brainman
5d5312c5dd runtime: fix parameter checking in syscall.NewCallback
I have made mistake while converting it to Go (CL 132820043).
Added test as penance for my sin.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/136560043
2014-09-15 12:58:28 +10:00
Russ Cox
3b4bccc820 syscall: add GO_ARGS to Go-called assembly
Fixes sporadic linux/386 build failure (untyped args)
and probably some others we haven't observed yet.

Fixes #8727.

TBR=iant
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, khr, r
https://golang.org/cl/143930043
2014-09-14 22:27:03 -04:00
Russ Cox
e8a74dcad9 runtime: fix solaris build, part 2
This file was already assigned to another CL
so it didn't make it into the build fix CL. Sigh.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/144850043
2014-09-14 22:24:29 -04:00
Russ Cox
6c59cdcf34 runtime: fix solaris build
CL 144830043 changed LibCall for Windows.
I didn't realize Solaris used it too.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142100043
2014-09-14 22:20:01 -04:00
Russ Cox
2eccf0d18f runtime: convert syscall_windows.c to Go
This is necessary because syscall.Syscall blocks, and the
garbage collector needs to be able to scan that frame while
it is blocked, and C frames have no garbage collection
information.

Windows builders are broken now due to this problem:
http://build.golang.org/log/152ca9a4be6783d3a8bf6e2f5b9fc265089728b6

LGTM=alex.brainman
R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/144830043
2014-09-14 21:25:44 -04:00
Nigel Tao
8e77a7ef6b image/jpeg: reject invalid Ta and Td values.
Fixes #8693.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/141470043
2014-09-15 08:41:59 +10:00
Russ Cox
d889f5f01e runtime: fix traceback of trap on ARM
The merged traceback was wrong for LR machines,
because traceback didn't pass lr to gentraceback.
Now that we have a test looking at traceback output
for a trap (the test of runtime.Breakpoint),
we caught this.

While we're here, fix a 'set and not used' warning.

Fixes arm build.

TBR=r
R=r
CC=golang-codereviews
https://golang.org/cl/143040043
2014-09-14 20:39:08 +00:00
Russ Cox
40dd6bf38e runtime: mark asmcgocall<>(SB) as having no arguments
It doesn't.
Fixes 386 build.

While we're here, mark runtime.asmcgocall as GO_ARGS,
so that it will work with stack copying. I don't think anything
that uses it can lead to a stack copy, but better safe than sorry.
Certainly the runtime.asmcgocall_errno variant needs
(and already has) GO_ARGS.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/138400043
2014-09-14 13:57:28 -04:00
Robert Griesemer
e3d2e5550e cmd/8g: remove unused variable (fix build)
http://build.golang.org/log/0434a945e3351eedaf56aa824d2bfe9c0d5e6735

LGTM=dave
R=bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/144800043
2014-09-12 16:35:40 -07:00
Josh Bleecher Snyder
d6cd230c98 runtime: test iteration order of sparse maps
The behavior was fixed in CL 141270043. Add a test.

Fixes #8410.

LGTM=khr
R=khr, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/137560044
2014-09-12 16:16:09 -07:00
Dmitriy Vyukov
d78823168f cmd/gc: fix racewalk after writebarrier change
Instrument dst argument of writebarrier calls.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/139560045
2014-09-12 15:05:41 -07:00
Russ Cox
44753479c6 runtime: remove a few untyped allocations
LGTM=iant, khr, rlh
R=khr, iant, bradfitz, rlh
CC=dvyukov, golang-codereviews
https://golang.org/cl/142030044
2014-09-12 16:12:39 -04:00
Robert Griesemer
a14c1c986e go/printer: don't reduce nesting depth twice if parentheses are present around an expr
No impact on formatting on our repos.

Fixes #8021.

LGTM=adonovan
R=adonovan, dvyukov
CC=golang-codereviews
https://golang.org/cl/142020043
2014-09-12 11:18:12 -07:00
Ian Lance Taylor
fbd1b5f98f runtime: fix typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/140590043
2014-09-12 07:52:56 -07:00
Russ Cox
68c1c6afa0 cmd/cc, cmd/gc: stop generating 'argsize' PCDATA
The argsize PCDATA was specifying the number of
bytes passed to a function call, so that if the function
did not specify its argument count, the garbage collector
could use the call site information to scan those bytes
conservatively. We don't do that anymore, so stop
generating the information.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/139530043
2014-09-12 07:51:00 -04:00
Russ Cox
e844f53a01 runtime: stop scanning stack frames/args conservatively
The goal here is to commit fully to having precise information
about stack frames. If we need information we don't have,
crash instead of assuming we should scan conservatively.

Since the stack copying assumes fully precise information,
any crashes during garbage collection that are introduced by
this CL are crashes that could have happened during stack
copying instead. Those are harder to find because stacks are
copied much less often than the garbage collector is invoked.

In service of that goal, remove ARGSIZE macros from
asm_*.s, change switchtoM to have no arguments
(it doesn't have any live arguments), and add
args and locals information to some frames that
can call back into Go.

LGTM=khr
R=khr, rlh
CC=golang-codereviews
https://golang.org/cl/137540043
2014-09-12 07:46:11 -04:00
Russ Cox
a7c6d89166 runtime: tell the truth about BitVector type
Dmitriy changed all the execution to interpret the BitVector
as an array of bytes. Update the declaration and generation
of the bitmaps to match, to avoid problems on big-endian
machines.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews
https://golang.org/cl/140570044
2014-09-12 07:36:23 -04:00
Russ Cox
f0d44dbeaf runtime: look up arg stackmap for makeFuncStub/methodValueStub during traceback
makeFuncStub and methodValueStub are used by reflect as
generic function implementations. Each call might have
different arguments. Extract those arguments from the
closure data instead of assuming it is the same each time.

Because the argument map is now being extracted from the
function itself, we don't need the special cases in reflect.Call
anymore, so delete those.

Fixes an occasional crash seen when stack copying does
not update makeFuncStub's arguments correctly.

Will also help make it safe to require stack maps in the
garbage collector.

Derived from CL 142000044 by khr.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143890044
2014-09-12 07:29:19 -04:00
Anthony Martin
70f928698b runtime: save correct pid for new m's on plan9/amd64
The pid field in the Tos structure is a 32-bit value.
Loading a 64-bit word also brings in the next field
which is used for the profiling clock.

LGTM=0intro, aram
R=rsc, 0intro, aram
CC=golang-codereviews, mischief
https://golang.org/cl/139560044
2014-09-12 01:21:51 -07:00
Russ Cox
860a645927 syscall: add #include "funcdata.h" to files modified in last CL
That's what defines GO_ARGS.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/141460043
2014-09-12 00:55:24 -04:00
Russ Cox
4179439de8 syscall: make func Syscall use pointer maps from Go prototypes
Before, Syscall and friends were having their arguments
treated conservatively. Now they will use the Go prototype,
which will mean the arguments are not considered pointers
at all.

This is safe because of CL 139360044.

The fact that all these non-Solaris systems were using
conservative scanning of the Syscall arguments is why
the failure that prompted CL 139360044 was only
observed on Solaris, which does something completely different.
If we'd done this earlier, we'd have seen the Solaris
failure in more places.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144730043
2014-09-12 00:23:03 -04:00
Russ Cox
99f7df0598 cmd/gc: turn Go prototypes into ptr liveness maps for assembly functions
The goal here is to allow assembly functions to appear in the middle
of a Go stack (having called other code) and still record enough information
about their pointers so that stack copying and garbage collection can handle
them precisely. Today, these frames are handled only conservatively.

If you write

        func myfunc(x *float64) (y *int)

(with no body, an 'extern' declaration), then the Go compiler now emits
a liveness bitmap for use from the assembly definition of myfunc.
The bitmap symbol is myfunc.args_stackmap and it contains two bitmaps.
The first bitmap, in effect at function entry, marks all inputs as live.
The second bitmap, not in effect at function entry, marks the outputs
live as well.

In funcdata.h, define new assembly macros:

GO_ARGS opts in to using the Go compiler-generated liveness bitmap
for the current function.

GO_RESULTS_INITIALIZED indicates that the results have been initialized
and need to be kept live for the remainder of the function; it causes a
switch to the second generated bitmap for the assembly code that follows.

NO_LOCAL_POINTERS indicates that there are no pointers in the
local variables being stored in the function's stack frame.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/137520043
2014-09-12 00:18:20 -04:00
Keith Randall
47f251c1ce runtime: fix cgo to handle the case where the G stack is copied.
Tests will come in a separate CL after the funcdata stuff is resolved.

Update #8696

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/138330045
2014-09-11 20:36:23 -07:00
Michael MacInnis
aa168ed2cd syscall: SysProcAttr job control changes
Making the child's process group the foreground process group and
placing the child in a specific process group involves co-ordination
between the parent and child that must be done post-fork but pre-exec.

LGTM=iant
R=golang-codereviews, gobot, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/131750044
2014-09-11 18:39:51 -07:00
Keith Randall
bcd36e8857 runtime: make gostringnocopy update maxstring
Fixes #8706

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/143880043
2014-09-11 16:53:34 -07:00
Keith Randall
00365b13b4 runtime: get rid of copyable check - all G frames are copyable.
Just go ahead and do it, if something is wrong we'll throw.

Also rip out cc-generated arg ptr maps, they are useless now.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/133690045
2014-09-11 13:46:58 -07:00
Russ Cox
91baf5c65d runtime: make Gosched nosplit
Replacing gosched with Gosched broke some builds because
some of the call sites are at times when the stack cannot be grown.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/142000043
2014-09-11 16:33:01 -04:00
Russ Cox
15a5c35cec runtime: move gosched to Go, to add stack frame information
LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/134520044
2014-09-11 16:22:21 -04:00
Robert Griesemer
724fa12f91 go/printer, gofmt: don't align map entries for irregular inputs
Details: Until now, when we saw a key:value pair that fit onto
a single line, we assumed that it should be formatted with a
vtab after the ':' for alignment of its value. This leads to
odd behavior if there are more than one such pair on a line.
This CL changes the behavior such that alignment is only used
for the first pair on a line. This preserves existing behavior
(in the std lib we have composite literals where the last line
contains multiple entries and the first entry's value is aligned
with the values on previous lines), and resolves this issue.

No impact on formatting of std lib, go.tools, go.exp, go.net.

Fixes #8685.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/139430043
2014-09-11 12:57:51 -07:00
Russ Cox
fcb4cabba4 cmd/gc: emit write barriers
A write *p = x that needs a write barrier (not all do)
now turns into runtime.writebarrierptr(p, x)
or one of the other variants.

The write barrier implementations are trivial.
The goal here is to emit the calls in the correct places
and to incur the cost of those function calls in the Go 1.4 cycle.

Performance on the Go 1 benchmark suite below.
Remember, the goal is to slow things down (and be correct).

We will look into optimizations in separate CLs, as part of
the process of comparing Go 1.3 against tip in order to make
sure Go 1.4 runs at least as fast as Go 1.3.

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              3118336716     3452876110     +10.73%
BenchmarkFannkuch11                3184497677     3211552284     +0.85%
BenchmarkFmtFprintfEmpty           89.9           107            +19.02%
BenchmarkFmtFprintfString          236            287            +21.61%
BenchmarkFmtFprintfInt             246            278            +13.01%
BenchmarkFmtFprintfIntInt          395            458            +15.95%
BenchmarkFmtFprintfPrefixedInt     343            378            +10.20%
BenchmarkFmtFprintfFloat           477            525            +10.06%
BenchmarkFmtManyArgs               1446           1707           +18.05%
BenchmarkGobDecode                 14398047       14685958       +2.00%
BenchmarkGobEncode                 12557718       12947104       +3.10%
BenchmarkGzip                      453462345      472413285      +4.18%
BenchmarkGunzip                    114226016      115127398      +0.79%
BenchmarkHTTPClientServer          114689         112122         -2.24%
BenchmarkJSONEncode                24914536       26135942       +4.90%
BenchmarkJSONDecode                86832877       103620289      +19.33%
BenchmarkMandelbrot200             4833452        4898780        +1.35%
BenchmarkGoParse                   4317976        4835474        +11.98%
BenchmarkRegexpMatchEasy0_32       150            166            +10.67%
BenchmarkRegexpMatchEasy0_1K       393            402            +2.29%
BenchmarkRegexpMatchEasy1_32       125            142            +13.60%
BenchmarkRegexpMatchEasy1_1K       1010           1236           +22.38%
BenchmarkRegexpMatchMedium_32      232            301            +29.74%
BenchmarkRegexpMatchMedium_1K      76963          102721         +33.47%
BenchmarkRegexpMatchHard_32        3833           5463           +42.53%
BenchmarkRegexpMatchHard_1K        119668         161614         +35.05%
BenchmarkRevcomp                   763449047      706768534      -7.42%
BenchmarkTemplate                  124954724      134834549      +7.91%
BenchmarkTimeParse                 517            511            -1.16%
BenchmarkTimeFormat                501            514            +2.59%

benchmark                         old MB/s     new MB/s     speedup
BenchmarkGobDecode                53.31        52.26        0.98x
BenchmarkGobEncode                61.12        59.28        0.97x
BenchmarkGzip                     42.79        41.08        0.96x
BenchmarkGunzip                   169.88       168.55       0.99x
BenchmarkJSONEncode               77.89        74.25        0.95x
BenchmarkJSONDecode               22.35        18.73        0.84x
BenchmarkGoParse                  13.41        11.98        0.89x
BenchmarkRegexpMatchEasy0_32      213.30       191.72       0.90x
BenchmarkRegexpMatchEasy0_1K      2603.92      2542.74      0.98x
BenchmarkRegexpMatchEasy1_32      254.00       224.93       0.89x
BenchmarkRegexpMatchEasy1_1K      1013.53      827.98       0.82x
BenchmarkRegexpMatchMedium_32     4.30         3.31         0.77x
BenchmarkRegexpMatchMedium_1K     13.30        9.97         0.75x
BenchmarkRegexpMatchHard_32       8.35         5.86         0.70x
BenchmarkRegexpMatchHard_1K       8.56         6.34         0.74x
BenchmarkRevcomp                  332.92       359.62       1.08x
BenchmarkTemplate                 15.53        14.39        0.93x

LGTM=rlh
R=rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/136380043
2014-09-11 12:17:45 -04:00
Russ Cox
1d550b87db runtime: allow crash from gsignal stack
The uses of onM in dopanic/startpanic are okay even from the signal stack.

Fixes #8666.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/134710043
2014-09-11 12:08:30 -04:00
Mikio Hara
f956740163 net: fix inconsistent behavior across platforms in SetKeepAlivePeriod
The previous implementation used per-socket TCP keepalive options
wrong. For example, it used another level socket option to control
TCP and it didn't use TCP_KEEPINTVL option when possible.

Fixes #8683.
Fixes #8701.
Update #8679

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/136480043
2014-09-11 17:56:58 +09:00
Keith Randall
b78d7b75c7 reflect: use runtime's memmove instead of its own
They will both need write barriers at some point.
But until then, no reason why we shouldn't share.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/141330043
2014-09-10 12:37:28 -07:00
Anthony Martin
2302b21bbe runtime: stop plan9/amd64 build from crashing
LGTM=iant
R=rsc, 0intro, alex.brainman, iant
CC=golang-codereviews
https://golang.org/cl/140460044
2014-09-10 06:25:05 -07:00
Matthew Dempsky
d955dfb007 runtime: cleanup openbsd semasleep implementation
The previous implementation had several subtle issues.  It's not
clear if any of these could actually be causing the flakiness
problems on openbsd/386, but fixing them should only help.

1. thrsleep() is implemented internally as unlock, then test *abort
(if abort != nil), then tsleep().  Under the current code, that makes
it theoretically possible that semasleep()/thrsleep() could release
waitsemalock, then a racing semawakeup() could acquire the lock,
increment waitsemacount, and call thrwakeup()/wakeup() before
thrsleep() reaches tsleep().  (In practice, OpenBSD's big kernel lock
seems unlikely to let this actually happen.)

The proper way to avoid this is to pass &waitsemacount as the abort
pointer to thrsleep so thrsleep knows to re-check it before going to
sleep, and to wakeup if it's non-zero.  Then we avoid any races.
(I actually suspect openbsd's sema{sleep,wakeup}() could be further
simplified using cas/xadd instead of locks, but I don't want to be
more intrusive than necessary so late in the 1.4 release cycle.)

2. semasleep() takes a relative sleep duration, but thrsleep() needs
an absolute sleep deadline.  Instead of recomputing the deadline each
iteration, compute it once up front and use (*Timespec)(nil) to signify
no deadline.  Ensures we retry properly if there's a spurious wakeup.

3. Instead of assuming if thrsleep() woke up and waitsemacount wasn't
available that we must have hit the deadline, check that the system
call returned EWOULDBLOCK.

4. Instead of assuming that 64-bit systems are little-endian, compute
timediv() using a temporary int32 nsec and then assign it to tv_nsec.

LGTM=iant
R=jsing, iant
CC=golang-codereviews
https://golang.org/cl/137960043
2014-09-09 17:41:48 -07:00
Anthony Martin
9f012e1002 runtime: call rfork on scheduler stack on Plan 9
A race exists between the parent and child processes after a fork.
The child needs to access the new M pointer passed as an argument
but the parent may have already returned and clobbered it.

Previously, we avoided this by saving the necessary data into
registers before the rfork system call but this isn't guaranteed
to work because Plan 9 makes no promises about the register state
after a system call. Only the 386 kernel seems to save them.
For amd64 and arm, this method won't work.

We eliminate the race by allocating stack space for the scheduler
goroutines (g0) in the per-process copy-on-write stack segment and
by only calling rfork on the scheduler stack.

LGTM=aram, 0intro, rsc
R=aram, 0intro, mischief, rsc
CC=golang-codereviews
https://golang.org/cl/110680044
2014-09-09 17:19:01 -07:00
Keith Randall
1a5e394ab7 runtime: more cleanups
Move timenow thunk into time.s
Move declarations for generic c/asm services into stubs.go

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/137360043
2014-09-09 14:32:53 -07:00
Keith Randall
251daf8650 runtime: map iterators: always use intrabucket randomess
Fixes #8688

LGTM=rsc
R=golang-codereviews, bradfitz, rsc, khr
CC=golang-codereviews
https://golang.org/cl/135660043
2014-09-09 14:22:58 -07:00
Russ Cox
f9829e92e1 runtime: fix plan9/amd64 build?
The only thing I can see that is really Plan 9-specific
is that the stack pointer used for signal handling used
to have more mapped memory above it.
Specifically it used to have at most 88 bytes (StackTop),
so change the allocation of a 40-byte frame to a 128-byte frame.

No idea if this will work, but worth a try.

Note that "fix" here means get it back to timing out
instead of crashing.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142840043
2014-09-09 17:16:31 -04:00
Russ Cox
ee6c6d96b6 runtime: fix windows/386 build
The difference between the old and the new (from earlier) code
is that we set stackguard = stack.lo + StackGuard, while the old
code set stackguard = stack.lo. That 512 bytes appears to be
the difference between the profileloop function running and not running.

We don't know how big the system stack is, but it is likely MUCH bigger than 4k.
Give Go/C 8k.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/140440044
2014-09-09 17:12:05 -04:00
Russ Cox
16c59acb97 runtime: avoid read overrun in heapdump
Start the stack a few words below the actual top, so that
if something tries to read goexit's caller PC from the stack,
it won't fault on a bad memory address.
Today, heapdump does that.
Maybe tomorrow, traceback or something else will do that.
Make it not a bug.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/136450043
2014-09-09 15:38:55 -04:00
Rob Pike
d33ee0c5e5 testing: read coverage counters atomically
For -mode=atomic, we need to read the counters
using an atomic load to avoid a race. Not worth worrying
about when -mode=atomic is set during generation
of the profile, so we use atomic loads always.

Fixes #8630.

LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/141800043
2014-09-09 12:31:07 -07:00
Rob Pike
eafa4fff52 fmt: fix allocation test
With new interface allocation rules, the old counts were wrong and
so was the commentary.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/142760044
2014-09-09 11:45:46 -07:00
Rob Pike
b6571a0713 strconv: fix documentation for CanBackquote.
Space is not a control character.

Fixes #8571.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/137380043
2014-09-09 11:45:36 -07:00
Russ Cox
8ac35be145 runtime: fix build failures after CL 137410043
No promise about correctness, but they do build.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/143720043
2014-09-09 14:02:37 -04:00
Russ Cox
15b76ad94b runtime: assume precisestack, copystack, StackCopyAlways, ScanStackByFrames
Commit to stack copying for stack growth.

We're carrying around a surprising amount of cruft from older schemes.
I am confident that precise stack scans and stack copying are here to stay.

Delete fallback code for when precise stack info is disabled.
Delete fallback code for when copying stacks is disabled.
Delete fallback code for when StackCopyAlways is disabled.
Delete Stktop chain - there is only one stack segment now.
Delete M.moreargp, M.moreargsize, M.moreframesize, M.cret.
Delete G.writenbuf (unrelated, just dead).
Delete runtime.lessstack, runtime.oldstack.
Delete many amd64 morestack variants.
Delete initialization of morestack frame/arg sizes (shortens split prologue!).

Replace G's stackguard/stackbase/stack0/stacksize/
syscallstack/syscallguard/forkstackguard with simple stack
bounds (lo, hi).

Update liblink, runtime/cgo for adjustments to G.

LGTM=khr
R=khr, bradfitz
CC=golang-codereviews, iant, r
https://golang.org/cl/137410043
2014-09-09 13:39:57 -04:00
Alex Brainman
d72029e3a3 undo CL 140110043 / 17b5fc2aa130
I have found better approach, then longer wait.
See CL 134360043 for details.

««« original CL description
runtime/pprof: adjust cpuHogger so that tests pass on windows builders

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

»»»

LGTM=dave
R=golang-codereviews, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/133500043
2014-09-09 16:05:00 +10:00
Russ Cox
bffb0590c1 runtime: merge mallocgc, gomallocgc
I assumed they were the same when I wrote
cgocallback.go earlier today. Merge them
to eliminate confusion.

I can't tell what gomallocgc did before with
a nil type but without FlagNoScan.
I created a call like that in cgocallback.go
this morning, translating from a C file.
It was supposed to do what the C version did,
namely treat the block conservatively.
Now it will.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/141810043
2014-09-09 01:08:34 -04:00
Russ Cox
0f99a91bb5 runtime: let stack copier update Panic structs for us
It already is updating parts of them; we're just getting lucky
retraversing them and not finding much to do.
Change argp to a pointer so that it will be updated too.
Existing tests break if you apply the change to adjustpanics
without also updating the type of argp.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/139380043
2014-09-08 21:02:36 -04:00
Brad Fitzpatrick
c93f74d34b syscall: keep Windows syscall pointers live too
Like https://golang.org/cl/139360044

LGTM=rsc, alex.brainman
R=alex.brainman, rsc
CC=golang-codereviews
https://golang.org/cl/138250043
2014-09-08 17:47:12 -07:00
Keith Randall
55c458e05f runtime: on bigger maps, start iterator at a random bucket.
This change brings the iter/delete pattern down to O(n lgn) from O(n^2).

Fixes #8412.

before:
BenchmarkMapPop100	   50000	     32498 ns/op
BenchmarkMapPop1000	     500	   3244851 ns/op
BenchmarkMapPop10000	       5	 270276855 ns/op

after:
BenchmarkMapPop100	  100000	     16169 ns/op
BenchmarkMapPop1000	    5000	    300416 ns/op
BenchmarkMapPop10000	     300	   5990814 ns/op

LGTM=iant
R=golang-codereviews, iant, khr
CC=golang-codereviews
https://golang.org/cl/141270043
2014-09-08 17:42:21 -07:00
Brad Fitzpatrick
d2788dc503 syscall: fix comment in mkall_windows.bat
src/pkg -> src

LGTM=alex.brainman
R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/139400043
2014-09-08 17:40:32 -07:00
Russ Cox
815a843b6a runtime: enable StackCopyAlways
It worked at CL 134660043 on the builders,
so I believe it will stick this time.

LGTM=bradfitz
R=khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/141280043
2014-09-08 20:37:28 -04:00
Keith Randall
1d88f9dd4d runtime: note the double-releasem isn't an error.
LGTM=bradfitz
R=dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/136390043
2014-09-08 15:42:48 -07:00
Mikio Hara
1fadd9e1ae net: don't set wrong option for controlling tcp keepalive on openbsd
Fixes #8679.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/141730043
2014-09-09 07:22:11 +09:00
Russ Cox
176020e1b1 runtime: turn off StackCopyAlways
windows/amd64 failure:
http://build.golang.org/log/1ded5e3ef4bd1226f976e3180772f87e6c918255

# ..\misc\cgo\testso
runtime: copystack: locals size info only for syscall.Syscall
fatal error: split stack not allowed

runtime stack:
runtime.throw(0xa64cc7)
        c:/go/src/runtime/panic.go:395 +0xad fp=0x6fde0 sp=0x6fdb0
runtime.newstack()
        c:/go/src/runtime/stack.c:1001 +0x750 fp=0x6ff20 sp=0x6fde0
runtime.morestack()
        c:/go/src/runtime/asm_amd64.s:306 +0x73 fp=0x6ff28 sp=0x6ff20

goroutine 1 [stack growth, locked to thread]:
runtime.freedefer(0xc0820ce120)
        c:/go/src/runtime/panic.go:162 fp=0xc08201b1a0 sp=0xc08201b198
runtime.deferreturn(0xa69420)
        c:/go/src/runtime/panic.go:211 +0xa8 fp=0xc08201b1e8 sp=0xc08201b1a0
runtime.cgocall_errno(0x498c00, 0xc08201b228, 0x0)
        c:/go/src/runtime/cgocall.go:134 +0x10e fp=0xc08201b210 sp=0xc08201b1e8
syscall.Syscall(0x7786b1d0, 0x2, 0xc0820c85b0, 0xc08201b2d8, 0x0, 0x0, 0x0, 0x0)
        c:/go/src/runtime/syscall_windows.c:74 +0x3c fp=0xc08201b260 sp=0xc08201b210
syscall.findFirstFile1(0xc0820c85b0, 0xc08201b2d8, 0x500000000000000, 0x0, 0x0)
        c:/go/src/syscall/zsyscall_windows.go:340 +0x76 fp=0xc08201b2b0 sp=0xc08201b260
syscall.FindFirstFile(0xc0820c85b0, 0xc08210c500, 0xc0820c85b0, 0x0, 0x0)
        c:/go/src/syscall/syscall_windows.go:907 +0x6a fp=0xc08201b530 sp=0xc08201b2b0
os.openDir(0xc0820b2e40, 0x33, 0x0, 0x0, 0x0)
        c:/go/src/os/file_windows.go:96 +0x110 fp=0xc08201b5e0 sp=0xc08201b530
os.OpenFile(0xc0820b2e40, 0x33, 0x0, 0x0, 0x41, 0x0, 0x0)
        c:/go/src/os/file_windows.go:143 +0x1e9 fp=0xc08201b650 sp=0xc08201b5e0

TBR=khr
CC=golang-codereviews
https://golang.org/cl/138230043
2014-09-08 18:07:50 -04:00
Russ Cox
5103500d13 runtime: mark endcgo go:nosplit
Should help windows/amd64.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/134660043
2014-09-08 18:07:33 -04:00
Robert Griesemer
ec96795ba2 go/parser: fix (pathological) corner case
Inside a control clause (if ... {}), composite
literals starting with a type name must be parenthesized.
A composite literal used in the array length expression
of an array composite literal is already parenthesized.
Not a valid program, but syntactically is should
be accepted.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/142760043
2014-09-08 14:54:00 -07:00
Russ Cox
857d55a3f9 runtime: mark freedefer and deferclass go:nosplit
This should make deferreturn nosplit all the way down,
which should fix the current windows/amd64 failure.
If not, I will change StackCopyAlways back to 0.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/135600043
2014-09-08 17:37:49 -04:00