Skip to content

Commit 712d35b

Browse files
committed
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.
1 parent efb6dde commit 712d35b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/wallet/db.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ BerkeleyEnvironment::BerkeleyEnvironment(const fs::path& dir_path) : strPath(dir
147147

148148
BerkeleyEnvironment::~BerkeleyEnvironment()
149149
{
150+
LOCK(cs_db);
150151
g_dbenvs.erase(strPath);
151152
Close();
152153
}

0 commit comments

Comments
 (0)