Skip to content

Race Hazard in group.work() #4

Description

@JoeReid

The closure in the group.work() function in group.go has a race hazard sending to the channel inside the closure.
Link to code

For loops reuse the variables defined in their scope, meaning that the data available to a closure evoked in a go routine is not thread-safe.

Eg:

for ch, _ := range g.members {
            go func() 
                // ch not safe to use here
            }()
        }

Either taking a copy of the variable or passing it to the function as an argument would fix this errror.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions