cenkalti / rain

🌧 BitTorrent client and library in Go
MIT License
974 stars 75 forks source link

data race between torrent.(*Session).insertTorrent() and torrent.(*Session).processDHTResults() #35

Closed bsergean closed 3 years ago

bsergean commented 3 years ago
==================
WARNING: DATA RACE
Write at 0x00c0003d2930 by goroutine 38:
  runtime.mapassign_faststr()
      /usr/local/go/src/runtime/map_faststr.go:202 +0x0
  github.com/bsergean/rain/torrent.(*Session).insertTorrent()
      /Users/benjaminsergeant/go/pkg/mod/github.com/bsergean/rain@v1.7.1-0.20210915153604-efd0f4345a36/torrent/session_add.go:286 +0x3c6
  github.com/bsergean/rain/torrent.(*Session).addTorrentStopped()
      /Users/benjaminsergeant/go/pkg/mod/github.com/bsergean/rain@v1.7.1-0.20210915153604-efd0f4345a36/torrent/session_add.go:117 +0x984
  github.com/bsergean/rain/torrent.(*Session).AddTorrent()
      /Users/benjaminsergeant/go/pkg/mod/github.com/bsergean/rain@v1.7.1-0.20210915153604-efd0f4345a36/torrent/session_add.go:41 +0x86
  company.com/module.SeedNewTorrent()
      /Users/benjaminsergeant/foo.go:562 +0x404

Previous read at 0x00c0003d2930 by goroutine 27:
  runtime.mapaccess2_faststr()
      /usr/local/go/src/runtime/map_faststr.go:107 +0x0
  github.com/bsergean/rain/torrent.(*Session).processDHTResults()
      /Users/benjaminsergeant/go/pkg/mod/github.com/bsergean/rain@v1.7.1-0.20210915153604-efd0f4345a36/torrent/session_dht.go:17 +0x365
  github.com/bsergean/rain/torrent.NewSession·dwrap·1()
      /Users/benjaminsergeant/go/pkg/mod/github.com/bsergean/rain@v1.7.1-0.20210915153604-efd0f4345a36/torrent/session.go:227 +0x39
cenkalti commented 3 years ago

I cannot reproduce this. Can you provide a test case please?

bsergean commented 3 years ago

I've pulled the latest master code and I cannot reproduce this anymore (I'm pretty sure this was coming from one of my tests (unittest or integration tests). I will close it, and re-open if I ever see it again.

BTW I should look and try to do what you did in your unittest to run chihaya directly.