mempool: Clear vTxHashes when mapTx is cleared #24145
pull Bushstar wants to merge 1 commits into bitcoin:master from Bushstar:patch-8 changing 1 files +1 −0-
Bushstar commented at 9:34 am on January 25, 2022: contributorvTxHashes is a vector of all entries in mapTx, if you clear one you should clear the other, lest someone try to use the txiter in vTxHashes which would result in a segfault.
-
fanquake added the label Mempool on Jan 25, 2022
-
glozow commented at 11:05 am on January 25, 2022: member
light code review ACK 2902780
Perhaps someone with more historical insight should look at this as well. I can’t find a reason for
vTxHashes
to not be cleared. It looks like it was introduced this way in 811902649d6aaddd886cb39b83aa69adf7b441bd. -
MarcoFalke commented at 3:10 pm on January 26, 2022: member
-
MarcoFalke commented at 4:04 pm on January 26, 2022: member
-
luke-jr commented at 10:54 pm on January 29, 2022: memberRegardless of removing the whole function later, this seems to be a good idea and should be reviewed/merged for backport benefit.
-
in src/txmempool.cpp:707 in 2902780093 outdated
704@@ -705,6 +705,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne 705 void CTxMemPool::_clear() 706 { 707 mapTx.clear(); 708+ vTxHashes.clear();
luke-jr commented at 10:54 pm on January 29, 2022:Just for the sake of not having invalid iterators even temporarily, I prefer this before mapTx is cleared.
Bushstar commented at 7:53 am on January 31, 2022:Updated to move vTxHashes clear before mapTx clear.luke-jr approvedluke-jr commented at 10:55 pm on January 29, 2022: memberutACK, 1 nitClear vTxHashes when mapTx is cleared 9d65ad365cBushstar force-pushed on Jan 31, 2022luke-jr approvedluke-jr commented at 8:15 am on January 31, 2022: memberre-utACKlaanwj commented at 12:00 pm on April 6, 2022: memberCode review ACK 9d65ad365c539557e969a35d22723d92e0b422fe This makes sense for consistency. As long as there is a clear function it makes sense to clear everything and not forget this. Also agree on the long-run goal of removing it in favor of safer approaches.laanwj renamed this:
Clear vTxHashes when mapTx is cleared
mempool: Clear vTxHashes when mapTx is cleared
on Apr 6, 2022laanwj merged this on Apr 6, 2022laanwj closed this on Apr 6, 2022
sidhujag referenced this in commit d29293f6aa on Apr 6, 2022glozow referenced this in commit 03254c2229 on Jan 4, 2023DrahtBot locked this on Apr 6, 2023
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 15:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 15:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me