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
  1. promag commented at 9:13 PM on February 1, 2019: member

    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

  2. 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.
    712d35bc56
  3. promag commented at 9:15 PM on February 1, 2019: member

    @practicalswift is this correct? @ryanofsky please take a look too.

  4. 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.

  5. jonasschnelli added the label Wallet on Feb 2, 2019
  6. practicalswift commented at 6:36 PM on February 3, 2019: contributor

    utACK 712d35bc563ac7de0b7dfc3a35fc48dc6448fa6a

    Good catch!

    Could be similar issues in other constructors/destructors.

  7. laanwj commented at 12:02 PM on February 4, 2019: member

    utACK, good catch ! 712d35bc563ac7de0b7dfc3a35fc48dc6448fa6a

  8. laanwj merged this on Feb 4, 2019
  9. laanwj closed this on Feb 4, 2019

  10. laanwj referenced this in commit ebc6542d98 on Feb 4, 2019
  11. promag deleted the branch on Feb 4, 2019
  12. 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.

  13. LarryRuane referenced this in commit b9cc8697f6 on Apr 29, 2021
  14. LarryRuane referenced this in commit efef1139fe on Jun 1, 2021
  15. linuxsh2 referenced this in commit 424fd9d5a4 on Jul 30, 2021
  16. linuxsh2 referenced this in commit d253a58d17 on Aug 3, 2021
  17. MarcoFalke locked this on Dec 16, 2021

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: 2026-04-21 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me