You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A possible data race in func setCapacity() in les/clientpool.go. f.capLimit is read/written 9 times; 7 out of 9 times it is protected by f.lock.Lock()
; 2 out of 9 times it is read without a Lock, which are in func setCapacity().
A data race may happen when setCapacity() and other func like setLimits are called in parallel.
I wonder if developers forgot to protect f.capLimit by f.lock.Lock() in func setCapacity() or there are some special calling rules on setCapacity() to guarantee the protection.
Actual behaviour
No, I found it through static analysis.
Steps to reproduce the behaviour
No.
Backtrace
No.
The text was updated successfully, but these errors were encountered:
A data race may happen when func handle() and other func like announce() are called in parallel.
I wonder if developers forgot to protect p.headInfo in func handle() or there are some special calling rules on handle() to guarantee the protection.
A possible fix is to add a boolean parameter to f.announce(), indicating whether it is locked or not. If locked, we won't use p.lock.Lock() inside it.
This is actually safe, though probably not the nicest piece of code because it is hard to see why it is safe. clientPool.setCapacity should only be called while clientPool.lock is locked and this is what really happens because it is called in api.go from a callback of clientPool.forClients which already locks the pool lock.
Btw a major refactoring of the client pool is happening right now because new features are being added and the existing code was hacky enough already. It is WIP but close to being finished, hopefully it will make things cleaner. #21236
System information
Geth version: 1.9.10
OS & Version: Windows/Linux/OSX
Commit hash : 8045504
Expected behaviour
A possible data race in func
setCapacity()
in les/clientpool.go.f.capLimit
is read/written 9 times; 7 out of 9 times it is protected byf.lock.Lock()
; 2 out of 9 times it is read without a Lock, which are in func
setCapacity()
.go-ethereum/les/clientpool.go
Lines 484 to 494 in 8045504
A data race may happen when
setCapacity()
and other func likesetLimits
are called in parallel.I wonder if developers forgot to protect
f.capLimit
byf.lock.Lock()
in funcsetCapacity()
or there are some special calling rules onsetCapacity()
to guarantee the protection.Actual behaviour
No, I found it through static analysis.
Steps to reproduce the behaviour
No.
Backtrace
No.
The text was updated successfully, but these errors were encountered: