Skip to content

Commit ebc6542

Browse files
committed
Merge bitcoin#15322: wallet: Add missing cs_db lock
712d35b wallet: Add missing cs_db lock (João Barbosa) Pull request description: 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. Reference: http://releases.llvm.org/5.0.2/tools/clang/docs/ThreadSafetyAnalysis.html#no-checking-inside-constructors-and-destructors Tree-SHA512: 350cb2b991ca699a6bca85f87c82c38f0814484c8ccb0d7d83cb3bff9afcf60dd32b2a9554a9e72eb5803bfad8b6970fe7da618b39be5889178b86faa1b74124
2 parents 424327e + 712d35b commit ebc6542

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: src/wallet/db.cpp

+1
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)