Skip to content

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

@randall77

Description

@randall77

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions