0Currently, CTxMemPool::check locks CTxMemPool's own cs member, then
1calls GetSpendHeight which locks cs_main. This can potentially cause an
2undesirable lock invesion since CTxMemPool's cs is supposed to be locked
3after cs_main.
4
5This does not cause us any problems right now because all callers of
6CTxMemPool already lock cs_main before calling CTxMemPool::check, which
7means that the LOCK(cs_main) in GetSpendHeight becomes benign.
8
9However, it is currently possible for new code to be added which calls
10CTxMemPool::check without locking cs_main (which would be dangerous).
11Therefore we should make it explicit that cs_main needs to be held
12before calling CTxMemPool::check.
13
14NOTE: After all review-only assertions are removed in "#20158 |
15 tree-wide: De-globalize ChainstateManager", and assuming that we
16 keep the changes in "validation: Pass in spendheight to
17 CTxMemPool::check", we can re-evaluate to see if this annotation
18 is still necessary.
Previous discussions:
- #20158 (review)
- #20158#pullrequestreview-557117202
- #20749 (review)