btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.1k stars 2.31k forks source link

blockchain: always relock chainLock for subscription callbacks #2128

Closed kcalvinalvin closed 3 months ago

kcalvinalvin commented 4 months ago

For various b.sendNotifcation() callbacks, if a runtime panic happens, we don't get any useful debugging information since the error that happens first is the "unlock of unlocked mutex" error.

This is because we temporarily unlock the chainLock for callbacks and then relock them. However, since the relocking code is executed after the completion of the callback, if an error happens during that callback, we never relock the chainLock.

Switching to an anonymous function and having the unlock code as a defer will ensure that the lock always relocks.

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 8060178922

Details


Totals Coverage Status
Change from base Build 8057525961: 0.007%
Covered Lines: 29202
Relevant Lines: 51474

💛 - Coveralls