HomePhabricator

Merge #13894: shutdown: Stop threads before resetting ptrs

Description

Merge #13894: shutdown: Stop threads before resetting ptrs

Summary:
PR13894 backport https://github.com/bitcoin/bitcoin/pull/13894/files
faab63111d8f27335aa1f09c1a48da3be45135de shutdown: Stop threads before resetting ptrs (MarcoFalke)

Pull request description:

On shutdown some threads would continue to run after or during a pointer reset. This leads to occasional segfaults on shutdown.

Fix this by resetting the smart pointers after all threads that might read from them have been stopped.

This should fix:
* A segfault in the txindex thread, that occurs when the txindex destructor is done, but the thread was not yet stopped (as this is done in the base index destructor)
* A segfault in the scheduler thread, which dereferences conman. (e.g. CheckForStaleTipAndEvictPeers)

Test Plan: make check

Reviewers: jasonbcox, Fabien, #bitcoin_abc, deadalnix

Reviewed By: jasonbcox, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3123

Details

Provenance
Wladimir J. van der Laan <laanwj@gmail.com>Authored on May 27 2019, 13:58
Mark Lundeberg <36528214+markblundeberg@users.noreply.github.com>Committed on May 27 2019, 13:59
markblundebergPushed on May 27 2019, 13:59
Reviewer
Restricted Project
Differential Revision
D3123: Merge #13894: shutdown: Stop threads before resetting ptrs
Parents
rABC23ae291d3e83: Expose method to find key for a single-key destination
Branches
Unknown
Tags
Unknown