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

Fix race conditions in tests #80

Closed
belak opened this issue Jul 28, 2016 · 2 comments
Closed

Fix race conditions in tests #80

belak opened this issue Jul 28, 2016 · 2 comments

Comments

@belak
Copy link
Contributor

belak commented Jul 28, 2016

When I run the tests with -race, there are a number or race conditions. It may be worth fixing them.

==================
WARNING: DATA RACE
Write by goroutine 31:
  github.com/thoj/go-ircevent.(*Connection).Quit()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
  github.com/thoj/go-ircevent.TestConnection.func5()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:218 +0x22b
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Previous read by goroutine 34:
  github.com/thoj/go-ircevent.(*Connection).Loop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83

Goroutine 31 (running) created at:
  github.com/thoj/go-ircevent.(*Connection).Connect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
  github.com/thoj/go-ircevent.TestConnection()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc

Goroutine 34 (running) created at:
  github.com/thoj/go-ircevent.TestConnection()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:239 +0xadb
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 36:
  runtime.mapassign1()
      /usr/lib/go/src/runtime/hashmap.go:429 +0x0
  github.com/thoj/go-ircevent.(*Connection).ClearCallback()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:50 +0x170
  github.com/thoj/go-ircevent.(*Connection).Disconnect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:346 +0xdc

Previous read by goroutine 31:
  runtime.mapaccess2_faststr()
      /usr/lib/go/src/runtime/hashmap_fast.go:298 +0x0
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:124 +0x7c9
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Goroutine 36 (running) created at:
  github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Goroutine 31 (finished) created at:
  github.com/thoj/go-ircevent.(*Connection).Connect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
  github.com/thoj/go-ircevent.TestConnection()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 36:
  github.com/thoj/go-ircevent.(*Connection).Disconnect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:352 +0x167

Previous read by goroutine 32:
  github.com/thoj/go-ircevent.(*Connection).writeLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:129 +0xb9

Goroutine 36 (running) created at:
  github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Goroutine 32 (finished) created at:
  github.com/thoj/go-ircevent.(*Connection).Connect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:437 +0x121c
  github.com/thoj/go-ircevent.TestConnection()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 35:
  github.com/thoj/go-ircevent.(*Connection).Quit()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
  github.com/thoj/go-ircevent.TestConnection.func3.1()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:203 +0x1eb

Previous read by goroutine 20:
  github.com/thoj/go-ircevent.(*Connection).Loop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83
  github.com/thoj/go-ircevent.TestConnection()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:240 +0xae9
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc

Goroutine 35 (running) created at:
  github.com/thoj/go-ircevent.TestConnection.func3()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:206 +0x54
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Goroutine 20 (running) created at:
  testing.RunTests()
      /usr/lib/go/src/testing/testing.go:582 +0xae2
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:515 +0x11d
  main.main()
      github.com/thoj/go-ircevent/_test/_testmain.go:84 +0x210
==================
==================
WARNING: DATA RACE
Write by goroutine 43:
  github.com/thoj/go-ircevent.(*Connection).Quit()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
  github.com/thoj/go-ircevent.TestConnectionSSL.func2()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:254 +0x77
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Previous read by goroutine 38:
  github.com/thoj/go-ircevent.(*Connection).Loop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83
  github.com/thoj/go-ircevent.TestConnectionSSL()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:263 +0x50b
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc

Goroutine 43 (running) created at:
  github.com/thoj/go-ircevent.(*Connection).Connect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
  github.com/thoj/go-ircevent.TestConnectionSSL()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:257 +0x2ca
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc

Goroutine 38 (running) created at:
  testing.RunTests()
      /usr/lib/go/src/testing/testing.go:582 +0xae2
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:515 +0x11d
  main.main()
      github.com/thoj/go-ircevent/_test/_testmain.go:84 +0x210
==================
==================
WARNING: DATA RACE
Write by goroutine 46:
  github.com/thoj/go-ircevent.(*Connection).Disconnect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:352 +0x167

Previous read by goroutine 43:
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:50 +0x1be

Goroutine 46 (running) created at:
  github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
  github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
  github.com/thoj/go-ircevent.(*Connection).readLoop()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3

Goroutine 43 (finished) created at:
  github.com/thoj/go-ircevent.(*Connection).Connect()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
  github.com/thoj/go-ircevent.TestConnectionSSL()
      /home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:257 +0x2ca
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:473 +0xdc
==================
Found 6 data race(s)
@thoj
Copy link
Owner

thoj commented Jul 28, 2016

Related to #67

Also see testing branch https://github.com/thoj/go-ircevent/tree/testing this fixes all race conditions with go test -race

@thoj
Copy link
Owner

thoj commented Nov 5, 2016

Merged race fixes.

@thoj thoj closed this as completed Nov 5, 2016
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

2 participants