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

race condition in Eventually #835

Closed
amir-arad opened this issue Nov 5, 2019 · 1 comment · Fixed by #808
Closed

race condition in Eventually #835

amir-arad opened this issue Nov 5, 2019 · 1 comment · Fixed by #808
Labels
assert.Eventually About assert.Eventually/EventuallyWithT bug pkg-assert Change related to package testify/assert

Comments

@amir-arad
Copy link

I've used a tightly timed 'Eventually' in my test:
assert.Eventually(t, func() bool { ... }, time.Millisecond*100, time.Millisecond)
ran it with -race -count=1000 and i got:

==================
WARNING: DATA RACE
Write at 0x00c0000ba5b0 by goroutine 34:
  runtime.closechan()
      /.../go/go1.12.9/src/runtime/chan.go:334 +0x0
  github.com/stretchr/testify/assert.Eventually()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:1490 +0x29e
  github.com/stretchr/testify/require.Eventually()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/[email protected]/require/require.go:278 +0xaf
  command-line-arguments_test.TestPeriodicalTriggerStopWorksWhenContextIsCancelled.func1()
    ...

Previous read at 0x00c0000ba5b0 by goroutine 62:
  runtime.chansend()
      /.../go/go1.12.9/src/runtime/chan.go:142 +0x0
  github.com/stretchr/testify/assert.Eventually.func1()
      /.../go/go1.12.9/pkg/mod/github.com/stretchr/[email protected]/assert/assertions.go:1494 +0x54
@perhallgren
Copy link

Same here! Not able to reproduce reliably. go version go1.13 darwin/amd64, using github.com/stretchr/testify v1.4.0.

==================
WARNING: DATA RACE
Read at 0x00c000468010 by goroutine 17:
  runtime.chansend()
      /usr/local/opt/go/libexec/src/runtime/chan.go:142 +0x0
  github.com/stretchr/testify/assert.Eventually.func1()

Previous write at 0x00c000468010 by goroutine 91:
  runtime.closechan()
      /usr/local/opt/go/libexec/src/runtime/chan.go:334 +0x0
  github.com/stretchr/testify/assert.Eventually()

Looks like this is the issue.

jszwec added a commit to jszwec/testify that referenced this issue Nov 6, 2019
georgelesica-wf pushed a commit that referenced this issue Nov 6, 2019
@dolmen dolmen added bug pkg-assert Change related to package testify/assert assert.Eventually About assert.Eventually/EventuallyWithT labels Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert.Eventually About assert.Eventually/EventuallyWithT bug pkg-assert Change related to package testify/assert
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants