]> Cypherpunks repositories - gostls13.git/log
gostls13.git
11 years agonet/http: Request Body error should not be ignored.
Luka Zakrajšek [Mon, 17 Mar 2014 22:52:52 +0000 (15:52 -0700)]
net/http: Request Body error should not be ignored.

Fixes #7521.

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

11 years agoA+C: Luka Zakrajšek (individual CLA)
Brad Fitzpatrick [Mon, 17 Mar 2014 22:49:32 +0000 (15:49 -0700)]
A+C: Luka Zakrajšek (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/77120044

11 years agonet/http/fcgi: fix handling of request ID reuse
Catalin Patulea [Mon, 17 Mar 2014 22:47:16 +0000 (15:47 -0700)]
net/http/fcgi: fix handling of request ID reuse

Request ID reuse is allowed by the FastCGI spec [1]. In particular nginx uses
the same request ID, 1, for all requests on a given connection. Because
serveRequest does not remove the request from conn.requests, this causes it to
treat the second request as a duplicate and drops the connection immediately
after beginRequest. This manifests with nginx option 'fastcgi_keep_conn on' as
the following message in nginx error log:

2014/03/17 01:39:13 [error] 730#0: *109 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "example.org"

Because handleRecord and serveRequest run in different goroutines, access to
conn.requests must now be synchronized.

[1] http://www.fastcgi.com/drupal/node/6?q=node/22#S3.3

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/76800043

11 years agoC: add Catalin Patulea (Google CLA)
Brad Fitzpatrick [Mon, 17 Mar 2014 22:46:31 +0000 (15:46 -0700)]
C: add Catalin Patulea (Google CLA)

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/76400044

11 years agoencoding/hex: add error check for write error.
Rui Ueyama [Mon, 17 Mar 2014 19:07:30 +0000 (12:07 -0700)]
encoding/hex: add error check for write error.

I believe the original author of this code just forgot to check for error here.

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

11 years agomisc/bash/go: Add a completion rule for "go env".
Rui Ueyama [Mon, 17 Mar 2014 18:58:02 +0000 (11:58 -0700)]
misc/bash/go: Add a completion rule for "go env".

"env" is a valid go command. This patch is to make bash to autocomplete it.

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

11 years agoC: add Rui Ueyama (Google CLA)
Brad Fitzpatrick [Mon, 17 Mar 2014 18:57:04 +0000 (11:57 -0700)]
C: add Rui Ueyama (Google CLA)

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

11 years agodoc: Revise Contribution Guidelines.
Nathan John Youngman [Sun, 16 Mar 2014 22:35:04 +0000 (09:35 +1100)]
doc: Revise Contribution Guidelines.

Smooth out the setup process for new contributors.

* Remove references $GOROOT (often not defined).
* Add a note for contributing to subrepositories.
* Emphasize that hg mail also uploads the latest copy.

LGTM=adg
R=golang-codereviews, iant, adg
CC=golang-codereviews
https://golang.org/cl/74370043

11 years agocmd/gc: fix comment about how GOEXPERIMENT works
Ian Lance Taylor [Sat, 15 Mar 2014 18:18:11 +0000 (11:18 -0700)]
cmd/gc: fix comment about how GOEXPERIMENT works

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://golang.org/cl/76270043

11 years agonet: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines
Mikio Hara [Sat, 15 Mar 2014 04:43:02 +0000 (13:43 +0900)]
net: make use of testing.Errorf instead of testing.Fatalf in non-test function goroutines

See testing.FailNow for further information.

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

11 years agoruntime: fix 386 assembly for syscall.naclWrite
Rémy Oudompheng [Fri, 14 Mar 2014 21:49:46 +0000 (22:49 +0100)]
runtime: fix 386 assembly for syscall.naclWrite

It was using the wrong offset and returned random values
making "runoutput" compiler tests crash.

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

11 years agoliblink, runtime: make nacl/386 binaries valid.
Rémy Oudompheng [Fri, 14 Mar 2014 20:33:55 +0000 (21:33 +0100)]
liblink, runtime: make nacl/386 binaries valid.

They were rejected by NaCl due to AES instructions and
accesses to %gs:0x8, caused by wrong tlsoffset value.

LGTM=iant
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/76050044

11 years agoruntime: fix another race in bgsweep
Dmitriy Vyukov [Fri, 14 Mar 2014 19:32:12 +0000 (23:32 +0400)]
runtime: fix another race in bgsweep
It's possible that bgsweep constantly does not catch up for some reason,
in this case runfinq was not woken at all.

R=rsc
CC=golang-codereviews
https://golang.org/cl/75940043

11 years agoruntime: fix spans corruption
Dmitriy Vyukov [Fri, 14 Mar 2014 19:25:48 +0000 (23:25 +0400)]
runtime: fix spans corruption
The problem was that spans end up in wrong lists after split
(e.g. in h->busy instead of h->central->empty).
Also the span can be non-swept before split,
I don't know what it can cause, but it's safer to operate on swept spans.
Fixes #7544.

R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/76160043

11 years agocmd/6g, runtime: alignment fixes for amd64p32.
Rémy Oudompheng [Fri, 14 Mar 2014 18:37:39 +0000 (19:37 +0100)]
cmd/6g, runtime: alignment fixes for amd64p32.

LGTM=rsc
R=rsc, dave, iant, khr
CC=golang-codereviews
https://golang.org/cl/75820044

11 years agoruntime: report "out of memory" in efence mode
Dmitriy Vyukov [Fri, 14 Mar 2014 17:22:03 +0000 (21:22 +0400)]
runtime: report "out of memory" in efence mode
Currently processes crash with obscure message.
Say that it's "out of memory".

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/75820045

11 years agoruntime: fix a race in bgsweep
Dmitriy Vyukov [Fri, 14 Mar 2014 17:21:44 +0000 (21:21 +0400)]
runtime: fix a race in bgsweep
See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75670044

11 years agoruntime: do not shrink stacks GOCOPYSTACK=0
Dmitriy Vyukov [Fri, 14 Mar 2014 17:11:04 +0000 (21:11 +0400)]
runtime: do not shrink stacks GOCOPYSTACK=0

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://golang.org/cl/76070043

11 years agocmd/go: fix invalid go pack command line in the output of go build -x
Jan Ziak [Fri, 14 Mar 2014 15:44:54 +0000 (16:44 +0100)]
cmd/go: fix invalid go pack command line in the output of go build -x

Fixes #7262

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

11 years agocmd/gc: fix spurious 'not enough arguments to return' error
Jan Ziak [Fri, 14 Mar 2014 15:42:42 +0000 (16:42 +0100)]
cmd/gc: fix spurious 'not enough arguments to return' error

Fixes #6405

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72920046

11 years agocmd/gc: replace '·' as '.' in ELF/Mach-O symbol tables
Shenghou Ma [Fri, 14 Mar 2014 14:07:51 +0000 (10:07 -0400)]
cmd/gc: replace '·' as '.' in ELF/Mach-O symbol tables

Old versions of DTrace (as those shipped in OS X and FreeBSD)
don't support unicode characters in symbol names.  Replace '·'
to '.' to make DTrace happy.

Fixes #7493

LGTM=aram, rsc
R=aram, rsc, gobot, iant
CC=golang-codereviews
https://golang.org/cl/72280043

11 years agoruntime: fix use after close race in Solaris network poller
Aram Hăvărneanu [Fri, 14 Mar 2014 13:53:05 +0000 (17:53 +0400)]
runtime: fix use after close race in Solaris network poller

The Solaris network poller uses event ports, which are
level-triggered. As such, it has to re-arm itself after each
wakeup. The arming mechanism (which runs in its own thread) raced
with the closing of a file descriptor happening in a different
thread. When a network file descriptor is about to be closed,
the network poller is awaken to give it a chance to remove its
association with the file descriptor. Because the poller always
re-armed itself, it raced with code that closed the descriptor.

This change makes the network poller check before re-arming if
the file descriptor is about to be closed, in which case it will
ignore the re-arming request. It uses the per-PollDesc lock in
order to serialize access to the PollDesc.

This change also adds extensive documentation describing the
Solaris implementation of the network poller.

Fixes #7410.

LGTM=dvyukov, iant
R=golang-codereviews, bradfitz, iant, dvyukov, aram.h, gobot
CC=golang-codereviews
https://golang.org/cl/69190044

11 years agodebug/macho: handle missing __debug_str section
Keith Randall [Thu, 13 Mar 2014 21:04:29 +0000 (14:04 -0700)]
debug/macho: handle missing __debug_str section

debug/elf does the same thing, use []byte{} for
any missing sections.

Fixes #7510

LGTM=rsc
R=golang-codereviews, iant
CC=golang-codereviews, rsc
https://golang.org/cl/75230043

11 years agoruntime: fix signal handling on Plan 9
Anthony Martin [Thu, 13 Mar 2014 16:00:12 +0000 (09:00 -0700)]
runtime: fix signal handling on Plan 9

LGTM=rsc
R=rsc, 0intro, aram, jeremyjackins, iant
CC=golang-codereviews, lucio.dere, minux.ma, paurea, r
https://golang.org/cl/9796043

11 years agoruntime: improve efence
Dmitriy Vyukov [Thu, 13 Mar 2014 15:04:00 +0000 (19:04 +0400)]
runtime: improve efence
Mark free memory blocks as unused.
On amd64 it allows the process to eat all 128 GB of heap
without killing the machine.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/74070043

11 years agodoc: update go1.3.txt for some performance changes
Dmitriy Vyukov [Thu, 13 Mar 2014 15:03:41 +0000 (19:03 +0400)]
doc: update go1.3.txt for some performance changes

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

11 years agoruntime: detect stack split after fork
Dmitriy Vyukov [Thu, 13 Mar 2014 13:41:08 +0000 (17:41 +0400)]
runtime: detect stack split after fork
This check would allowed to easily prevent issue 7511.
Update #7511

LGTM=rsc
R=rsc, aram
CC=golang-codereviews
https://golang.org/cl/75260043

11 years agoruntime: harden conditions when runtime panics on crash
Dmitriy Vyukov [Thu, 13 Mar 2014 09:25:59 +0000 (13:25 +0400)]
runtime: harden conditions when runtime panics on crash
This is especially important for SetPanicOnCrash,
but also useful for e.g. nil deref in mallocgc.
Panics on such crashes can't lead to anything useful,
only to deadlocks, hangs and obscure crashes.
This is a copy of broken but already LGTMed
https://golang.org/cl/68540043/

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/75320043

11 years agoruntime: fix stack size check
Dmitriy Vyukov [Thu, 13 Mar 2014 09:16:02 +0000 (13:16 +0400)]
runtime: fix stack size check
When we copy stack, we check only new size of the top segment.
This is incorrect, because we can have other segments below it.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/73980045

11 years agoruntime: avoid runtime·cgocall in functions called by forkAndExecInChild
Aram Hăvărneanu [Thu, 13 Mar 2014 07:26:01 +0000 (18:26 +1100)]
runtime: avoid runtime·cgocall in functions called by forkAndExecInChild

Calling runtime·cgocall could trigger a GC in the child while
gclock was held by the parent.

Fixes #7511

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

11 years agocmd/gc: fix spurious type errors in walkselect.
Rémy Oudompheng [Thu, 13 Mar 2014 07:14:05 +0000 (08:14 +0100)]
cmd/gc: fix spurious type errors in walkselect.

The lowering to runtime calls introduces hidden pointers to the
arguments of select clauses. When implicit conversions were
involved it could end up with incompatible pointers. Since the
pointed-to types have the same representation, we can introduce a
forced conversion.

Fixes #6847.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/72380043

11 years agocmd/6g: fix stack zeroing preamble on amd64p32.
Rémy Oudompheng [Thu, 13 Mar 2014 07:12:38 +0000 (08:12 +0100)]
cmd/6g: fix stack zeroing preamble on amd64p32.

It was using a REP STOSQ but putting in CX the number of 32-bit
words to clear.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/75240043

11 years agonet: fix TCP keepalive on dragonfly
Mikio Hara [Thu, 13 Mar 2014 05:45:50 +0000 (14:45 +0900)]
net: fix TCP keepalive on dragonfly

Fixes #7528.

LGTM=jsing
R=jsing
CC=golang-codereviews
https://golang.org/cl/75140045

11 years agocmd/go: use correct libraries during gccgo link
Michael Hudson-Doyle [Thu, 13 Mar 2014 03:05:54 +0000 (23:05 -0400)]
cmd/go: use correct libraries during gccgo link

Under some circumstances, gccgoToolchain's ld can pass the path of
build outputs that have been deleted to the link command.

Fixes #7303.

LGTM=rsc
R=golang-codereviews, dave, michael.hudson, rsc
CC=golang-codereviews
https://golang.org/cl/61970044

11 years agoruntime: call symtabinit earlier
Anthony Martin [Thu, 13 Mar 2014 02:42:58 +0000 (19:42 -0700)]
runtime: call symtabinit earlier

Otherwise, we won't get a stack trace in some of the early init.

Here's one example:

        http://build.golang.org/log/a96d10f6aee1fa3e3ae51f41da46d414a7ab02de

After walking the stack by hand in acid, I was able to determine
that the stackalloc inside mpreinit was causing the throw.

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

11 years agocmd/gc: make the fpu handle all exceptions on Plan 9
Anthony Martin [Thu, 13 Mar 2014 02:41:36 +0000 (19:41 -0700)]
cmd/gc: make the fpu handle all exceptions on Plan 9

The compilers expect to not be interrupted by floating
point exceptions. On Plan 9, every process starts with
interrupts enabled for invalid operation, stack overflow,
and divide by zero exceptions.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/72750043

11 years agoos: relax the way we kill processes on Plan 9
Anthony Martin [Thu, 13 Mar 2014 01:12:56 +0000 (18:12 -0700)]
os: relax the way we kill processes on Plan 9

Previously, we wrote "kill" to the process control file
to kill a program. This is problematic because it doesn't
let the program gracefully exit.

This matters especially if the process we're killing is a
Go program. On Unix, sending SIGKILL to a Go program will
automatically kill all runtime threads. On Plan 9, there
are no threads so when the program wants to exit it has to
somehow signal all of the runtime processes. It can't do
this if we mercilessly kill it by writing to it's control
file.

Instead, we now send it a note to invoke it's note handler
and let it perform any cleanup before exiting.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/74440044

11 years agoruntime: use unoptimized memmove and memclr on Plan 9
Anthony Martin [Thu, 13 Mar 2014 01:12:25 +0000 (18:12 -0700)]
runtime: use unoptimized memmove and memclr on Plan 9

On Plan 9, the kernel disallows the use of floating point
instructions while handling a note. Previously, we worked
around this by using a simple loop in place of memmove.

When I added that work-around, I verified that all paths
from the note handler didn't end up calling memmove. Now
that memclr is using SSE instructions, the same process
will have to be done again.

Instead of doing that, however, this CL just punts and
uses unoptimized functions everywhere on Plan 9.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/73830044

11 years agocmd/ld: give acid a fighting chance at unwinding the stack
Anthony Martin [Thu, 13 Mar 2014 01:10:31 +0000 (18:10 -0700)]
cmd/ld: give acid a fighting chance at unwinding the stack

Acid can't produce a stack trace without .frame symbols.

Of course, it can only unwind through linear stacks but
this is still better than nothing. (I wrote an acid func
to do the full unwind a long time ago but lost it and
haven't worked up the courage to write it again).

Note that these will only be present in the native symbol
table for Plan 9 binaries.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72450045

11 years agodoc: update go1.3.txt for regexp change
Brad Fitzpatrick [Wed, 12 Mar 2014 21:23:40 +0000 (14:23 -0700)]
doc: update go1.3.txt for regexp change

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72640043

11 years agoruntime: fix missing nacl/386 symbol
Dave Cheney [Wed, 12 Mar 2014 20:58:42 +0000 (07:58 +1100)]
runtime: fix missing nacl/386 symbol

syscall.naclWrite was missing from sys_nacl_386.s

This gets ./make.bash passing, but doesn't pass validation. I'm not sure if this is the fault of this change, or validation was broken anyway.

LGTM=rsc
R=minux.ma, rsc
CC=golang-codereviews
https://golang.org/cl/74510043

11 years agodoc/go1.3.txt: add notes about copying stacks, win2k support
Russ Cox [Wed, 12 Mar 2014 20:32:35 +0000 (16:32 -0400)]
doc/go1.3.txt: add notes about copying stacks, win2k support

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

11 years agomisc/emacs: correctly fontify methods when go-fontify-function-calls is nil
Dominik Honnef [Wed, 12 Mar 2014 15:02:42 +0000 (11:02 -0400)]
misc/emacs: correctly fontify methods when go-fontify-function-calls is nil

We were fontifying the wrong part of method declarations

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/66120043

11 years agofmt: improve documentation for width and precision
Rob Pike [Wed, 12 Mar 2014 11:00:48 +0000 (22:00 +1100)]
fmt: improve documentation for width and precision
Fixes #7048.

LGTM=dominik.honnef
R=golang-codereviews, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/74280044

11 years agoruntime: efence support for growable stacks
Dmitriy Vyukov [Wed, 12 Mar 2014 06:21:34 +0000 (10:21 +0400)]
runtime: efence support for growable stacks
1. Fix the bug that shrinkstack returns memory to heap.
   This causes growslice to misbehave (it manually initialized
   blocks, and in efence mode shrinkstack's free leads to
   partially-initialized blocks coming out of growslice.
   Which in turn causes GC to crash while treating the garbage
   as Eface/Iface.
2. Enable efence for stack segments.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://golang.org/cl/74080043

11 years agoruntime: temporary weaken a check in test
Dmitriy Vyukov [Wed, 12 Mar 2014 06:20:58 +0000 (10:20 +0400)]
runtime: temporary weaken a check in test
Currently the test fails as:
$ go test -v -cpu 1,1,1,1 runtime -test.run=TestStack
stack_test.go:1584: Stack inuse: want 4194304, got 18446744073709547520

Update #7468

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

11 years agocmd/go: respect system CGO_CFLAGS and CGO_CXXFLAGS
Jan Ziak [Wed, 12 Mar 2014 06:16:22 +0000 (07:16 +0100)]
cmd/go: respect system CGO_CFLAGS and CGO_CXXFLAGS

Fixes #6882

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/72080043

11 years agonet/http/cgi: serve 500, not 200, on invalid responses from child processes
Brad Fitzpatrick [Wed, 12 Mar 2014 05:55:15 +0000 (22:55 -0700)]
net/http/cgi: serve 500, not 200, on invalid responses from child processes

Per RFC 3875 section 6 rules.

Fixes #7198

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/68960049

11 years agoruntime: fix empty string handling in garbage collector
Russ Cox [Wed, 12 Mar 2014 03:58:39 +0000 (23:58 -0400)]
runtime: fix empty string handling in garbage collector

The garbage collector uses type information to guide the
traversal of the heap. If it sees a field that should be a string,
it marks the object pointed at by the string data pointer as
visited but does not bother to look at the data, because
strings contain bytes, not pointers.

If you save s[len(s):] somewhere, though, the string data pointer
actually points just beyond the string data; if the string data
were exactly the size of an allocated block, the string data
pointer would actually point at the next block. It is incorrect
to mark that next block as visited and not bother to look at
the data, because the next block may be some other type
entirely.

The fix is to ignore strings with zero length during collection:
they are empty and can never become non-empty: the base
pointer will never be used again. The handling of slices already
does this (but using cap instead of len).

This was not a bug in Go 1.2, because until January all string
allocations included a trailing NUL byte not included in the
length, so s[len(s):] still pointed inside the string allocation
(at the NUL).

This bug was causing the crashes in test/run.go. Specifically,
the parsing of a regexp in package regexp/syntax allocated a
[]syntax.Inst with rounded size 1152 bytes. In fact it
allocated many such slices, because during the processing of
test/index2.go it creates thousands of regexps that are all
approximately the same complexity. That takes a long time, and
test/run works on other tests in other goroutines. One such
other test is chan/perm.go, which uses an 1152-byte source
file. test/run reads that file into a []byte and then calls
strings.Split(string(src), "\n"). The string(src) creates an
1152-byte string - and there's a very good chance of it
landing next to one of the many many regexp slices already
allocated - and then because the file ends in a \n,
strings.Split records the tail empty string as the final
element in the slice. A garbage collection happens at this
point, the collection finds that string before encountering
the []syntax.Inst data it now inadvertently points to, and the
[]syntax.Inst data is not scanned for the pointers that it
contains. Each syntax.Inst contains a []rune, those are
missed, and the backing rune arrays are freed for reuse. When
the regexp is later executed, the runes being searched for are
no longer runes at all, and there is no match, even on text
that should match.

On 64-bit machines the pointer in the []rune inside the
syntax.Inst is larger (along with a few other pointers),
pushing the []syntax.Inst backing array into a larger size
class, avoiding the collision with chan/perm.go's
inadvertently sized file.

I expect this was more prevalent on OS X than on Linux or
Windows because those managed to run faster or slower and
didn't overlap index2.go with chan/perm.go as often. On the
ARM systems, we only run one errorcheck test at a time, so
index2 and chan/perm would never overlap.

It is possible that this bug is the root cause of other crashes
as well. For now we only know it is the cause of the test/run crash.

Many thanks to Dmitriy for help debugging.

Fixes #7344.
Fixes #7455.

LGTM=r, dvyukov, dave, iant
R=golang-codereviews, dave, r, dvyukov, delpontej, iant
CC=golang-codereviews, khr
https://golang.org/cl/74250043

11 years agotest/run: make errorcheck tests faster
Russ Cox [Wed, 12 Mar 2014 03:58:24 +0000 (23:58 -0400)]
test/run: make errorcheck tests faster

Some of the errorcheck tests have many many identical regexps.
Use a map to avoid storing the compiled form many many times
in memory. Change the filterRe to a simple string to avoid
the expense of those regexps as well.

Cuts the time for run.go on index2.go by almost 50x.

Noticed during debugging of issue 7344.

LGTM=bradfitz
R=bradfitz, josharian
CC=golang-codereviews
https://golang.org/cl/74380043

11 years agocmd/gc: fix crash in -live mode
Russ Cox [Wed, 12 Mar 2014 03:58:11 +0000 (23:58 -0400)]
cmd/gc: fix crash in -live mode

debuglive >= 1 is not the condition under which we
start recording messages (we avoid printing for
init functions even if debuglive is set).

LGTM=bradfitz, iant
R=golang-codereviews, bradfitz
CC=golang-codereviews, iant, khr
https://golang.org/cl/74390043

11 years agodwarf: add extensions for multi-file compression (.dwz)
Dhiru Kholia [Wed, 12 Mar 2014 01:49:50 +0000 (18:49 -0700)]
dwarf: add extensions for multi-file compression (.dwz)

LGTM=iant
R=golang-codereviews, iant, bradfitz
CC=golang-codereviews, math-nuts
https://golang.org/cl/72820044

11 years agoruntime: make use of THREAD_SHARE userspace mutex on freebsd
Mikio Hara [Wed, 12 Mar 2014 01:33:09 +0000 (10:33 +0900)]
runtime: make use of THREAD_SHARE userspace mutex on freebsd

For now Note, futexsleep and futexwakeup are designed for threads,
not for processes. The explicit use of UMTX_OP_WAIT_UINT_PRIVATE and
UMTX_OP_WAKE_PRIVATE can avoid unnecessary traversals of VM objects,
to hit undiscovered bugs related to VM system on SMP/SMT/NUMA
environment.

Update #7496

LGTM=iant
R=golang-codereviews, gobot, iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/72760043

11 years agosyscall, net: clean up socket stub for solaris
Mikio Hara [Wed, 12 Mar 2014 01:32:46 +0000 (10:32 +0900)]
syscall, net: clean up socket stub for solaris

Solaris doesn't have struct ip_mreqn, instead it uses struct ip_mreq
and struct group_req with struct sockaddr_storage.

Also fixes incorrect SockaddrDatalink.

Update #7399

LGTM=aram, iant
R=golang-codereviews, aram, gobot, iant
CC=golang-codereviews
https://golang.org/cl/73920043

11 years agoruntime: disable Native Client fake time support
Dave Cheney [Tue, 11 Mar 2014 21:55:30 +0000 (08:55 +1100)]
runtime: disable Native Client fake time support

This CL is a reformulation of CL 73110043 containing only the minimum required to get the nacl builds compiling.

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

11 years agopath/filepath: fixed misaligned comment.
Kay Zhu [Tue, 11 Mar 2014 21:34:07 +0000 (14:34 -0700)]
path/filepath: fixed misaligned comment.

The comment for 'Clean' function is prepended with spaces instead of
a single tab, resulting in visually misaligned comment in the generated
documentation.

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

11 years agoruntime: fix nacl/amd64p32 signal handling
Dave Cheney [Tue, 11 Mar 2014 20:21:55 +0000 (07:21 +1100)]
runtime: fix nacl/amd64p32 signal handling

The change to signal_amd64.c from CL 15790043 was not merged correctly.

This CL reapplies the change, renaming the file to signal_amd64x.c and adds the appropriate build tags.

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

11 years agoC: add Kay Zhu (Google CLA)
Brad Fitzpatrick [Tue, 11 Mar 2014 18:50:56 +0000 (11:50 -0700)]
C: add Kay Zhu (Google CLA)

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/74110043

11 years agoliblink: fix bad code generated for MOVFD/MOVDF when reg > 7
Josh Bleecher Snyder [Tue, 11 Mar 2014 18:04:44 +0000 (14:04 -0400)]
liblink: fix bad code generated for MOVFD/MOVDF when reg > 7

The byte that r is or'd into is already 0x7, so the failure to zero r only
impacts the generated machine code if the register is > 7.

Fixes #7044.

LGTM=dave, minux.ma, rsc
R=dave, minux.ma, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/73730043

11 years agocrypto/rsa: fix docs for PrecomputedValues.Qinv
Shenghou Ma [Tue, 11 Mar 2014 17:06:01 +0000 (13:06 -0400)]
crypto/rsa: fix docs for PrecomputedValues.Qinv
Fixes #7507.

LGTM=agl
R=agl
CC=golang-codereviews
https://golang.org/cl/74090043

11 years agoruntime: remove atomic CAS loop from marknogc
Dmitriy Vyukov [Tue, 11 Mar 2014 13:35:49 +0000 (17:35 +0400)]
runtime: remove atomic CAS loop from marknogc
Spans are now private to threads, and the loop
is removed from all other functions.
Remove it from marknogc for consistency.

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

11 years agoruntime: wipe out bitSpecial from GC code
Dmitriy Vyukov [Tue, 11 Mar 2014 13:33:03 +0000 (17:33 +0400)]
runtime: wipe out bitSpecial from GC code

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

11 years agosyscall: replace mksyscall_windows.pl with mksyscall_windows.go
Alex Brainman [Tue, 11 Mar 2014 05:36:14 +0000 (16:36 +1100)]
syscall: replace mksyscall_windows.pl with mksyscall_windows.go

Not many windows users have perl installed. They can just use
standard go tools instead. Also mkerrors_windows.sh script
removed - we don't add any new "unix" errors to windows
syscall package anymore.

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

11 years agoruntime: more Native Client fixes
Dave Cheney [Tue, 11 Mar 2014 03:43:10 +0000 (14:43 +1100)]
runtime: more Native Client fixes

Thanks to Ian for spotting these.

runtime.h: define uintreg correctly.
stack.c: address warning caused by the type of uintreg being 32 bits on amd64p32.

Commentary (mainly for my own use)

nacl/amd64p32 defines a machine with 64bit registers, but address space is limited to a 4gb window (the window is placed randomly inside the full 48 bit virtual address space of a process). To cope with this 6c defines _64BIT and _64BITREG.

_64BITREG is always defined by 6c, so both GOARCH=amd64 and GOARCH=amd64p32 use 64bit wide registers.

However _64BIT itself is only defined when 6c is compiling for amd64 targets. The definition is elided for amd64p32 environments causing int, uint and other arch specific types to revert to their 32bit definitions.

LGTM=iant
R=iant, rsc, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/72860046

11 years agonet/http: eliminate defined-but-not-used var.
Alan Donovan [Tue, 11 Mar 2014 02:22:51 +0000 (22:22 -0400)]
net/http: eliminate defined-but-not-used var.

gc does not report this as an error, but go/types does.
(I suspect that constructing a closure counts as a reference
to &all in gc's implementation).

This is not a tool bug, since the spec doesn't require
implementations to implement this check, but it does
illustrate that dialect variations are always a nuisance.

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

11 years agoruntime: remove unused declarations.
Keith Randall [Mon, 10 Mar 2014 23:02:46 +0000 (16:02 -0700)]
runtime: remove unused declarations.

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

11 years agoA+C: Dhiru Kholia (individual CLA)
Brad Fitzpatrick [Mon, 10 Mar 2014 22:59:38 +0000 (15:59 -0700)]
A+C: Dhiru Kholia (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/73770043

11 years agoruntime: small Native Client fixes
Dave Cheney [Mon, 10 Mar 2014 19:57:46 +0000 (06:57 +1100)]
runtime: small Native Client fixes

mem_nacl.c: add SysFault
env_posix.c: add nacl to build tag, from CL 15790043

LGTM=remyoudompheng, iant
R=rsc, remyoudompheng, iant
CC=golang-codereviews
https://golang.org/cl/72780043

11 years agoA+C: Steven Hartland (individual CLA)
Brad Fitzpatrick [Mon, 10 Mar 2014 16:34:57 +0000 (09:34 -0700)]
A+C: Steven Hartland (individual CLA)

Generated by addca.

R=gobot
CC=golang-codereviews
https://golang.org/cl/73630043

11 years agotime: handle int64 overflow in ParseDuration.
Adam Langley [Mon, 10 Mar 2014 16:33:45 +0000 (12:33 -0400)]
time: handle int64 overflow in ParseDuration.

Previously, passing a long duration to ParseDuration could result in
random, even negative, values.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/72120043

11 years agoruntime: fix cgocallback stack size on amd64p32.
Rémy Oudompheng [Mon, 10 Mar 2014 06:57:58 +0000 (07:57 +0100)]
runtime: fix cgocallback stack size on amd64p32.

LGTM=dave
R=rsc, dave, iant
CC=golang-codereviews
https://golang.org/cl/73160043

11 years agoruntime: fix flakiness on futexsleep test
Mikio Hara [Mon, 10 Mar 2014 03:20:16 +0000 (12:20 +0900)]
runtime: fix flakiness on futexsleep test

Fixes #7496.

LGTM=jsing
R=golang-codereviews, jsing
CC=golang-codereviews
https://golang.org/cl/72840043

11 years agosyscall: add missing SO_ERROR constant for nacl/*
Dave Cheney [Sun, 9 Mar 2014 02:18:12 +0000 (13:18 +1100)]
syscall: add missing SO_ERROR constant for nacl/*

CL 69340044 requires that syscall.SO_ERROR be defined on all unix like platforms. Add SO_ERROR to the list of dummy constants in sycall/net_nacl.go.

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

11 years agonet/rpc/jsonrpc: set exactly one of result or error to non-null in response
Brad Fitzpatrick [Sat, 8 Mar 2014 00:59:11 +0000 (16:59 -0800)]
net/rpc/jsonrpc: set exactly one of result or error to non-null in response

Fixes #7442

LGTM=gri
R=golang-codereviews, gri
CC=golang-codereviews
https://golang.org/cl/72570044

11 years agoos: document that Process.Wait only works on child processes
Brad Fitzpatrick [Fri, 7 Mar 2014 22:44:31 +0000 (14:44 -0800)]
os: document that Process.Wait only works on child processes

Fixes #7072

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/71900045

11 years agoruntime: fix futexsleep test on freebsd/386
Mikio Hara [Fri, 7 Mar 2014 22:34:40 +0000 (07:34 +0900)]
runtime: fix futexsleep test on freebsd/386

Fixes #7194.

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

11 years agocmd/gc: correct GOARCH in object files for amd64p32.
Rémy Oudompheng [Fri, 7 Mar 2014 22:18:07 +0000 (23:18 +0100)]
cmd/gc: correct GOARCH in object files for amd64p32.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72260045

11 years agoruntime: add missing nacl build tag for lock_sema.c
Rémy Oudompheng [Fri, 7 Mar 2014 22:17:44 +0000 (23:17 +0100)]
runtime: add missing nacl build tag for lock_sema.c

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72240045

11 years agosync: give finalizers more time in TestPoolGC
Russ Cox [Fri, 7 Mar 2014 21:08:12 +0000 (16:08 -0500)]
sync: give finalizers more time in TestPoolGC

If we report a leak, make sure we've waited long enough to be sure.
The new sleep regimen waits 1.05 seconds before failing; the old
one waited 0.005 seconds.

(The single linux/amd64 failure in this test feels more like a
timing problem than a leak. I don't want to spend time on it unless
we're sure.)

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/72630043

11 years agocrypto/md5, crypto/sha1: exclude amd64p32 from generic implementations.
Dave Cheney [Fri, 7 Mar 2014 20:54:41 +0000 (07:54 +1100)]
crypto/md5, crypto/sha1: exclude amd64p32 from generic implementations.

We provide amd64p32 implementations for md5 and sha1 so we need to exclude amd64p32 from the generic implementations in those packages.

Fixes build once CL 72360044 lands.

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

11 years agoregexp: add one-pass optimization from RE2
David Covert [Fri, 7 Mar 2014 20:30:02 +0000 (15:30 -0500)]
regexp: add one-pass optimization from RE2

This produces about a 2.3x speedup for patterns
that can be handled this way.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/13345046

11 years agoruntime: round stack size to power of 2.
Shenghou Ma [Fri, 7 Mar 2014 20:11:16 +0000 (15:11 -0500)]
runtime: round stack size to power of 2.
Fixes build on windows/386 and plan9/386.
Fixes #7487.

LGTM=mattn.jp, dvyukov, rsc
R=golang-codereviews, mattn.jp, dvyukov, 0intro, rsc
CC=golang-codereviews
https://golang.org/cl/72360043

11 years agocmd/gc: enforce register-width alignment for stack sizes.
Rémy Oudompheng [Fri, 7 Mar 2014 19:28:18 +0000 (20:28 +0100)]
cmd/gc: enforce register-width alignment for stack sizes.

This fixes the following amd64p32 issue:
    pkg/time/format.go:724: internal compiler error: twobitwalktype1: invalid initial alignment, Time

caused by the pointer zone ending on a 32-bit-aligned boundary.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/72270046

11 years agoruntime: comment out breakpoint in windows/386 sighandler
Russ Cox [Fri, 7 Mar 2014 19:22:17 +0000 (14:22 -0500)]
runtime: comment out breakpoint in windows/386 sighandler

This code being buggy is the only explanation I can come up
with for issue 7325. It's probably not, but the only alternative
is a Windows kernel bug. Comment this out to see what breaks
or gets fixed.

Update #7325

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

11 years agoruntime: fix windows/386 build
Russ Cox [Fri, 7 Mar 2014 19:19:05 +0000 (14:19 -0500)]
runtime: fix windows/386 build

From the trace it appears that stackalloc is being
called with 0x1800 which is 6k = 4k + (StackSystem=2k).
Make StackSystem 4k too, to make stackalloc happy.
It's already 4k on windows/amd64.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/72600043

11 years agoliblink: fix morestack handling on amd64p32.
Rémy Oudompheng [Fri, 7 Mar 2014 18:44:35 +0000 (19:44 +0100)]
liblink: fix morestack handling on amd64p32.

It was using MOVL to pass a 64-bit argument
(concatenated framesize and argsize) to morestack11.

LGTM=dave, rsc
R=dave, rsc, iant
CC=golang-codereviews
https://golang.org/cl/72360044

11 years agoruntime: refactor and fix stack management code
Dmitriy Vyukov [Fri, 7 Mar 2014 16:52:29 +0000 (20:52 +0400)]
runtime: refactor and fix stack management code
There are at least 3 bugs:
1. g->stacksize accounting is broken during copystack/shrinkstack
2. stktop->free is not properly maintained during copystack/shrinkstack
3. stktop->free logic is broken:
        we can have stktop->free==FixedStack,
        and we will free it into stack cache,
        but it actually comes from heap as the result of non-copying segment shrink
This shows as at least spurious races on race builders (maybe something else as well I don't know).

The idea behind the refactoring is to consolidate stacksize and
segment origin logic in stackalloc/stackfree.

Fixes #7490.

LGTM=rsc, khr
R=golang-codereviews, rsc, khr
CC=golang-codereviews
https://golang.org/cl/72440043

11 years agoruntime: fix memory corruption and leak in recursive panic handling
Dmitriy Vyukov [Fri, 7 Mar 2014 16:50:30 +0000 (20:50 +0400)]
runtime: fix memory corruption and leak in recursive panic handling
Recursive panics leave dangling Panic structs in g->panic stack.
At best it leads to a Defer leak and incorrect output on a subsequent panic.
At worst it arbitrary corrupts heap.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72480043

11 years agoruntime: fix memory leak in runfinq
Russ Cox [Fri, 7 Mar 2014 16:27:01 +0000 (11:27 -0500)]
runtime: fix memory leak in runfinq

One reason the sync.Pool finalizer test can fail is that
this function's ef1 contains uninitialized data that just
happens to point at some of the old pool. I've seen this cause
retention of a single pool cache line (32 elements) on arm.

Really we need liveness information for C functions, but
for now we can be more careful about data in long-lived
C functions that block.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews, iant, khr
https://golang.org/cl/72490043

11 years agocmd/6a: add support for nacl/amd64p32
Dave Cheney [Fri, 7 Mar 2014 05:02:25 +0000 (16:02 +1100)]
cmd/6a: add support for nacl/amd64p32

Replaces CL 70000043.

Switch to the amd64p32 linker model if we are building under nacl/amd64p32.

No need to introduce linkarchinit() as 6a contains its own main() function.

LGTM=rsc
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/72020043

11 years agocmd/gc, cmd/5g, cmd/6g, cmd/8g: introduce linkarchinit and add amd64p32 support
Dave Cheney [Fri, 7 Mar 2014 04:33:44 +0000 (15:33 +1100)]
cmd/gc, cmd/5g, cmd/6g, cmd/8g: introduce linkarchinit and add amd64p32 support

Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6g, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/71330045

11 years agoencoding/gob: document that Decode returns EOF at EOF
Rob Pike [Fri, 7 Mar 2014 02:24:14 +0000 (13:24 +1100)]
encoding/gob: document that Decode returns EOF at EOF

Just commentary describing existing behavior, no code changes.

Fixes #7033.

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

11 years agostrconv: document value returned by ParseInt when there is an error
Rob Pike [Fri, 7 Mar 2014 02:23:50 +0000 (13:23 +1100)]
strconv: document value returned by ParseInt when there is an error
Documenting existing behavior; new commentary only.
Fixes #7105.

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

11 years agospec: clarify when constant slice indices must be in range
Robert Griesemer [Fri, 7 Mar 2014 01:11:13 +0000 (17:11 -0800)]
spec: clarify when constant slice indices must be in range

This documents the status quo for most implementations,
with one exception: gc generates a run-time error for
constant but out-of-range indices when slicing a constant
string. See issue 7200 for a detailed discussion.

LGTM=r
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/72160044

11 years agoruntime: shrink bigger stacks without any copying.
Keith Randall [Fri, 7 Mar 2014 00:03:43 +0000 (16:03 -0800)]
runtime: shrink bigger stacks without any copying.

Instead, split the underlying storage in half and
free just half of it.

Shrinking without copying lets us reclaim storage used
by a previously profligate Go routine that has now blocked
inside some C code.

To shrink in place, we need all stacks to be a power of 2 in size.

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

11 years agocmd/go: add test case for cgo coverage
Russ Cox [Thu, 6 Mar 2014 23:36:32 +0000 (18:36 -0500)]
cmd/go: add test case for cgo coverage

This is a test case for CL 34680044.

Fixes #6333.

LGTM=bradfitz
R=golang-codereviews, bradfitz, minux.ma
CC=golang-codereviews
https://golang.org/cl/71230049

11 years agoruntime: fix malloc page alignment + efence
Russ Cox [Thu, 6 Mar 2014 23:34:29 +0000 (18:34 -0500)]
runtime: fix malloc page alignment + efence

Two memory allocator bug fixes.

- efence is not maintaining the proper heap metadata
  to make eventual memory reuse safe, so use SysFault.

- now that our heap PageSize is 8k but most hardware
  uses 4k pages, SysAlloc and SysReserve results must be
  explicitly aligned. Do that in a few more call sites and
  document this fact in malloc.h.

Fixes #7448.

LGTM=iant
R=golang-codereviews, josharian, iant
CC=dvyukov, golang-codereviews
https://golang.org/cl/71750048

11 years agocmd/5c: fix arm build
Dave Cheney [Thu, 6 Mar 2014 23:13:00 +0000 (10:13 +1100)]
cmd/5c: fix arm build

cmd/5c/txt.c was missing from CL 72010043.

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

11 years agocmd/cc, cmd/5c, cmd/6c, cmd/8c: introduce linkarchinit and add amd64p32 support
Dave Cheney [Thu, 6 Mar 2014 22:55:59 +0000 (09:55 +1100)]
cmd/cc, cmd/5c, cmd/6c, cmd/8c: introduce linkarchinit and add amd64p32 support

Replaces CL 70000043.

Introduce linkarchinit() from cmd/ld.

For cmd/6c, switch to the amd64p32 linker model if we are building under nacl/amd64p32.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/72010043

11 years agoruntime: print goroutine header on fault
Dmitriy Vyukov [Thu, 6 Mar 2014 20:01:24 +0000 (00:01 +0400)]
runtime: print goroutine header on fault
I've just needed the G status on fault to debug runtime bug.
For some reason we print everything except header here.
Make it more informative and consistent.

R=rsc
CC=golang-codereviews
https://golang.org/cl/67870056