mirror of
https://github.com/golang/go
synced 2024-11-21 18:44:45 -07:00
runtime: select bug
The sanity checking in pass 2 is wrong when a select is offering to communicate in either direction on a channel and neither case is immediately ready. R=ken2 CC=golang-dev https://golang.org/cl/3991047
This commit is contained in:
parent
4608feb18b
commit
504da53c85
@ -732,25 +732,12 @@ loop:
|
||||
|
||||
switch(cas->send) {
|
||||
case 0: // recv
|
||||
if(c->dataqsiz > 0) {
|
||||
if(c->qcount > 0)
|
||||
runtime·throw("select: pass 2 async recv");
|
||||
} else {
|
||||
if(dequeue(&c->sendq, c))
|
||||
runtime·throw("select: pass 2 sync recv");
|
||||
}
|
||||
enqueue(&c->recvq, sg);
|
||||
break;
|
||||
|
||||
case 1: // send
|
||||
if(c->dataqsiz > 0) {
|
||||
if(c->qcount < c->dataqsiz)
|
||||
runtime·throw("select: pass 2 async send");
|
||||
} else {
|
||||
if(dequeue(&c->recvq, c))
|
||||
runtime·throw("select: pass 2 sync send");
|
||||
if(c->dataqsiz == 0)
|
||||
c->elemalg->copy(c->elemsize, sg->elem, cas->u.elem);
|
||||
}
|
||||
enqueue(&c->sendq, sg);
|
||||
break;
|
||||
}
|
||||
|
@ -196,4 +196,13 @@ func main() {
|
||||
case closedch <- 7:
|
||||
}
|
||||
})
|
||||
|
||||
// select should not get confused if it sees itself
|
||||
testBlock(always, func() {
|
||||
c := make(chan int)
|
||||
select {
|
||||
case c <- 1:
|
||||
case <-c:
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user