trustmaster / goflow

Flow-based and dataflow programming library for Go (golang)
MIT License
1.6k stars 125 forks source link

Races, lots of races #42

Closed abferm closed 4 years ago

abferm commented 6 years ago

Output of go test -v -race, I can't even get the tests to finish executing.

=== RUN   TestSingleInput
--- PASS: TestSingleInput (0.00s)
=== RUN   TestStateLock
--- PASS: TestStateLock (0.12s)
=== RUN   TestSyncLock
--- PASS: TestSyncLock (0.03s)
=== RUN   TestInitFinish
--- PASS: TestInitFinish (0.00s)
=== RUN   TestClose
--- PASS: TestClose (0.00s)
=== RUN   TestShutdown
--- PASS: TestShutdown (0.00s)
=== RUN   TestPoolMode
--- PASS: TestPoolMode (0.00s)
=== RUN   TestStopProc
==================
WARNING: DATA RACE
Write at 0x00c42023c5d0 by goroutine 178:
  reflect.Value.SetBool()
      /usr/local/go/src/reflect/value.go:1364 +0x60
  github.com/abferm/goflow.RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:322 +0x18c8
  github.com/abferm/goflow.TestStopProc()
      /home/aferm/go/src/github.com/abferm/goflow/component_test.go:381 +0x2ae
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Previous read at 0x00c42023c5d0 by goroutine 152:
  reflect.Value.Bool()
      /usr/local/go/src/reflect/value.go:248 +0x52
  github.com/abferm/goflow.RunProc.func5()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:234 +0x14a
  github.com/abferm/goflow.RunProc.func8()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:331 +0x54

Goroutine 178 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/abferm/goflow/_test/_testmain.go:88 +0x20f

Goroutine 152 (finished) created at:
  github.com/abferm/goflow.RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:340 +0x192e
  github.com/abferm/goflow.TestStopProc()
      /home/aferm/go/src/github.com/abferm/goflow/component_test.go:361 +0x13e
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
==================
--- FAIL: TestStopProc (0.00s)
    testing.go:610: race detected during execution of test
=== RUN   TestLooper
--- PASS: TestLooper (0.00s)
=== RUN   TestFactory
--- PASS: TestFactory (0.00s)
=== RUN   TestFactoryConnection
--- PASS: TestFactoryConnection (0.00s)
=== RUN   TestFactorySubgraph
--- PASS: TestFactorySubgraph (0.00s)
=== RUN   TestRuntimeNetwork
--- PASS: TestRuntimeNetwork (0.00s)
=== RUN   TestConnection
--- PASS: TestConnection (0.00s)
=== RUN   TestComposite
--- PASS: TestComposite (0.00s)
=== RUN   TestMultiOutChannel
--- PASS: TestMultiOutChannel (0.00s)
=== RUN   TestIIP
--- PASS: TestIIP (0.00s)
=== RUN   TestStopNet
==================
WARNING: DATA RACE
Read at 0x00c4200b2c50 by goroutine 120:
  github.com/abferm/goflow.(*Graph).Stop()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:771 +0x57
  github.com/abferm/goflow.TestStopNet()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:391 +0x1d6
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Previous write at 0x00c4200b2c50 by goroutine 78:
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:651 +0x26c
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c

Goroutine 120 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/abferm/goflow/_test/_testmain.go:88 +0x20f

Goroutine 78 (running) created at:
  github.com/abferm/goflow.RunNet()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:940 +0xdb
  github.com/abferm/goflow.TestStopNet()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:380 +0x123
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
==================
==================
WARNING: DATA RACE
Read at 0x00c42023ccf0 by goroutine 83:
  reflect.Value.Bool()
      /usr/local/go/src/reflect/value.go:248 +0x52
  github.com/abferm/goflow.RunProc.func3()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:181 +0xc3
  github.com/abferm/goflow.RunProc.func7()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:299 +0x375

Previous write at 0x00c42023ccf0 by goroutine 78:
  reflect.Value.SetBool()
      /usr/local/go/src/reflect/value.go:1364 +0x60
  github.com/abferm/goflow.RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:322 +0x18c8
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:648 +0x106f
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c

Goroutine 83 (running) created at:
  github.com/abferm/goflow.RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:317 +0x19de
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:648 +0x106f
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c

Goroutine 78 (running) created at:
  github.com/abferm/goflow.RunNet()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:940 +0xdb
  github.com/abferm/goflow.TestStopNet()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:380 +0x123
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
==================
--- FAIL: TestStopNet (0.00s)
    testing.go:610: race detected during execution of test
=== RUN   TestReconnection
==================
WARNING: DATA RACE
Write at 0x00c42012c290 by goroutine 251:
  reflect.Value.Set()
      /usr/local/go/src/reflect/value.go:1355 +0x109
  github.com/abferm/goflow.unsetProcPort()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:465 +0x244
  github.com/abferm/goflow.(*Graph).Disconnect()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:482 +0x1eb
  github.com/abferm/goflow.TestReconnection()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:436 +0x9b6
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Previous read at 0x00c42012c290 by goroutine 257:
  reflect.Value.pointer()
      /usr/local/go/src/reflect/value.go:90 +0x85
  reflect.Select()
      /usr/local/go/src/reflect/value.go:2016 +0x87c
  github.com/abferm/goflow.RunProc.func7()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:295 +0xa4

Goroutine 251 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/abferm/goflow/_test/_testmain.go:88 +0x20f

Goroutine 257 (running) created at:
  github.com/abferm/goflow.RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/component.go:317 +0x19de
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:648 +0x106f
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c
==================
==================
WARNING: DATA RACE
Read at 0x00c42012c180 by goroutine 253:
  runtime.mapiternext()
      /usr/local/go/src/runtime/hashmap.go:730 +0x0
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:642 +0x238
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c

Previous write at 0x00c42012c180 by goroutine 251:
  runtime.mapassign()
      /usr/local/go/src/runtime/hashmap.go:485 +0x0
  github.com/abferm/goflow.(*Graph).Add()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:191 +0x2a0
  github.com/abferm/goflow.TestReconnection()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:441 +0xa0f
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Goroutine 253 (running) created at:
  github.com/abferm/goflow.RunNet()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:940 +0xdb
  github.com/abferm/goflow.TestReconnection()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:420 +0x82c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Goroutine 251 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/abferm/goflow/_test/_testmain.go:88 +0x20f
==================
==================
WARNING: DATA RACE
Write at 0x00c420314080 by goroutine 253:
  github.com/abferm/goflow.(*Graph).run()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:651 +0x26c
  github.com/abferm/goflow.RunNet.func1()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:931 +0x3c

Previous read at 0x00c420314080 by goroutine 251:
  github.com/abferm/goflow.(*Graph).RunProc()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:748 +0x4c
  github.com/abferm/goflow.TestReconnection()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:451 +0xb50
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Goroutine 253 (running) created at:
  github.com/abferm/goflow.RunNet()
      /home/aferm/go/src/github.com/abferm/goflow/network.go:940 +0xdb
  github.com/abferm/goflow.TestReconnection()
      /home/aferm/go/src/github.com/abferm/goflow/network_test.go:420 +0x82c
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107

Goroutine 251 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/local/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/abferm/goflow/_test/_testmain.go:88 +0x20f
==================
TerraTech commented 6 years ago

Is this a major "there be dragons lurking about" problem that would preclude it from being used in "production" code?

I ask because many months have passed with no feedback on this issue, where the shown results should warrant some sort of response by the library stewards.

After seeing this, I'm a little hesitant wiring it in to some current projects I'm working on where it would make a good fit.

abferm commented 6 years ago

I am currently using goflow in some production code, working around some of its inherent issues. It makes heavy use of reflect which is highly discouraged by most of the golang community. I have a fork that I would like to refactor to be more "go like", but have not had the time to do so.

Darfk commented 6 years ago

I wrote a toy web spider using this package and had nothing but issues with race conditions. If only I had run go test on this package first.

trustmaster commented 4 years ago

Closing this as legacy. The current master branch is tested with -race as part of CI.