Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime/race: Race detector does not detect len(c) / {send,recv}(c) race #11067

Closed
randall77 opened this issue Jun 4, 2015 · 2 comments
Closed

Comments

@randall77
Copy link
Contributor

The race detector should report a race when one goroutine is reading the length of a channel and another is reading or writing to the channel.

func main() {
    res := make(chan int, 1)
    ch := make(chan bool, 1)
    go func() { ch <- true }()
    go func() { res <- len(ch) }()
    fmt.Println(<-res)
}

@dvyukov

@randall77 randall77 added this to the Go1.6 milestone Jun 4, 2015
@bradfitz
Copy link
Contributor

bradfitz commented Jun 4, 2015

@mikioh mikioh changed the title Race detector does not detect len(c) / {send,recv}(c) race runtime/race: Race detector does not detect len(c) / {send,recv}(c) race Jun 4, 2015
@dvyukov
Copy link
Member

dvyukov commented Jun 4, 2015

http://golang.org/ref/spec#Channel_types

A single channel may be used in send statements, receive operations, and calls to the built-in functions cap and len by any number of goroutines without further synchronization.

@dvyukov dvyukov closed this as completed Jun 4, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
@rsc rsc unassigned dvyukov Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants