From 6b6d2a85732007aa9d267a590d0eadb091762459 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Thu, 28 Apr 2022 09:51:57 -0700 Subject: [PATCH] Fix crash when flushing events to disk at exit. The event "name" field references a literal within an object that could be destroy before the event writter is finished using it at program exit. This fix ensures the "name" field is always copied whose lifetime is the same as the buffer. --- src/gpgmm/TraceEvent.cpp | 2 +- src/gpgmm/TraceEvent.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gpgmm/TraceEvent.cpp b/src/gpgmm/TraceEvent.cpp index 6d160e7d7..96e1ba2a1 100644 --- a/src/gpgmm/TraceEvent.cpp +++ b/src/gpgmm/TraceEvent.cpp @@ -53,7 +53,7 @@ namespace gpgmm { TraceEvent::TraceEvent(char phase, TraceEventCategory category, - const char* name, + const std::string& name, uint64_t id, uint32_t tid, double timestamp, diff --git a/src/gpgmm/TraceEvent.h b/src/gpgmm/TraceEvent.h index 39f21fafd..9f09fa3b3 100644 --- a/src/gpgmm/TraceEvent.h +++ b/src/gpgmm/TraceEvent.h @@ -153,7 +153,7 @@ namespace gpgmm { public: TraceEvent(char phase, TraceEventCategory category, - const char* name, + const std::string& name, uint64_t id, uint32_t tid, double timestamp, @@ -165,7 +165,7 @@ namespace gpgmm { char mPhase = 0; TraceEventCategory mCategory; - const char* mName = nullptr; + std::string mName; uint64_t mID = 0; uint32_t mTID = 0; double mTimestamp = 0;