-
Notifications
You must be signed in to change notification settings - Fork 780
Closed
Labels
Description
Bug Report
Noticed in a code audit that this code is erroneously invoking a read-lock meanwhile it performs write/mutating operations
cometbft/mempool/clist_mempool.go
Lines 221 to 229 in 4ce0277
| func (mem *CListMempool) Flush() { | |
| mem.updateMtx.RLock() | |
| defer mem.updateMtx.RUnlock() | |
| mem.txsBytes.Store(0) | |
| mem.cache.Reset() | |
| mem.removeAllTxs() | |
| } |
which also means that this mempool implementation is not properly tested because it clearly invokes mutating code here
cometbft/mempool/clist_mempool.go
Lines 136 to 147 in 4ce0277
| func (mem *CListMempool) removeAllTxs() { | |
| for e := mem.txs.Front(); e != nil; e = e.Next() { | |
| mem.txs.Remove(e) | |
| e.DetachPrev() | |
| } | |
| mem.txsMap.Range(func(key, _ interface{}) bool { | |
| mem.txsMap.Delete(key) | |
| mem.invokeRemoveTxOnReactor(key.(types.TxKey)) | |
| return true | |
| }) | |
| } |
Reactions are currently unavailable