Fix memory access violation in tests
Summary:
Fix the memory access violations, such as:
unknown location(0): fatal error: in "wallet_tests/rescan": memory access violation at address: 0x0000001f: no mapping at fault address ../src/wallet/test/wallet_tests.cpp(34): last checkpoint: "rescan" fixture ctor *** 1 failure is detected in the test module "Bitcoin Test Suite" test_bitcoin: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:116: boost::condition_variable::~condition_variable(): Assertion `!ret' failed. Aborted (core dumped)
~TestingSetup calls UnloadBlockIndex() which deletes the
mapBlockIndex but does not reset the pindexBestForkTip and
pindexBestForkBase pointers. When a test then calls
ProcessNewBlock() (such as validation_block_tests), the callstack
leads to the CheckForkWarningConditions() where these pointers are
read, causing the fault.
Test Plan:
Should never fail:
for i in {1..100} do # This combination is known to exhibit the issue frequently ./src/test/test_bitcoin -t validation_block_tests,wallet_tests done
Reviewers: #bitcoin_abc, deadalnix, jasonbcox
Reviewed By: #bitcoin_abc, jasonbcox
Differential Revision: https://reviews.bitcoinabc.org/D3570