miner: Avoid stack-use-after-return in validationinterface
Summary:
This is a squash of 2 commits, to add the unbroken test and the solution
at the same time, and a revert of D5140 (different solution to the same problem)
test: Add unregister_validation_interface_race test
https://github.com/bitcoin/bitcoin/pull/18742/commits/fab6d060ce5f580db538070beec1c5518c8c777c
miner: Avoid stack-use-after-return in validationinterface
This is achieved by switching to a shared_ptr.
Also, switch the validationinterfaces in the tests to use shared_ptrs
for the same reason.
https://github.com/bitcoin/bitcoin/pull/18742/commits/7777f2a4bb1f9d843bc50a4e35085cfbb2808780
This is a backport of Core PR18742 [3/3]
This replaces the solution in D5140
See comment https://reviews.bitcoinabc.org/D5140#124338
Depends on D9104
Test Plan:
Test suggested by this PR:
export ASAN_OPTIONS=detect_leaks=0 ninja && ninja check while ./src/test/test_bitcoin -t validationinterface_tests/unregister_validation_interface_race --catch_system_errors=no ; do true; done
Test from D5140:
CC=clang CXX=clang++ cmake -GNinja .. -DCMAKE_BUILD_TYPE=Debug ninja check-extended
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D9105