From cf30c239bf45dd303261aed39eeec2a02d64f865 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Sun, 27 Jun 2021 21:10:57 -0500 Subject: [PATCH] env_settings cleanup fix (#206) * fixes deleting env_settings on main thread when malloc/free wrapping via gotcha is activated * fix to cupti_pcsampling compilation * tweaks to some tests which fail in windows linux subsystem * bumped version to 3.2.0rc3 - fixed free corruption when deleting env_settings and mallocp is enabled - increased the util tolerance in timing_tests - fixed cache_tests.io in Windows Linux Subsystem (/proc//io not available) --- VERSION | 2 +- source/tests/cache_tests.cpp | 3 +++ source/tests/timing_tests.cpp | 2 +- source/timemory/components/cupti/backends.hpp | 7 ++++--- source/timemory/environment/definition.hpp | 15 +++++---------- source/timemory/storage/declaration.hpp | 3 +++ 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index df3834160..3760a13d2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.0.rc2 +3.2.0.rc3 diff --git a/source/tests/cache_tests.cpp b/source/tests/cache_tests.cpp index 003180e8e..b84ca3678 100644 --- a/source/tests/cache_tests.cpp +++ b/source/tests/cache_tests.cpp @@ -217,6 +217,7 @@ class cache_tests : public ::testing::Test trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); } static void extra_teardown() @@ -559,6 +560,8 @@ get_value(Arg&) #if defined(TIMEMORY_LINUX) TEST_F(cache_tests, io) { + if(!std::ifstream{ TIMEMORY_JOIN('/', "/proc", tim::process::get_target_id(), "io") }) + return; using io_bundle_t = tim::component_tuple; using timing_t = tim::auto_tuple; diff --git a/source/tests/timing_tests.cpp b/source/tests/timing_tests.cpp index bcc9c0721..5f9b73803 100644 --- a/source/tests/timing_tests.cpp +++ b/source/tests/timing_tests.cpp @@ -39,7 +39,7 @@ using namespace tim::component; using mutex_t = std::mutex; using lock_t = std::unique_lock; -static const double util_tolerance = 5.0; +static const double util_tolerance = 12.5; static const double timer_tolerance = 0.025; #define CHECK_AVAILABLE(type) \ diff --git a/source/timemory/components/cupti/backends.hpp b/source/timemory/components/cupti/backends.hpp index d3c426117..c55cc4f17 100644 --- a/source/timemory/components/cupti/backends.hpp +++ b/source/timemory/components/cupti/backends.hpp @@ -31,9 +31,10 @@ # include "timemory/backends/cupti.hpp" # include # include -# if defined(TIMEMORY_USE_CUPTI_PCSAMPLING) -# include -# endif +#endif + +#if defined(TIMEMORY_USE_CUPTI_PCSAMPLING) +# include #endif #include diff --git a/source/timemory/environment/definition.hpp b/source/timemory/environment/definition.hpp index 68ff2b4bc..9ad15c590 100644 --- a/source/timemory/environment/definition.hpp +++ b/source/timemory/environment/definition.hpp @@ -339,22 +339,17 @@ TIMEMORY_ENVIRONMENT_LINKAGE(tim::env_settings*) env_settings::instance() { static std::atomic _count{ 0 }; - static env_settings* _instance = new env_settings(); - static thread_local int _id = _count++; + static env_settings _instance{}; + static thread_local int _id = _count++; static thread_local env_settings* _local = - (_id == 0) ? _instance : new env_settings{ _instance, _id }; + (_id == 0) ? (&_instance) : new env_settings{ &_instance, _id }; static thread_local auto _ldtor = scope::destructor{ []() { - if(_local == _instance) - _instance = nullptr; + if(_local == &_instance || _id == 0) + return; delete _local; _local = nullptr; } }; - static auto _gdtor = scope::destructor{ []() { - delete _instance; - _instance = nullptr; - } }; return _local; - (void) _gdtor; (void) _ldtor; } // diff --git a/source/timemory/storage/declaration.hpp b/source/timemory/storage/declaration.hpp index 763239ba7..007ee54e6 100644 --- a/source/timemory/storage/declaration.hpp +++ b/source/timemory/storage/declaration.hpp @@ -899,6 +899,9 @@ struct storage_deleter : public std::default_delete void operator()(StorageType* ptr) { + // if(ptr == nullptr) + // return; + StorageType* master = singleton_t::master_instance_ptr(); std::thread::id master_tid = singleton_t::master_thread_id(); std::thread::id this_tid = std::this_thread::get_id();