mirror of
https://github.com/golang/go.git
synced 2025-05-26 01:41:25 +00:00
runtime: document non-obvious requirement on sudog.elem
The channel code must not allow stack splits between when it assigns a potential stack pointer to sudog.elem (or sudog.selectdone) and when it makes the sudog visible to copystack by putting it on the g.waiting list. We do get this right everywhere, but add a comment about this subtlety for future eyes. Change-Id: I941da150437167acff37b0e56983c793f40fcf79 Reviewed-on: https://go-review.googlesource.com/19632 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:
parent
39f2bd737b
commit
1e91e2a25a
@ -203,6 +203,8 @@ func chansend(t *chantype, c *hchan, ep unsafe.Pointer, block bool, callerpc uin
|
|||||||
if t0 != 0 {
|
if t0 != 0 {
|
||||||
mysg.releasetime = -1
|
mysg.releasetime = -1
|
||||||
}
|
}
|
||||||
|
// No stack splits between assigning elem and enqueuing mysg
|
||||||
|
// on gp.waiting where copystack can find it.
|
||||||
mysg.elem = ep
|
mysg.elem = ep
|
||||||
mysg.waitlink = nil
|
mysg.waitlink = nil
|
||||||
mysg.g = gp
|
mysg.g = gp
|
||||||
@ -460,6 +462,8 @@ func chanrecv(t *chantype, c *hchan, ep unsafe.Pointer, block bool) (selected, r
|
|||||||
if t0 != 0 {
|
if t0 != 0 {
|
||||||
mysg.releasetime = -1
|
mysg.releasetime = -1
|
||||||
}
|
}
|
||||||
|
// No stack splits between assigning elem and enqueuing mysg
|
||||||
|
// on gp.waiting where copystack can find it.
|
||||||
mysg.elem = ep
|
mysg.elem = ep
|
||||||
mysg.waitlink = nil
|
mysg.waitlink = nil
|
||||||
gp.waiting = mysg
|
gp.waiting = mysg
|
||||||
|
@ -370,6 +370,8 @@ loop:
|
|||||||
sg.g = gp
|
sg.g = gp
|
||||||
// Note: selectdone is adjusted for stack copies in stack1.go:adjustsudogs
|
// Note: selectdone is adjusted for stack copies in stack1.go:adjustsudogs
|
||||||
sg.selectdone = (*uint32)(noescape(unsafe.Pointer(&done)))
|
sg.selectdone = (*uint32)(noescape(unsafe.Pointer(&done)))
|
||||||
|
// No stack splits between assigning elem and enqueuing
|
||||||
|
// sg on gp.waiting where copystack can find it.
|
||||||
sg.elem = cas.elem
|
sg.elem = cas.elem
|
||||||
sg.releasetime = 0
|
sg.releasetime = 0
|
||||||
if t0 != 0 {
|
if t0 != 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user