Skip to content

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

Open
@michaeljdennis

Description

@michaeljdennis

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/[email protected]/poll.go:262 +0xa5
  github.com/haivision/srtgo.SrtSocket.Read()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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/[email protected]/pollserver.go:100 +0x1d9
  github.com/haivision/srtgo.pollServerCtxInit.func1()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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/[email protected]/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/[email protected]/pollserver.go:20 +0x11e
  github.com/haivision/srtgo.pollDescInit()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/poll.go:77 +0xfd
  github.com/haivision/srtgo.NewSrtSocket()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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/[email protected]/pollserver.go:100 +0x1d9
  github.com/haivision/srtgo.pollServerCtxInit.func1()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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/[email protected]/poll.go:262 +0xa5
  github.com/haivision/srtgo.SrtSocket.Read()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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/[email protected]/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/[email protected]/pollserver.go:20 +0x11e
  github.com/haivision/srtgo.pollDescInit()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/poll.go:77 +0xfd
  github.com/haivision/srtgo.NewSrtSocket()
      /home/michael/go/pkg/mod/github.com/haivision/[email protected]/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
==================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions