txindex: Stop thread before calling base destructor #13882

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:Mf1808-txindexDestruct changing 5 files +8 −8
  1. MarcoFalke commented at 3:21 PM on August 5, 2018: member

    Currently the thread would be stopped in the base destructor. Effectively leaving a race condition where the derived destructor is finished and the thread is still running, leading to segfaults.

    Fix this by stopping the thread in the derived destructor.

  2. txindex: Stop thread before calling base destructor fa860c4fcc
  3. MarcoFalke added the label UTXO Db and Indexes on Aug 5, 2018
  4. in src/index/base.cpp:52 in fa860c4fcc
      47 | @@ -48,8 +48,6 @@ bool BaseIndex::DB::WriteBestBlock(const CBlockLocator& locator)
      48 |  
      49 |  BaseIndex::~BaseIndex()
      50 |  {
      51 | -    Interrupt();
      52 | -    Stop();
    


    domob1812 commented at 4:09 PM on August 5, 2018:

    You could check here that m_thread_sync is not joinable, to enforce that subclasses actually stop the thread as they should.


    MarcoFalke commented at 4:13 PM on August 5, 2018:

    This is done by ~thread, which std::terminates on that occasion.


    domob1812 commented at 4:32 PM on August 5, 2018:

    Yes indeed. Would it make sense to add a brief comment somewhere mentioning this? It would certainly have helped clarify it for me.

  5. MarcoFalke closed this on Aug 5, 2018

  6. MarcoFalke deleted the branch on Aug 5, 2018
  7. DrahtBot locked this on Sep 8, 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-17 06:15 UTC

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