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

testing: is the package thread-safe? #20940

matthewmueller opened this issue Jul 7, 2017 · 2 comments

testing: is the package thread-safe? #20940

matthewmueller opened this issue Jul 7, 2017 · 2 comments


Copy link

matthewmueller commented Jul 7, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.3 darwin/amd64

What operating system and processor architecture are you using (go env)?


What did you do?

Running t.Fatal(err) inside multiple goroutines with the -race flag

What did you expect to see?

The testing package to be thread-safe and not report data races when running the -race flag.

I'm not 100% sure this isn't related to my code, but based on the error I think it's because I'm calling t.Fatal(err) from multiple goroutines. So I'd just like some clarity there.

What did you see instead?

Write at 0x00c42014e524 by goroutine 10:
      /usr/local/go/src/testing/testing.go:658 +0x119

Previous write at 0x00c42014e524 by goroutine 62:
      /usr/local/go/src/testing/testing.go:485 +0x4a
      /usr/local/go/src/testing/testing.go:524 +0x7c
      /Users/matt/go/src/ +0x2d3
Copy link

ALTree commented Jul 7, 2017

This is documented:

A test ends when its Test function returns or calls any of the methods FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods, as well as the Parallel method, must be called only from the goroutine running the Test function.

Closing this, since it's not a bug.

@ALTree ALTree closed this as completed Jul 7, 2017
Copy link

matthewmueller commented Jul 7, 2017

Ahh there it is. Thanks!

@mikioh mikioh changed the title Is the testing package thread-safe? testing: is the package thread-safe? Jul 10, 2017
@golang golang locked and limited conversation to collaborators Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants