-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
concurrencypkg-assertChange related to package testify/assertChange related to package testify/assert
Description
When using EventuallyWithT() from 1.8.3 like so:
package main
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestEventuallyWithT(t *testing.T) {
assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.NoError(c, assert.AnError)
}, time.Millisecond, time.Nanosecond)
}
the following data race is triggered:
=== RUN TestEventuallyWithT
==================
WARNING: DATA RACE
Write at 0x00c0000b42a0 by goroutine 26:
github.com/stretchr/testify/assert.(*CollectT).Errorf()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1869 +0x110
github.com/stretchr/testify/assert.Fail()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:333 +0x358
github.com/stretchr/testify/assert.NoError()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1495 +0xe0
eventuallwitht.TestEventuallyWithT.func1()
eventuallwitht/main_test.go:12 +0x58
github.com/stretchr/testify/assert.EventuallyWithT.func1()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1933 +0x44
Previous read at 0x00c0000b42a0 by goroutine 6:
github.com/stretchr/testify/assert.(*CollectT).Copy()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1887 +0x58
github.com/stretchr/testify/assert.EventuallyWithT()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1927 +0x354
eventuallwitht.TestEventuallyWithT()
eventuallwitht/main_test.go:11 +0x50
testing.tRunner()
testing/testing.go:1576 +0x188
testing.(*T).Run.func1()
testing/testing.go:1629 +0x40
Goroutine 26 (running) created at:
github.com/stretchr/testify/assert.EventuallyWithT()
github.com/stretchr/testify@v1.8.3/assert/assertions.go:1932 +0x310
eventuallwitht.TestEventuallyWithT()
eventuallwitht/main_test.go:11 +0x50
testing.tRunner()
testing/testing.go:1576 +0x188
testing.(*T).Run.func1()
testing/testing.go:1629 +0x40
Goroutine 6 (running) created at:
testing.(*T).Run()
testing/testing.go:1629 +0x5e4
testing.runTests.func1()
testing/testing.go:2036 +0x80
testing.tRunner()
testing/testing.go:1576 +0x188
testing.runTests()
testing/testing.go:2034 +0x700
testing.(*M).Run()
testing/testing.go:1906 +0x950
main.main()
_testmain.go:47 +0x300
==================
- Write:
Line 1869 in f97607b
c.errors = append(c.errors, fmt.Errorf(format, args...)) - Potential write also at:
Line 1879 in f97607b
c.errors = nil - Read:
Line 1887 in f97607b
for _, err := range c.errors {
It seems that those .errors accesses should be guarded with a lock.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
concurrencypkg-assertChange related to package testify/assertChange related to package testify/assert