fako1024/slimcap

Data race in NoDrain mock source mode

Closed this issue · 0 comments

The NoDrain mock source mode generates an inherent data race w.r.t. Close() / Free() and accesses to the mock ring buffer:

WARNING: DATA RACE
Write at 0x00c0000b01f0 by goroutine 29:
  github.com/fako1024/slimcap/capture/afpacket/afring.(*MockSource).Free()
      /home/fako/Develop/go/pkg/mod/github.com/fako1024/slimcap@v0.0.0-20230512072549-58c6d54e1823/capture/afpacket/afring/afring_mock.go:340 +0x52
  github.com/els0r/goProbe/pkg/capture.(*Capture).process.func1()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture.go:204 +0x257

Previous read at 0x00c0000b01f0 by goroutine 28:
  github.com/fako1024/slimcap/capture/afpacket/afring.(*MockSource).RunNoDrain.func1()
      /home/fako/Develop/go/pkg/mod/github.com/fako1024/slimcap@v0.0.0-20230512072549-58c6d54e1823/capture/afpacket/afring/afring_mock.go:253 +0x337
  github.com/fako1024/slimcap/capture/afpacket/afring.(*MockSource).RunNoDrain.func2()
      /home/fako/Develop/go/pkg/mod/github.com/fako1024/slimcap@v0.0.0-20230512072549-58c6d54e1823/capture/afpacket/afring/afring_mock.go:262 +0x47

Goroutine 29 (running) created at:
  github.com/els0r/goProbe/pkg/capture.(*Capture).process()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture.go:177 +0x136
  github.com/els0r/goProbe/pkg/capture.testDeadlock()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture_test.go:47 +0x2fe
  github.com/els0r/goProbe/pkg/capture.TestHighTrafficDeadlock()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture_skiprace_test.go:23 +0x35
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1629 +0x47

Goroutine 28 (finished) created at:
  github.com/fako1024/slimcap/capture/afpacket/afring.(*MockSource).RunNoDrain()
      /home/fako/Develop/go/pkg/mod/github.com/fako1024/slimcap@v0.0.0-20230512072549-58c6d54e1823/capture/afpacket/afring/afring_mock.go:236 +0x276
  github.com/els0r/goProbe/pkg/capture.testDeadlock()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture_test.go:44 +0x8a4
  github.com/els0r/goProbe/pkg/capture.TestHighTrafficDeadlock()
      /home/fako/Develop/go/src/github.com/els0r/goProbe/pkg/capture/capture_skiprace_test.go:23 +0x35
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /usr/local/go/src/testing/testing.go:1629 +0x47

DoD

  • Assess options to mitigate without sacrificing performance
  • Refactor mock sources to simplify handling of draining vs. non-draining
  • Amend tests