isacikgoz / tldr

fast and interactive tldr client written with go
https://isacikgoz.me/tldr/
MIT License
1.36k stars 48 forks source link

Data race in package prompt #25

Closed dolmen closed 3 years ago

dolmen commented 4 years ago

When building with -race (cd cmd/tldr; go build -race; ./tldr ps) I can easily get a data race report.

==================
WARNING: DATA RACE
Read at 0x00c0001280b0 by goroutine 8:
  github.com/isacikgoz/gitin/prompt.(*Prompt).spawnEvents()
      $GOPATH/pkg/mod/github.com/isacikgoz/gitin@v0.2.3/prompt/prompt.go:180 +0xef

Previous write at 0x00c0001280b0 by main goroutine:
  github.com/isacikgoz/gitin/prompt.(*Prompt).mainloop()
      $GOPATH/pkg/mod/github.com/isacikgoz/gitin@v0.2.3/prompt/prompt.go:227 +0x364
  github.com/isacikgoz/gitin/prompt.(*Prompt).Run()
      $GOPATH/pkg/mod/github.com/isacikgoz/gitin@v0.2.3/prompt/prompt.go:145 +0x1cc
  main.run()

I don't know if this is related to #23, but at least this happens in the same package.

go version

go version go1.13.6 darwin/amd64

Commit: 3918253df491996b5618f2eb3de015170d63c21a

dolmen commented 4 years ago

In prompt.go p.hold should be protected (or replaced) by a lock.

isacikgoz commented 3 years ago

I've just fixed it and it's merged to master. Please let me know if you still the issue. Also, feel free to open a new issue.