Skip to content

Commit

Permalink
Merge bitcoin#15322: wallet: Add missing cs_db lock
Browse files Browse the repository at this point in the history
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
  • Loading branch information
laanwj authored and linuxsh2 committed Jul 30, 2021
1 parent 791a234 commit 424fd9d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ BerkeleyEnvironment::BerkeleyEnvironment(const fs::path& dir_path) : strPath(dir

BerkeleyEnvironment::~BerkeleyEnvironment()
{
LOCK(cs_db);
g_dbenvs.erase(strPath);
Close();
}
Expand Down

0 comments on commit 424fd9d

Please sign in to comment.