1
0
mirror of https://github.com/golang/go synced 2024-10-01 13:18:33 -06:00
Commit Graph

21392 Commits

Author SHA1 Message Date
Rob Pike
dd26fc3822 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.

Fixes #9143.
Fixes #9196.

LGTM=rsc, dominik.honnef
R=rsc, cespare, minux, dominik.honnef
CC=golang-codereviews
https://golang.org/cl/182970043
2014-12-05 09:15:38 +09:00
Shenghou Ma
c9d0c81214 cmd/pprof/internal/commands: add command to open browser on windows
While we're at there, also add a message to prompt the user to install
Graphviz if "dot" command is not found.

Fixes #9178.

LGTM=adg, alex.brainman, cookieo9, rsc
R=rsc, adg, bradfitz, alex.brainman, cookieo9, smyrman
CC=golang-codereviews
https://golang.org/cl/180380043
2014-12-04 11:24:23 -05:00
Rob Pike
b2950a2931 lib/time: update to ICANN time zone database 2014j
Fixes #9189.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews
https://golang.org/cl/178660043
2014-12-03 20:07:48 -08:00
David Symonds
583b29cb18 spec: add comment marker for consistency.
LGTM=r
R=gri, r
CC=golang-codereviews
https://golang.org/cl/185830043
2014-12-04 09:29:29 +11:00
Russ Cox
9f04a62a39 cmd/pprof: fix symbol resolution for remote profiles
Fixes #9199.

LGTM=iant
R=golang-codereviews, iant
CC=austin, golang-codereviews, minux
https://golang.org/cl/183080043
2014-12-03 14:14:00 -05:00
Dominik Honnef
14948481f6 cmd/go: regenerate doc.go
Move change from CL 170770043 to correct file and regenerate docs
for changes from CL 164120043.

LGTM=adg
R=golang-codereviews, adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/183000043
2014-12-03 10:28:54 +11:00
Andrew Gerrand
ce5d7cffe8 tag go1.4rc2
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/178600043
2014-12-02 14:39:23 +11:00
Russ Cox
2b62e1eaec 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
2014-12-01 16:32:06 -05:00
Keith Randall
7c1e33033d reflect: Fix reflect.funcLayout. The GC bitmap has two bits per
pointer, not one.

Fixes #9179

LGTM=iant, rsc
R=golang-codereviews, iant, rsc
CC=golang-codereviews
https://golang.org/cl/182160043
2014-12-01 07:52:09 -08:00
Austin Clements
6f755f2f8f [dev.cc] 9l: make R_CALLPOWER like ELF's R_PPC64_REL24
These accomplished the same thing, but R_CALLPOWER expected
the whole instruction to be in the addend (and completely
overwrote what was in the text section), while R_PPC64_REL24
overwrites only bits 6 through 24 of whatever was in the text
section.  Make R_CALLPOWER work like R_PPC64_REL24 to ease the
implementation of dynamic linking.

LGTM=rsc
R=rsc
CC=golang-codereviews, minux
https://golang.org/cl/177430043
2014-11-25 16:00:25 -05:00
David du Colombier
c8af6de2e8 [dev.cc] cmd/5g,cmd/6g,cmd/9g: fix warnings on Plan 9
warning: src/cmd/5g/reg.c:461 format mismatch d VLONG, arg 5
warning: src/cmd/6g/reg.c:396 format mismatch d VLONG, arg 5
warning: src/cmd/9g/reg.c:440 format mismatch d VLONG, arg 5

LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/179300043
2014-11-25 08:42:00 +01:00
Andrew Gerrand
c1374b5c78 doc: tidy up "Projects" page; add Go 1.4
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/182750043
2014-11-25 15:41:33 +11:00
Russ Cox
355f25305b go/build: build $GOOS_test.go always
We decided to build $GOOS.go always
but forgot to test $GOOS_test.go.

Fixes #9159.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/176290043
2014-11-24 20:18:44 -05:00
Russ Cox
b8540fc288 [dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbage
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179290043
2014-11-24 12:07:11 -05:00
Austin Clements
ed5488eece [dev.cc] 9g: peephole optimizer
This was based on the 9c peephole optimizer, modified to work
with code generated by gc and use the proginfo infrastructure
in gc.

LGTM=rsc
R=rsc, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/179190043
2014-11-24 11:42:15 -05:00
Austin Clements
e78777ebfe [dev.cc] 9g: fill progtable for CC, V, and VCC instruction variants
This adds some utilities for converting between the CC, V, and
VCC variants of operations and uses these to derive the
ProgInfo entries for these variants (which are identical to
the ProgInfo for the base operations).

The 9g peephole optimizer will also use these conversion
utilities.

LGTM=minux, rsc
R=rsc, dave, minux
CC=golang-codereviews
https://golang.org/cl/180110044
2014-11-24 11:40:36 -05:00
Joel Sing
6ddc2cb80c [dev.cc] runtime: convert dragonfly/386 port to Go
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/178210043
2014-11-25 03:15:11 +11:00
Russ Cox
a236804c76 [dev.cc] all: merge default (95f5614b4648) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/177220044
2014-11-23 15:13:48 -05:00
Russ Cox
04923042bd image/jpeg: handle Read returning n > 0, err != nil in d.fill
Fixes #9127.

LGTM=r
R=bradfitz, r
CC=golang-codereviews, nigeltao
https://golang.org/cl/178120043
2014-11-22 13:55:33 -05:00
Shenghou Ma
8cda58c25e cmd/go: fix running pprof on windows.
Fixes #9149.

LGTM=alex.brainman, rsc
R=rsc, dave, alex.brainman
CC=golang-codereviews
https://golang.org/cl/176170043
2014-11-22 13:37:46 -05:00
Joel Sing
0d76887433 [dev.cc] runtime: convert netbsd/386 port to Go
LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/177170043
2014-11-22 22:09:11 +11:00
Joel Sing
cfc8099a9a [dev.cc] runtime: convert netbsd/amd64 port to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/169620043
2014-11-22 16:05:31 +11:00
Shenghou Ma
d3526ea0f6 [dev.cc] runtime: migrate Android/ARM port to Go.
I tested building Go itself, but not any of go.mobile tests.

LGTM=crawshaw
R=crawshaw, rsc
CC=golang-codereviews
https://golang.org/cl/179110043
2014-11-21 18:15:30 -05:00
Shenghou Ma
adbca13cb3 [dev.cc] runtime: explicitly exclude android in zgoos_linux.go
Otherwise both zgoos_linux.go and zgoos_android.go will be compiled
for GOOS=android.

LGTM=crawshaw, rsc
R=rsc, crawshaw
CC=golang-codereviews
https://golang.org/cl/178110043
2014-11-21 18:13:59 -05:00
Rick Hudson
273507aa8f [dev.garbage] runtime: Stop running gs during the GCscan phase.
Ensure that all gs are in a scan state when their stacks are being scanned.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179160044
2014-11-21 16:46:27 -05:00
Austin Clements
cabc555326 [dev.cc] liblink: more docs on Prog and Addr fields
LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/174530043
2014-11-21 15:58:29 -05:00
Austin Clements
ee853dacf5 [dev.cc] 9g: correct bad proginfo for ADUFFZERO and ADUFFCOPY
LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/176130044
2014-11-21 15:58:01 -05:00
Russ Cox
8c3f64022a [dev.garbage] runtime: add prefetcht0, prefetcht1, prefetcht2, prefetcht3, prefetchnta for GC
We don't know what we need yet, so add them all.
Add them even on x86 architectures (as no-ops) so that
the GC can refer to them unconditionally.

Eventually we'll know what we want and probably
have just one 'prefetch' with an appropriate meaning
on each architecture.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/179160043
2014-11-21 15:57:10 -05:00
David du Colombier
2f28916f02 [dev.cc] liblink: fix warnings on Plan 9
warning: src/liblink/list6.c:94 set and not used: s
warning: src/liblink/list6.c:157 format mismatch ld VLONG, arg 3
warning: src/liblink/list6.c:157 format mismatch E UINT, arg 4
warning: src/liblink/list6.c:157 format mismatch d VLONG, arg 5
warning: src/liblink/list6.c:163 set and not used: s
warning: src/liblink/list9.c:105 set and not used: s
warning: src/liblink/list9.c:185 format mismatch ld VLONG, arg 3
warning: src/liblink/list9.c:185 format mismatch E UINT, arg 4
warning: src/liblink/list9.c:185 format mismatch d VLONG, arg 5
warning: src/liblink/list9.c:193 set and not used: s

LGTM=rsc
R=rsc
CC=austin, golang-codereviews, minux
https://golang.org/cl/176130043
2014-11-21 20:56:33 +01:00
David du Colombier
213a6645ce [dev.cc] cmd/8g: fix warning on Plan 9
warning: /usr/go/src/cmd/8g/reg.c:365 format mismatch d VLONG, arg 5

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/177160043
2014-11-21 20:44:04 +01:00
David du Colombier
e9c57d8a2d [dev.cc] runtime: convert Plan 9 port to Go
Thanks to Aram Hăvărneanu, Nick Owens
and Russ Cox for the early reviews.

LGTM=aram, rsc
R=rsc, lucio.dere, aram, ality
CC=golang-codereviews, mischief
https://golang.org/cl/175370043
2014-11-21 19:39:01 +01:00
Russ Cox
ad8179281d [dev.cc] runtime: convert nacl support to Go
LGTM=dave
R=minux, dave
CC=golang-codereviews
https://golang.org/cl/181030043
2014-11-21 10:22:18 -05:00
Russ Cox
ce3e8e4edc [dev.cc] build: skip API checks on Windows too (not just Unix)
TBR=brainman
CC=golang-codereviews
https://golang.org/cl/175490043
2014-11-21 00:21:49 -05:00
Alex Brainman
841de809bb [dev.cc] runtime: windows does not use _cgo_setenv and _cgo_unsetenv
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175480043
2014-11-21 15:59:22 +11:00
Alex Brainman
0a38b2cdaf [dev.cc] runtime: fix windows goenvs conversion mistake
uint16 occupies 2 bytes, not 1

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/178100043
2014-11-21 12:15:18 +11:00
Austin Clements
7b596457d1 [dev.cc] liblink: fix Solaris build some more
a->name and a->class are char, so Solaris doesn't like using
them as array indexes.  (This same problem was fixed for amd64
in CL 169630043.)

LGTM=aram, minux
R=rsc, minux, aram
CC=golang-codereviews
https://golang.org/cl/175430043
2014-11-20 14:28:54 -05:00
Rick Hudson
cc73a44f67 [dev.garbage] runtime: Fix constant overflow on 32 bit machines
LGTM=rsc
R=golang-codereviews
CC=golang-codereviews, rsc
https://golang.org/cl/180040043
2014-11-20 14:24:01 -05:00
Robert Griesemer
e538770d4b go/parser: Use test-specific filesets to avoid races.
Only affects test code.

Fixes #9025.
Fixes #9130.

LGTM=r, adonovan
R=adonovan, r
CC=golang-codereviews
https://golang.org/cl/180920043
2014-11-20 09:35:22 -08:00
Rick Hudson
8cfb084534 [dev.garbage] runtime: Turn concurrent GC on by default. Avoid write barriers for GC internal structures such as free lists.
LGTM=rsc
R=rsc
CC=golang-codereviews, rsc
https://golang.org/cl/179000043
2014-11-20 12:08:13 -05:00
Russ Cox
50e0749f87 [dev.cc] all: merge default (e4ab8f908aac) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179040044
2014-11-20 11:48:08 -05:00
Russ Cox
754de8d403 [dev.cc] all: merge dev.power64 (f57928630b36) into dev.cc
This will be the last dev.power64 merge; we'll finish on dev.cc.

TBR=austin
CC=golang-codereviews
https://golang.org/cl/175420043
2014-11-20 11:30:43 -05:00
Dmitriy Vyukov
2b3f379080 runtime: fix atomic operations on non-heap addresses
Race detector runtime does not tolerate operations on addresses
that was not previously declared with __tsan_map_shadow
(namely, data, bss and heap). The corresponding address
checks for atomic operations were removed in
https://golang.org/cl/111310044
Restore these checks.
It's tricker than just not calling into race runtime,
because it is the race runtime that makes the atomic
operations themselves (if we do not call into race runtime
we skip the atomic operation itself as well). So instead we call
__tsan_go_ignore_sync_start/end around the atomic operation.
This forces race runtime to skip all other processing
except than doing the atomic operation itself.
Fixes #9136.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179030043
2014-11-20 09:51:02 -05:00
Russ Cox
361199749d build: disable race external linking test on OS X 10.6 and earlier
External linking doesn't work there at all.

LGTM=bradfitz
R=adg, bradfitz
CC=golang-codereviews
https://golang.org/cl/176070043
2014-11-19 20:52:58 -05:00
Alex Brainman
ab4578adef [dev.cc] runtime: convert remaining windows C code to Go
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/177090043
2014-11-20 12:24:03 +11:00
Russ Cox
378c2515ae runtime: remove assumption that noptrdata data bss noptrbss are ordered and contiguous
The assumption can be violated by external linkers reordering them or
inserting non-Go sections in between them. I looked briefly at trying
to write out the _go_.o in external linking mode in a way that forced
the ordering, but no matter what there's no way to force Go's data
and Go's bss to be next to each other. If there is any data or bss from
non-Go objects, it's very likely to get stuck in between them.

Instead, rewrite the two places we know about that make the assumption.
I grepped for noptrdata to look for more and didn't find any.

The added race test (os/exec in external linking mode) fails without
the changes in the runtime. It crashes with an invalid pointer dereference.

Fixes #9133.

LGTM=dneil
R=dneil
CC=dvyukov, golang-codereviews, iant
https://golang.org/cl/179980043
2014-11-19 15:25:33 -05:00
Austin Clements
f4a525452e [dev.cc] runtime: add explicit siginfo.si_addr field
struct siginfo_t's si_addr field is part of a union.
Previously, we represented this union in Go using an opaque
byte array and accessed the si_addr field using unsafe (and
wrong on 386 and arm!) pointer arithmetic.  Since si_addr is
the only field we use from this union, this replaces the
opaque byte array with an explicit declaration of the si_addr
field and accesses it directly.

LGTM=minux, rsc
R=rsc, minux
CC=golang-codereviews
https://golang.org/cl/179970044
2014-11-19 14:56:49 -05:00
Austin Clements
d11a425959 [dev.cc] runtime: decode power64 branch instructions the way the CPU does
Previously, this used the top 8 bits of an instruction as a
sort-of opcode and ignored the top two bits of the relative
PC.  This worked because these jumps are always negative and
never big enough for the top two bits of the relative PC (also
the bottom 2 bits of the sort-of opcode) to be anything other
than 0b11, but the code is confusing because it doesn't match
the actual structure of the instruction.

Instead, use the real 6 bit opcode and use all 24 bits of
relative PC.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/179960043
2014-11-19 14:24:41 -05:00
Russ Cox
2d53d6b5d5 undo CL 131750044 / 2d6d44ceb80e
Breaks reading from stdin in parent after exec with SysProcAttr{Setpgid: true}.

package main

import (
        "fmt"
        "os"
        "os/exec"
        "syscall"
)

func main() {
        cmd := exec.Command("true")
        cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
        cmd.Run()

        fmt.Printf("Hit enter:")
        os.Stdin.Read(make([]byte, 100))
        fmt.Printf("Bye\n")
}

In go1.3, I type enter at the prompt and the program exits.
With the CL being rolled back, the program wedges at the
prompt.

««« original CL description
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

»»»

LGTM=minux, dneil
R=dneil, minux
CC=golang-codereviews, iant, michael.p.macinnis
https://golang.org/cl/174450043
2014-11-19 14:16:12 -05:00
Austin Clements
b76e836042 [dev.cc] runtime: allow more address bits in lfstack on Power64
Previously, lfstack assumed Linux limited user space addresses
to 43 bits on Power64 based on a paper from 2001.  It turns
out the limit is now 46 bits, so lfstack was truncating
pointers.

Raise the limit to 48 bits (for some future proofing and to
make it match amd64) and add a self-test that will fail in a
useful way if ever unpack(pack(x)) != x.

With this change, dev.cc passes all.bash on power64le.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/174430043
2014-11-19 11:30:58 -05:00
Alex Brainman
b27c0618eb [dev.cc] runtime: update sys_windows_386.s and sys_windows_amd64.s for Go conversion
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/176970043
2014-11-19 11:55:15 +11:00