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

Running /examples/echo-receiver/main.go with the race detector reports a race condition #68

Open
michaeljdennis opened this issue Sep 21, 2023 · 1 comment

Comments

@michaeljdennis
Copy link

michaeljdennis commented Sep 21, 2023

When running the echo-receiver example with the race detector (go run -race main.go) and then starting an SRT stream, I see the following race condition reported:

WARNING: DATA RACE
Write at 0x00c00020e020 by goroutine 10:
  github.com/haivision/srtgo.(*pollDesc).reset()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/poll.go:262 +0xa5
  github.com/haivision/srtgo.SrtSocket.Read()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/read.go:43 +0x46
  main.handler()
      /home/michael/bitcentral/srt-example/main.go:38 +0xfc
  main.main.func2()
      /home/michael/bitcentral/srt-example/main.go:77 +0x44

Previous write at 0x00c00020e020 by goroutine 8:
  sync/atomic.StoreInt32()
      /usr/local/go/src/runtime/race_amd64.s:231 +0xb
  sync/atomic.StoreInt32()
      <autogenerated>:1 +0x14
  github.com/haivision/srtgo.(*pollServer).run()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:100 +0x1d9
  github.com/haivision/srtgo.pollServerCtxInit.func1()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:31 +0x33

Goroutine 10 (running) created at:
  main.main()
      /home/michael/bitcentral/srt-example/main.go:77 +0x315

Goroutine 8 (running) created at:
  github.com/haivision/srtgo.pollServerCtxInit()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:31 +0x1bc
  sync.(*Once).doSlow()
      /usr/local/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /usr/local/go/src/sync/once.go:65 +0x44
  github.com/haivision/srtgo.pollServerCtx()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:20 +0x11e
  github.com/haivision/srtgo.pollDescInit()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/poll.go:77 +0xfd
  github.com/haivision/srtgo.NewSrtSocket()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/srtgo.go:112 +0x2e9
  main.main()
      /home/michael/bitcentral/srt-example/main.go:59 +0x15c
==================
==================
WARNING: DATA RACE
Read at 0x00c00020e020 by goroutine 8:
  sync/atomic.LoadInt32()
      /usr/local/go/src/runtime/race_amd64.s:202 +0xb
  sync/atomic.LoadInt32()
      <autogenerated>:1 +0x10
  github.com/haivision/srtgo.(*pollServer).run()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:100 +0x1d9
  github.com/haivision/srtgo.pollServerCtxInit.func1()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:31 +0x33

Previous write at 0x00c00020e020 by goroutine 10:
  github.com/haivision/srtgo.(*pollDesc).reset()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/poll.go:262 +0xa5
  github.com/haivision/srtgo.SrtSocket.Read()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/read.go:43 +0x46
  main.handler()
      /home/michael/bitcentral/srt-example/main.go:38 +0xfc
  main.main.func2()
      /home/michael/bitcentral/srt-example/main.go:77 +0x44

Goroutine 8 (running) created at:
  github.com/haivision/srtgo.pollServerCtxInit()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:31 +0x1bc
  sync.(*Once).doSlow()
      /usr/local/go/src/sync/once.go:74 +0xf0
  sync.(*Once).Do()
      /usr/local/go/src/sync/once.go:65 +0x44
  github.com/haivision/srtgo.pollServerCtx()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/pollserver.go:20 +0x11e
  github.com/haivision/srtgo.pollDescInit()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/poll.go:77 +0xfd
  github.com/haivision/srtgo.NewSrtSocket()
      /home/michael/go/pkg/mod/github.com/haivision/srtgo@v0.0.0-20230627061225-a70d53fcd618/srtgo.go:112 +0x2e9
  main.main()
      /home/michael/bitcentral/srt-example/main.go:59 +0x15c

Goroutine 10 (running) created at:
  main.main()
      /home/michael/bitcentral/srt-example/main.go:77 +0x315
==================
@michaeljdennis
Copy link
Author

This issue seems to be handled by pull request #65.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant