From 43f900d01e03b9fbbe2b1b7f6d67d4d2c8044c9b Mon Sep 17 00:00:00 2001 From: Sohaib Nadeem Date: Thu, 27 Feb 2025 14:34:52 -0500 Subject: [PATCH] Fix an application crash when collecting performance counters with rocprofiler (#117) * Add check to skip counter_storage::write() if internal storage field is destroyed. * Output warning message if counter data is not available when trying to write out to Timemory --------- Co-authored-by: David Galiffi --- .../lib/rocprof-sys/library/rocprofiler-sdk/counters.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/lib/rocprof-sys/library/rocprofiler-sdk/counters.cpp b/source/lib/rocprof-sys/library/rocprofiler-sdk/counters.cpp index 22b76c7dfd..94977f9597 100644 --- a/source/lib/rocprof-sys/library/rocprofiler-sdk/counters.cpp +++ b/source/lib/rocprof-sys/library/rocprofiler-sdk/counters.cpp @@ -126,6 +126,14 @@ counter_storage::operator()(const counter_event& _event, timing_interval _timing void counter_storage::write() const { + if(!trait::runtime_enabled::get()) + { + ROCPROFSYS_WARNING_F( + 1, "%s counter_data_tracker is disabled. Can't write storage.\n", + metric_name.c_str()); + return; + } + operation::set_storage{}(storage.get()); counter_data_tracker::label() = metric_name; counter_data_tracker::description() = metric_description;