<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/go.git/src/runtime, branch dev.cc</title>
<subtitle>code.google.com: Obsolete (use go-git)
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/'/>
<entry>
<title>[dev.cc] all: merge default (8d42099cdc23) into dev.cc</title>
<updated>2014-12-05T16:18:10+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2014-12-05T16:18:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=6d3ba1914e289ed223f7bb69f34604c0e2ae5384'/>
<id>6d3ba1914e289ed223f7bb69f34604c0e2ae5384</id>
<content type='text'>
TBR=austin
CC=golang-codereviews
https://codereview.appspot.com/178700044
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
TBR=austin
CC=golang-codereviews
https://codereview.appspot.com/178700044
</pre>
</div>
</content>
</entry>
<entry>
<title>runtime: fix hang in GC due to shrinkstack vs netpoll race</title>
<updated>2014-12-01T21:32:06+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2014-12-01T21:32:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=329c8eb00165253162ba8932acca5677aa519e0d'/>
<id>329c8eb00165253162ba8932acca5677aa519e0d</id>
<content type='text'>
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 &amp;= ~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 &lt; 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 &lt;- c1
                }()
                c2, err := l.Accept()
                if err != nil {
                        log.Fatal(err)
                }
                c1 := &lt;-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 &gt; 0 {
                bigstack(n - 1)
        }
        g = int(buf[0]) + int(buf[99])
}

Fixes issue 9186.

LGTM=rlh
R=austin, rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://codereview.appspot.com/179680043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &amp;= ~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 &lt; 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 &lt;- c1
                }()
                c2, err := l.Accept()
                if err != nil {
                        log.Fatal(err)
                }
                c1 := &lt;-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 &gt; 0 {
                bigstack(n - 1)
        }
        g = int(buf[0]) + int(buf[99])
}

Fixes issue 9186.

LGTM=rlh
R=austin, rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://codereview.appspot.com/179680043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: convert dragonfly/386 port to Go</title>
<updated>2014-11-24T16:15:11+00:00</updated>
<author>
<name>Joel Sing</name>
<email>jsing@google.com</email>
</author>
<published>2014-11-24T16:15:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=da15dedfd028d08bb842c990d1195ff901d8b014'/>
<id>da15dedfd028d08bb842c990d1195ff901d8b014</id>
<content type='text'>
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/178210043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LGTM=rsc
R=rsc, bradfitz
CC=golang-codereviews
https://codereview.appspot.com/178210043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: convert netbsd/386 port to Go</title>
<updated>2014-11-22T11:09:11+00:00</updated>
<author>
<name>Joel Sing</name>
<email>jsing@google.com</email>
</author>
<published>2014-11-22T11:09:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=a2ad0eafc9de98075da0525d4d8c384658caacb8'/>
<id>a2ad0eafc9de98075da0525d4d8c384658caacb8</id>
<content type='text'>
LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://codereview.appspot.com/177170043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LGTM=minux
R=rsc, minux
CC=golang-codereviews
https://codereview.appspot.com/177170043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: convert netbsd/amd64 port to Go</title>
<updated>2014-11-22T05:05:31+00:00</updated>
<author>
<name>Joel Sing</name>
<email>jsing@google.com</email>
</author>
<published>2014-11-22T05:05:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=4834c71adef00d1de50d1e1e3565b37be8619098'/>
<id>4834c71adef00d1de50d1e1e3565b37be8619098</id>
<content type='text'>
LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/169620043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/169620043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: migrate Android/ARM port to Go.</title>
<updated>2014-11-21T23:15:30+00:00</updated>
<author>
<name>Shenghou Ma</name>
<email>minux@golang.org</email>
</author>
<published>2014-11-21T23:15:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=7d9f09fdbaa7610c4a63214470d253006f6b567a'/>
<id>7d9f09fdbaa7610c4a63214470d253006f6b567a</id>
<content type='text'>
I tested building Go itself, but not any of go.mobile tests.

LGTM=crawshaw
R=crawshaw, rsc
CC=golang-codereviews
https://codereview.appspot.com/179110043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I tested building Go itself, but not any of go.mobile tests.

LGTM=crawshaw
R=crawshaw, rsc
CC=golang-codereviews
https://codereview.appspot.com/179110043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: explicitly exclude android in zgoos_linux.go</title>
<updated>2014-11-21T23:13:59+00:00</updated>
<author>
<name>Shenghou Ma</name>
<email>minux@golang.org</email>
</author>
<published>2014-11-21T23:13:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=182a9190d718d14b05d0f523d90729478298a292'/>
<id>182a9190d718d14b05d0f523d90729478298a292</id>
<content type='text'>
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://codereview.appspot.com/178110043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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://codereview.appspot.com/178110043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: convert Plan 9 port to Go</title>
<updated>2014-11-21T18:39:01+00:00</updated>
<author>
<name>David du Colombier</name>
<email>0intro@gmail.com</email>
</author>
<published>2014-11-21T18:39:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=f5c70e8582808d3372d00cb44f87828b4855ddc7'/>
<id>f5c70e8582808d3372d00cb44f87828b4855ddc7</id>
<content type='text'>
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://codereview.appspot.com/175370043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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://codereview.appspot.com/175370043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: convert nacl support to Go</title>
<updated>2014-11-21T15:22:18+00:00</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2014-11-21T15:22:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=ecbbc98fca8ef53f6b63083a00372b0a5f38f420'/>
<id>ecbbc98fca8ef53f6b63083a00372b0a5f38f420</id>
<content type='text'>
LGTM=dave
R=minux, dave
CC=golang-codereviews
https://codereview.appspot.com/181030043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LGTM=dave
R=minux, dave
CC=golang-codereviews
https://codereview.appspot.com/181030043
</pre>
</div>
</content>
</entry>
<entry>
<title>[dev.cc] runtime: windows does not use _cgo_setenv and _cgo_unsetenv</title>
<updated>2014-11-21T04:59:22+00:00</updated>
<author>
<name>Alex Brainman</name>
<email>alex.brainman@gmail.com</email>
</author>
<published>2014-11-21T04:59:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go.git/commit/?id=42120900e85f74a44a0508a75f76d3160694e592'/>
<id>42120900e85f74a44a0508a75f76d3160694e592</id>
<content type='text'>
LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/175480043
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LGTM=rsc
R=rsc
CC=golang-codereviews
https://codereview.appspot.com/175480043
</pre>
</div>
</content>
</entry>
</feed>
