runtime: record channel in sudog

Given a G, there's currently no way to find the channel it's blocking
on. We'll need this information to fix a (probably theoretical) bug in
select and to implement concurrent stack shrinking, so record the
channel in the sudog.

For #12967.

Change-Id: If8fb63a140f1d07175818824d08c0ebeec2bdf66
Reviewed-on: https://go-review.googlesource.com/20035
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Austin Clements 2016-02-15 17:37:04 -05:00
parent d7cedc4b74
commit e4a95b6343
5 changed files with 13 additions and 2 deletions

View file

@ -215,13 +215,14 @@ type gobuf struct {
// selecttype.
type sudog struct {
g *g
selectdone *uint32
selectdone *uint32 // CAS to 1 to win select race (may point to stack)
next *sudog
prev *sudog
elem unsafe.Pointer // data element
elem unsafe.Pointer // data element (may point to stack)
releasetime int64
ticket uint32
waitlink *sudog // g.waiting list
c *hchan // channel
}
type gcstats struct {