ipfs / go-bitswap

The golang implementation of the bitswap protocol
MIT License
216 stars 112 forks source link

fix: fix a map access race condition in the want index #523

Closed Stebalien closed 3 years ago

Stebalien commented 3 years ago

We should have better tests here, but I'm not sure how to go about that. We basically need a fuzzer.

Stebalien commented 3 years ago

Seems reasonable. Is the problem here that we're calling e.peerLedger.CancelWant without taking the lock on the ledger?

Yes. On the happy path we just read the map so we only need a read lock. On the sad path, we need to take the lock.