{"action":"created","issue":{"url":"https://api.github.com/repos/go-check/check/issues/43","labels_url":"https://api.github.com/repos/go-check/check/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/go-check/check/issues/43/comments","events_url":"https://api.github.com/repos/go-check/check/issues/43/events","html_url":"https://github.com/go-check/check/issues/43","id":86854146,"number":43,"title":"Data race if c.Fail is called in a goroutine","user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-06-10T06:08:53Z","updated_at":"2015-06-18T09:50:37Z","closed_at":null,"body":"Consider this test case\r\n```\r\npackage suite\r\n\r\nimport (\r\n\t\"sync\"\r\n\t\"testing\"\r\n\r\n\tgc \"gopkg.in/check.v1\"\r\n)\r\n\r\ntype TestSuite struct{}\r\n\r\nvar _ = gc.Suite(&TestSuite{})\r\n\r\nfunc TestTesting(t *testing.T) {\r\n\tgc.TestingT(t)\r\n}\r\n\r\nfunc (t *TestSuite) TestRace(c *gc.C) {\r\n\tvar wg sync.WaitGroup\r\n\tstart := make(chan bool)\r\n\r\n\tconst n = 2\r\n\r\n\twg.Add(n)\r\n\tfor i := 0; i < n; i++ {\r\n\t\tgo func() {\r\n\t\t\tdefer wg.Done()\r\n\r\n\t\t\t<-start\r\n\r\n\t\t\tc.Error(\"an error occured\")\r\n\t\t}()\r\n\t}\r\n\tclose(start)\r\n\twg.Wait()\r\n}\r\n```\r\nWhen running the test with -race, the following data race results\r\n```\r\n==================\r\nWARNING: DATA RACE\r\nWrite by goroutine 9:\r\n  gopkg.in/check%2ev1.(*C).Error()\r\n      /home/dfc/src/gopkg.in/check.v1/helpers.go:117 +0x246\r\n  suite.(*TestSuite).TestRace.func1()\r\n      /home/dfc/src/suite/suite_test.go:31 +0x152\r\n\r\nPrevious write by goroutine 10:\r\n  gopkg.in/check%2ev1.(*C).Error()\r\n      /home/dfc/src/gopkg.in/check.v1/helpers.go:117 +0x246\r\n  suite.(*TestSuite).TestRace.func1()\r\n      /home/dfc/src/suite/suite_test.go:31 +0x152\r\n\r\nGoroutine 9 (running) created at:\r\n  suite.(*TestSuite).TestRace()\r\n      /home/dfc/src/suite/suite_test.go:32 +0xd0\r\n  runtime.call32()\r\n      /home/dfc/go/src/runtime/asm_amd64.s:437 +0x44\r\n  reflect.Value.Call()\r\n      /home/dfc/go/src/reflect/value.go:300 +0xd0\r\n  gopkg.in/check%2ev1.(*suiteRunner).forkTest.func1()\r\n      /home/dfc/src/gopkg.in/check.v1/check.go:763 +0x5e3\r\n  gopkg.in/check%2ev1.(*suiteRunner).forkCall.func1()\r\n      /home/dfc/src/gopkg.in/check.v1/check.go:657 +0x83\r\n\r\nGoroutine 10 (finished) created at:\r\n  suite.(*TestSuite).TestRace()\r\n      /home/dfc/src/suite/suite_test.go:32 +0xd0\r\n  runtime.call32()\r\n      /home/dfc/go/src/runtime/asm_amd64.s:437 +0x44\r\n  reflect.Value.Call()\r\n      /home/dfc/go/src/reflect/value.go:300 +0xd0\r\n  gopkg.in/check%2ev1.(*suiteRunner).forkTest.func1()\r\n      /home/dfc/src/gopkg.in/check.v1/check.go:763 +0x5e3\r\n  gopkg.in/check%2ev1.(*suiteRunner).forkCall.func1()\r\n      /home/dfc/src/gopkg.in/check.v1/check.go:657 +0x83\r\n==================\r\n\r\n----------------------------------------------------------------------\r\nFAIL: suite_test.go:18: TestSuite.TestRace\r\n\r\nOOPS: 0 passed, 1 FAILED\r\nsuite_test.go:31:\r\n    c.Error(\"an error occured\")\r\n... Error: an error occured\r\n\r\nsuite_test.go:31:\r\n    c.Error(\"an error occured\")\r\n... Error: an error occured\r\n\r\n--- FAIL: TestTesting (0.00s)\r\nFAIL\r\nexit status 1\r\nFAIL    suite   0.018s\r\n```"},"comment":{"url":"https://api.github.com/repos/go-check/check/issues/comments/113095138","html_url":"https://github.com/go-check/check/issues/43#issuecomment-113095138","issue_url":"https://api.github.com/repos/go-check/check/issues/43","id":113095138,"user":{"login":"davecheney","id":7171,"avatar_url":"https://avatars.githubusercontent.com/u/7171?v=3","gravatar_id":"","url":"https://api.github.com/users/davecheney","html_url":"https://github.com/davecheney","followers_url":"https://api.github.com/users/davecheney/followers","following_url":"https://api.github.com/users/davecheney/following{/other_user}","gists_url":"https://api.github.com/users/davecheney/gists{/gist_id}","starred_url":"https://api.github.com/users/davecheney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davecheney/subscriptions","organizations_url":"https://api.github.com/users/davecheney/orgs","repos_url":"https://api.github.com/users/davecheney/repos","events_url":"https://api.github.com/users/davecheney/events{/privacy}","received_events_url":"https://api.github.com/users/davecheney/received_events","type":"User","site_admin":false},"created_at":"2015-06-18T09:50:37Z","updated_at":"2015-06-18T09:50:37Z","body":"`c.Error` does not invoke `c.FailNow`."}}