aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-15 14:37:51 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-04-15 14:38:02 -0400
commit4bd6bc5cb4f3c4b017cc0ac21c00c2218acb97d0 (patch)
tree4016a23cc98cf80a18634ba582999f0d438b397b /src/test
parent20c0e2e0f04f699d29419d52696601b76eca3124 (diff)
parentfa176e253fb473767c61d4d8cd2d93e87d71a015 (diff)
Merge #18615: test: Avoid accessing free'd memory in validation_chainstatemanager_tests
fa176e253fb473767c61d4d8cd2d93e87d71a015 test: Avoid accessing free'd memory in validation_chainstatemanager_tests (MarcoFalke) Pull request description: ACKs for top commit: ryanofsky: Code review ACK fa176e253fb473767c61d4d8cd2d93e87d71a015, though if you have to update this again, would suggest separating txindex test cleanup and the chainstatemanager test fix in separate commits, or identifying which part of the change is the bugfix fix in the commit description. Also to clean up the txindex test it might make sense to call SyncWithValidationInterfaceQueue in the test destructor to prevent nondeterminism in other tests Tree-SHA512: 34c5dca283a7c205cd42b6aa59f00a71fd1bd980bc3d6640a18b280be11470bfabb2fd8c93fadde6fb8e084bcf96c80ec3aa72bbccccfde8a8260d173eaad08f
Diffstat (limited to 'src/test')
-rw-r--r--src/test/txindex_tests.cpp8
-rw-r--r--src/test/validation_chainstatemanager_tests.cpp9
2 files changed, 8 insertions, 9 deletions
diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp
index 3550a02316..721e3498e6 100644
--- a/src/test/txindex_tests.cpp
+++ b/src/test/txindex_tests.cpp
@@ -70,12 +70,8 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
// shutdown sequence (c.f. Shutdown() in init.cpp)
txindex.Stop();
- // txindex job may be scheduled, so stop scheduler before destructing
- m_node.scheduler->stop();
- threadGroup.interrupt_all();
- threadGroup.join_all();
-
- // Rest of shutdown sequence and destructors happen in ~TestingSetup()
+ // Let scheduler events finish running to avoid accessing any memory related to txindex after it is destructed
+ SyncWithValidationInterfaceQueue();
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/test/validation_chainstatemanager_tests.cpp b/src/test/validation_chainstatemanager_tests.cpp
index 6e7186db22..e79ae1f4d5 100644
--- a/src/test/validation_chainstatemanager_tests.cpp
+++ b/src/test/validation_chainstatemanager_tests.cpp
@@ -3,12 +3,13 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
//
#include <chainparams.h>
-#include <random.h>
-#include <uint256.h>
#include <consensus/validation.h>
+#include <random.h>
#include <sync.h>
#include <test/util/setup_common.h>
+#include <uint256.h>
#include <validation.h>
+#include <validationinterface.h>
#include <vector>
@@ -97,7 +98,9 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
exp_tip = c1.m_chain.Tip();
BOOST_CHECK_EQUAL(validated_tip, exp_tip);
- // Avoid triggering the address sanitizer.
+ // Let scheduler events finish running to avoid accessing memory that is going to be unloaded
+ SyncWithValidationInterfaceQueue();
+
WITH_LOCK(::cs_main, manager.Unload());
}