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

x/tools/go/analysis/passes/loopclosure: handle t.Parallel #28771

Open
alandonovan opened this issue Nov 13, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@alandonovan
Copy link
Contributor

commented Nov 13, 2018

If a test calls t.Run in a loop, and the t.Run function literal contains a call to t.Parallel, then the t.Run effectively turns from a synchronous call into a go statement.

func Test(t *testing.T) {
    for name, value := range tests {
        t.Run(name, func(t *testing.T) {
            t.Parallel()
            ...
            use(value) // oops! read of value races with loop index variable update
        }
    }
}

The loopclosure check could recognize this case and treat such t.Run calls equivalent to a go statement.

@gopherbot gopherbot added this to the Unreleased milestone Nov 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.