Ghidra is a software reverse engineering (SRE) framework
Fix ASAN static initialization order fiasco
Eric Kilmer1c2323cad380
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/test.ccindex 660f069400..603aaa5bb8 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.cc@@ -18,8 +18,6 @@namespace ghidra {-vector<UnitTest *> UnitTest::tests;-/// Run all the tests unless a non-empty set of names is passed in./// In which case, only the named tests in the set are run./// \param testNames is the set of names@@ -30,7 +28,7 @@ int UnitTest::run(set<string> &testNames)int total = 0;int passed = 0;- for(auto &t : UnitTest::tests) {+ for(auto &t : UnitTest::tests()) {if (testNames.size() > 0 && testNames.find(t->name) == testNames.end()) {continue;}diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hhindex 27c27bc218..adf0e618a4 100644--- a/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/test.hh@@ -53,7 +53,6 @@ typedef void (*testfunc_t)(); ///< A unit-test function/// The static run() method calls all the function pointers of all instantiated/// objects.struct UnitTest {- static vector<UnitTest *> tests; ///< The collection of test objectsstring name; ///< Name of the testtestfunc_t func; ///< Call-back function executing the test@@ -64,7 +63,13 @@ struct UnitTest {UnitTest(const string &name,testfunc_t func) :name(name), func(func){- tests.push_back(this);+ tests().push_back(this);+ }++ /// \brief The collection of test objects+ static vector<UnitTest *> & tests() {+ static vector<UnitTest *> tests;+ return tests;}static int run(set<string> &testNames); ///< Run all the instantiated tests