Skip to content

runtime/race: race detector misses when copying into an interface #12664

@jbardin

Description

@jbardin

The following is missed by the race detector

var (
    a = "hi"
    c = make(chan struct{})
)

func f() {
    a = "bye"
    close(c)
}

func main() {
    go f()
    fmt.Println(a)
    // fmt.Printf(a)
    <-c
}

But changing the fmt call to fmt.Printf where the a value is copied into the format string triggers a race

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions