Without this lock BerkeleyEnvironment::~BerkeleyEnvironment and GetWalletEnv would race for g_dbenvs. This wasn't detected before because thread safety analysis does not check constructors
and destructors.
wallet: Add missing cs_db lock #15322
pull promag wants to merge 1 commits into bitcoin:master from promag:2019-01-cs_db changing 1 files +1 −0-
promag commented at 9:13 PM on February 1, 2019: member
-
712d35bc56
wallet: Add missing cs_db lock
Without this lock BerkeleyEnvironment::~BerkeleyEnvironment and GetWalletEnv would race for g_dbenvs. This wasn't detected before because thread safety analysis does not check constructors and destructors.
-
promag commented at 9:15 PM on February 1, 2019: member
@practicalswift is this correct? @ryanofsky please take a look too.
-
MarcoFalke commented at 11:00 PM on February 1, 2019: member
utACK 712d35bc563ac7de0b7dfc3a35fc48dc6448fa6a. Would be nice if there was a (unit) test that run into problems with tsan.
- jonasschnelli added the label Wallet on Feb 2, 2019
-
practicalswift commented at 6:36 PM on February 3, 2019: contributor
utACK 712d35bc563ac7de0b7dfc3a35fc48dc6448fa6a
Good catch!
Could be similar issues in other constructors/destructors.
-
laanwj commented at 12:02 PM on February 4, 2019: member
utACK, good catch ! 712d35bc563ac7de0b7dfc3a35fc48dc6448fa6a
- laanwj merged this on Feb 4, 2019
- laanwj closed this on Feb 4, 2019
- laanwj referenced this in commit ebc6542d98 on Feb 4, 2019
- promag deleted the branch on Feb 4, 2019
-
MarcoFalke commented at 10:21 PM on February 4, 2019: member
... race for g_dbenvs. This wasn't detected before because thread safety analysis does not check constructors and destructors.
A solution to that would be to require that constructors don't access globals in their body. Calling a function that does it for them would be fine, since that is covered by the static analyser.
- LarryRuane referenced this in commit b9cc8697f6 on Apr 29, 2021
- LarryRuane referenced this in commit efef1139fe on Jun 1, 2021
- linuxsh2 referenced this in commit 424fd9d5a4 on Jul 30, 2021
- linuxsh2 referenced this in commit d253a58d17 on Aug 3, 2021
- MarcoFalke locked this on Dec 16, 2021
Contributors
Labels