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 issue 7410.

LGTM=dvyukov, iant
R=golang-codereviews, bradfitz, iant, dvyukov, aram.h, gobot
CC=golang-codereviews
https://codereview.appspot.com/69190044

Committer: Dmitriy Vyukov <dvyukov@google.com>
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 issue 7493

LGTM=aram, rsc
R=aram, rsc, gobot, iant
CC=golang-codereviews
https://codereview.appspot.com/72280043
cmd/gc: fix spurious 'not enough arguments to return' error

Fixes issue 6405

LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://codereview.appspot.com/72920046
cmd/go: fix invalid go pack command line in the output of go build -x

Fixes issue 7262

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/76110043
runtime: do not shrink stacks GOCOPYSTACK=0

LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, khr, rsc
https://codereview.appspot.com/76070043
runtime: fix a race in bgsweep
See the comment for description.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/75670044
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://codereview.appspot.com/75820045
cmd/6g, runtime: alignment fixes for amd64p32.

LGTM=rsc
R=rsc, dave, iant, khr
CC=golang-codereviews
https://codereview.appspot.com/75820044
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 issue 7544.

R=golang-codereviews, rsc
CC=golang-codereviews, khr
https://codereview.appspot.com/76160043
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://codereview.appspot.com/75940043
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://codereview.appspot.com/76050044
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://codereview.appspot.com/76250043
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://codereview.appspot.com/75900043
cmd/gc: fix comment about how GOEXPERIMENT works

LGTM=minux.ma
R=golang-codereviews, minux.ma
CC=golang-codereviews
https://codereview.appspot.com/76270043
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://codereview.appspot.com/74370043

Committer: Andrew Gerrand <adg@golang.org>
C: add Rui Ueyama (Google CLA)

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://codereview.appspot.com/76930044
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://codereview.appspot.com/74660045

Committer: Brad Fitzpatrick <bradfitz@golang.org>
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://codereview.appspot.com/76760043

Committer: Brad Fitzpatrick <bradfitz@golang.org>
C: add Catalin Patulea (Google CLA)

LGTM=iant
R=iant
CC=golang-codereviews
https://codereview.appspot.com/76400044
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://codereview.appspot.com/76800043

Committer: Brad Fitzpatrick <bradfitz@golang.org>