Ian Lance Taylor [Wed, 17 Dec 2014 16:52:59 +0000 (08:52 -0800)]
test: add bug494: test case miscompiled by gccgo
Gccgo incorrectly executed functions multiple times when they appeared
in a composite literal that required a conversion between different
interface types.
Kato Kazuyoshi [Tue, 16 Dec 2014 16:22:17 +0000 (08:22 -0800)]
os: handle the sticky bit separately for *BSD and Solaris
open(2) and mkdir(2) won't set the sticky bit on *BSD and Solaris.
This behavior is mentioned on sticky(8).
see also: https://github.com/dotcloud/docker/pull/6587
Fixes #8383.
Change-Id: Ic4733700f9926b9fc2b6fd1f998acec34e518764
Reviewed-on: https://go-review.googlesource.com/1673 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Tue, 16 Dec 2014 23:53:41 +0000 (15:53 -0800)]
test: add test that gccgo failed to compile
Gccgo failed to create the type descriptor for the type used to
allocate the nil value passed to append as the second argument when
append is called with only one argument. Calling append with only one
argument is unusual but obviously should not cause a compiler crash.
Keith Randall [Mon, 15 Dec 2014 22:39:28 +0000 (14:39 -0800)]
runtime: fix deadlock in runtime.Stack
It shouldn't semacquire() inside an acquirem(), the runtime
thinks that means deadlock. It actually isn't a deadlock, but it
looks like it because acquirem() does m.locks++.
Candidate for inclusion in 1.4.1. runtime.Stack with all=true
is pretty unuseable in GOMAXPROCS>1 environment.
Brad Fitzpatrick [Tue, 16 Dec 2014 06:47:55 +0000 (17:47 +1100)]
net/http/httputil: don't use DisableKeepAlives in DumpRequestOut, fix build
I broke the build in https://golang.org/change/207950a when I made
http.Transport send "Connection: close" request headers when
DisableKeepAlives was set true because I didn't run all the tests
before submitting.
httputil.DumpRequestOut used Transport to get its output, and used it
with DisableKeepAlives, so this changed the output.
Rather than updating golden data in our tests (because surely others
depend on the exact bytes from these in their tests), switch to not
using DisableKeepAlives in DumpRequestOut instead, so the output is
the same as before.
Change-Id: I9fad190be8032e55872e6947802055a6d65244df
Reviewed-on: https://go-review.googlesource.com/1632 Reviewed-by: Andrew Gerrand <adg@golang.org>
Brad Fitzpatrick [Tue, 16 Dec 2014 04:11:43 +0000 (15:11 +1100)]
crypto/rand: handle EAGAIN reads from /dev/urandom
Fixes #9205
Change-Id: Iacd608ba43332008984aa8ece17dcb5757f27b3f
Reviewed-on: https://go-review.googlesource.com/1611 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Wed, 10 Dec 2014 15:45:59 +0000 (10:45 -0500)]
build: change all.bash output to be more markdown-friendly
People keep pasting all.bash output into GitHub bugs, which turns
the # lines into <h1> headlines. Add some more #s so that the
bug reports are more readable. Not ideal but seems like the best
of a few bad options.
Change-Id: I4c69930ec304b2d504d7cd66221281a8577b87ae
Reviewed-on: https://go-review.googlesource.com/1286 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
Russ Cox [Tue, 9 Dec 2014 15:15:18 +0000 (10:15 -0500)]
cmd/gc: add //go:nowritebarrier to diagnose unintended write barriers
//go:nowritebarrier can only be used in package runtime.
It does not disable write barriers; it is an assertion, checked
by the compiler, that the following function needs no write
barriers.
Change-Id: Id7978b779b66dc1feea39ee6bda9fd4d80280b7c
Reviewed-on: https://go-review.googlesource.com/1224 Reviewed-by: Rick Hudson <rlh@golang.org>
Russ Cox [Fri, 5 Dec 2014 19:04:17 +0000 (14:04 -0500)]
[release-branch.go1.4] cmd/api: make API check fail for undeclared API in release branch
We forgot to do the usual API review.
Make that not possible in the future.
I'll pull this change over to the main
branch too, but it's more important
(and only testable) here.
David Crawshaw [Wed, 10 Dec 2014 14:29:24 +0000 (09:29 -0500)]
runtime: send android stderr to /dev/log/main
I tried to submit this in Go 1.4 as cl/107540044 but tripped over the
changes for getting C off the G stack. This is a rewritten version that
avoids cgo and works directly with the underlying log device.
Change-Id: I14c227dbb4202690c2c67c5a613d6c6689a6662a
Reviewed-on: https://go-review.googlesource.com/1285 Reviewed-by: Keith Randall <khr@golang.org>
Austin Clements [Tue, 9 Dec 2014 17:31:11 +0000 (12:31 -0500)]
runtime: restore error message on early needm
needm used to print an error before exiting when it was called too
early, but this error was lost in the transition to Go. Bring back
the error so we don't silently exit(1) when this happens.
Shenghou Ma [Tue, 9 Dec 2014 05:13:10 +0000 (00:13 -0500)]
test/fixedbugs/bug302: fix test on windows.
Change-Id: I74c2578d1620b37a6486eca00a774b9a736a8899
Reviewed-on: https://go-review.googlesource.com/1222 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Griesemer [Mon, 8 Dec 2014 19:20:41 +0000 (11:20 -0800)]
test/fibo: a stand-alone bignum/allocation benchmark and test
Usage:
fibo <n> compute fibonacci(n), n must be >= 0
fibo -bench benchmark fibonacci computation (takes about 1 min)
Additional flags:
-half add values using two half-digit additions
-opt optimize memory allocation through reuse
-short only print the first 10 digits of very large fibonacci numbers
This change was reviewed in detail as https://codereview.appspot.com/168480043 .
Austin Clements [Mon, 8 Dec 2014 16:12:33 +0000 (11:12 -0500)]
runtime: fix missing newline when dumping bad symbol table
If the symbol table isn't sorted, we print it and abort. However, we
were missing the line break after each symbol, resulting in one
gigantic line instead of a nicely formatted table.
Russ Cox [Sat, 6 Dec 2014 01:34:45 +0000 (20:34 -0500)]
all: merge dev.garbage (d1238958d4ae) into default branch
When we start work on Gerrit, ppc64 and garbage collection
work will continue in the master branch, not the dev branches.
(We may still use dev branches for other things later, but
these are ready to be merged, and doing it now, before moving
to Git means we don't have to have dev branches working
in the Gerrit workflow on day one.)
With this change, default now contains Go 1.5 work.
Any future bug fixes for Go 1.4 in the compilers or
the runtime will have to be made directly to the
release branch.
Austin Clements [Fri, 5 Dec 2014 14:24:01 +0000 (09:24 -0500)]
[dev.cc] liblink: don't patch jumps to jumps to symbols
When liblink sees something like
JMP x
...
x: JMP y
it rewrites the first jump to jump directly to y. This is
fine if y is a resolved label. However, it *also* does this
if y is a function symbol, but fails to carry over the
relocation that would later patch in that symbol's value. As
a result, the original jump becomes either a self-jump (if
relative) or a jump to PC 0 (if absolute).
Fix this by disabling this optimization if the jump being
patched in is a jump to a symbol.
Shenghou Ma [Fri, 5 Dec 2014 07:22:20 +0000 (02:22 -0500)]
[dev.cc] cmd/ld: finalize linkmode before determining whether to import runtime/cgo
Frankly, I don't understand how the current code could possibly work except
when every android program is using cgo. Discovered this while working on
the iOS port.
Rob Pike [Fri, 5 Dec 2014 00:15:38 +0000 (09:15 +0900)]
cmd/go: avoid use of bufio.Scanner in generate
Scanner can't handle stupid long lines and there are
reports of stupid long lines in production.
Note the issue isn't long "//go:generate" lines, but
any long line in any Go source file.
To be fair, if you're going to have a stupid long line
it's not a bad bet you'll want to run it through go
generate, because it's some embeddable asset that
has been machine generated. (One could ask why
that generation process didn't add a newline or two,
but we should cope anyway.)
Rewrite the file scanner in "go generate" so it can
handle arbitrarily long lines, and only stores in memory
those lines that start "//go:generate".
Also: Adjust the documentation to make clear that it
does not parse the file.
Russ Cox [Mon, 1 Dec 2014 21:32:06 +0000 (16:32 -0500)]
runtime: fix hang in GC due to shrinkstack vs netpoll race
During garbage collection, after scanning a stack, we think about
shrinking it to reclaim some memory. The shrinking code (called
while the world is stopped) checked that the status was Gwaiting
or Grunnable and then changed the state to Gcopystack, to essentially
lock the stack so that no other GC thread is scanning it.
The same locking happens for stack growth (and is more necessary there).
oldstatus = runtime·readgstatus(gp);
oldstatus &= ~Gscan;
if(oldstatus == Gwaiting || oldstatus == Grunnable)
runtime·casgstatus(gp, oldstatus, Gcopystack); // oldstatus is Gwaiting or Grunnable
else
runtime·throw("copystack: bad status, not Gwaiting or Grunnable");
Unfortunately, "stop the world" doesn't stop everything. It stops all
normal goroutine execution, but the network polling thread is still
blocked in epoll and may wake up. If it does, and it chooses a goroutine
to mark runnable, and that goroutine is the one whose stack is shrinking,
then it can happen that between readgstatus and casgstatus, the status
changes from Gwaiting to Grunnable.
casgstatus assumes that if the status is not what is expected, it is a
transient change (like from Gwaiting to Gscanwaiting and back, or like
from Gwaiting to Gcopystack and back), and it loops until the status
has been restored to the expected value. In this case, the status has
changed semi-permanently from Gwaiting to Grunnable - it won't
change again until the GC is done and the world can continue, but the
GC is waiting for the status to change back. This wedges the program.
To fix, call a special variant of casgstatus that accepts either Gwaiting
or Grunnable as valid statuses.
Without the fix bug with the extra check+throw in casgstatus, the
program below dies in a few seconds (2-10) with GOMAXPROCS=8
on a 2012 Retina MacBook Pro. With the fix, it runs for minutes
and minutes.
package main
import (
"io"
"log"
"net"
"runtime"
)
func main() {
const N = 100
for i := 0; i < N; i++ {
l, err := net.Listen("tcp", "127.0.0.1:0")
if err != nil {
log.Fatal(err)
}
ch := make(chan net.Conn, 1)
go func() {
var err error
c1, err := net.Dial("tcp", l.Addr().String())
if err != nil {
log.Fatal(err)
}
ch <- c1
}()
c2, err := l.Accept()
if err != nil {
log.Fatal(err)
}
c1 := <-ch
l.Close()
go netguy(c1, c2)
go netguy(c2, c1)
c1.Write(make([]byte, 100))
}
for {
runtime.GC()
}
}
func netguy(r, w net.Conn) {
buf := make([]byte, 100)
for {
bigstack(1000)
_, err := io.ReadFull(r, buf)
if err != nil {
log.Fatal(err)
}
w.Write(buf)
}
}
var g int
func bigstack(n int) {
var buf [100]byte
if n > 0 {
bigstack(n - 1)
}
g = int(buf[0]) + int(buf[99])
}
Fixes #9186.
LGTM=rlh
R=austin, rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/179680043