HomePhabricator

synchronize validation queue during submitblock

Description

synchronize validation queue during submitblock

Summary:
I was observing some intermittent segfaults of feature_dbcrash
with my debug build, where just after submitblock was called (and
a block was connected): a CValidationInterface was having its
vtable pointer nulled out just as it attempted to execute one of
its background slots (such as UpdatedBlockTip, BlockConnected).

This seems to be the explanation: the boost signals2 system allows
disconnections to happen concurrently with slot execution, thus
the UnregisterValidationInterface can complete and sc can go out
of scope while one of its slots is running. There seems to be a very
tight race involved here, visible due to the debug build slowdown,
and because feature_dbcrash does thousands of submitblock calls.

(It's not quite as tight as just calling an empty function: for each slot
call, there are something like 8 wrappers in between when the
disconnection could be noticed, and when the CValidationInterface
method is actually called.)

https://www.boost.org/doc/libs/1_55_0/doc/html/signals2/thread-safety.html

Test Plan:
I was observing failures in this setup:

CC=clang CXX=clang++ cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug
ninja check-extended

Reviewers: Fabien, #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

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

Details

Provenance
Mark Lundeberg <markblundeberg@users.noreply.github.com>Authored on Feb 3 2020, 16:30
markblundebergPushed on Feb 4 2020, 00:21
Reviewer
Restricted Project
Differential Revision
D5140: synchronize validation queue during submitblock
Parents
rABC34398ab486ea: Ensure the thresold for BIP9 can be configured on a per activation basis.
Branches
Unknown
Tags
Unknown