issadarkthing / gomu

golang TUI music player
GNU General Public License v2.0
159 stars 15 forks source link

Data Race happened #50

Closed tramhao closed 3 years ago

tramhao commented 3 years ago

When I build with go build -race, and run ./gomu, I get many data races like below:

WARNING: DATA RACE
Write at 0x00c0002207f8 by main goroutine:
  github.com/issadarkthing/gomu/player.(*Player).Run()
      /home/tramhao/.local/src/gomu/player/player.go:137 +0x671
  main.(*Queue).enqueue()
      /home/tramhao/.local/src/gomu/queue.go:162 +0x673
  main.(*Queue).loadQueue()
      /home/tramhao/.local/src/gomu/queue.go:271 +0x16f
  main.start()
      /home/tramhao/.local/src/gomu/start.go:421 +0x19ce
  main.main()
      /home/tramhao/.local/src/gomu/main.go:21 +0x232

Previous read at 0x00c0002207f8 by goroutine 15:
  github.com/issadarkthing/gomu/player.(*Player).IsPaused()
      /home/tramhao/.local/src/gomu/player/player.go:241 +0x124
  main.(*PlayingBar).run()
      /home/tramhao/.local/src/gomu/playingbar.go:69 +0xc9
  main.start.func1.1()
      /home/tramhao/.local/src/gomu/start.go:377 +0x6b

Goroutine 15 (running) created at:
  main.start.func1()
      /home/tramhao/.local/src/gomu/start.go:376 +0x25e
  github.com/issadarkthing/gomu/player.(*Player).execSongStart()
      /home/tramhao/.local/src/gomu/player/player.go:75 +0xbf6
  github.com/issadarkthing/gomu/player.(*Player).Run()
      /home/tramhao/.local/src/gomu/player/player.go:90 +0x68
  main.(*Queue).enqueue()
      /home/tramhao/.local/src/gomu/queue.go:162 +0x673
  main.(*Queue).loadQueue()
      /home/tramhao/.local/src/gomu/queue.go:271 +0x16f
  main.start()
      /home/tramhao/.local/src/gomu/start.go:421 +0x19ce
  main.main()
      /home/tramhao/.local/src/gomu/main.go:21 +0x232
==================
Found 5 data race(s)
issadarkthing commented 3 years ago

It will be a lot to fix

issadarkthing commented 3 years ago

51