Skip to content

Commit 893c37a

Browse files
committed
fix a deadlock when pcm is interrupted during initialization
Change-Id: I1ab9d817ace1bac7e095ff41398ab670fdc54a6b
1 parent 685789b commit 893c37a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/cpucounters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,8 @@ class PCM_API PCM
10641064
bool isRDTDisabled() const;
10651065

10661066
public:
1067+
static bool isInitialized() { return instance != nullptr; }
1068+
10671069
//! check if TMA level 1 metrics are supported
10681070
bool isHWTMAL1Supported() const;
10691071

src/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void exit_cleanup(void)
3232
restore_signal_handlers();
3333

3434
// this replaces same call in cleanup() from util.h
35-
PCM::getInstance()->cleanup(); // this replaces same call in cleanup() from util.h
35+
if (PCM::isInitialized()) PCM::getInstance()->cleanup(); // this replaces same call in cleanup() from util.h
3636

3737
//TODO: delete other shared objects.... if any.
3838

@@ -141,7 +141,7 @@ BOOL sigINT_handler(DWORD fdwCtrlType)
141141

142142
// in case PCM is blocked just return and summary will be dumped in
143143
// calling function, if needed
144-
if (PCM::getInstance()->isBlocked()) {
144+
if (PCM::isInitialized() && PCM::getInstance()->isBlocked()) {
145145
return FALSE;
146146
} else {
147147
exit_cleanup();
@@ -177,7 +177,7 @@ void sigINT_handler(int signum)
177177

178178
// in case PCM is blocked just return and summary will be dumped in
179179
// calling function, if needed
180-
if (PCM::getInstance()->isBlocked()) {
180+
if (PCM::isInitialized() && PCM::getInstance()->isBlocked()) {
181181
return;
182182
} else {
183183
exit_cleanup();

0 commit comments

Comments
 (0)