File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ static SignpostEmitter &signposts();
57
57
static sys::SmartMutex<true > &timerLock ();
58
58
static TimerGroup &defaultTimerGroup ();
59
59
static Name2PairMap &namedGroupedTimers ();
60
+ static bool isTimerGlobalsConstructed ();
60
61
61
62
// ===----------------------------------------------------------------------===//
62
63
//
@@ -305,14 +306,26 @@ TimerGroup::~TimerGroup() {
305
306
PrintQueuedTimers (*OutStream);
306
307
}
307
308
309
+ auto unlink = [&]() {
310
+ *Prev = Next;
311
+ if (Next)
312
+ Next->Prev = Prev;
313
+ };
314
+
315
+ // TimerGlobals is always created implicity, through a call to timerLock(),
316
+ // when a TimeGroup is created. On CRT shutdown, the TimerGlobals instance
317
+ // might have been destroyed already. Avoid re-creating it if calling
318
+ // timerLock().
319
+ if (!isTimerGlobalsConstructed ()) {
320
+ unlink ();
321
+ return ;
322
+ }
323
+
308
324
// Remove the group from the TimerGroupList.
309
325
sys::SmartScopedLock<true > L (timerLock ());
310
- *Prev = Next;
311
- if (Next)
312
- Next->Prev = Prev;
326
+ unlink ();
313
327
}
314
328
315
-
316
329
void TimerGroup::removeTimer (Timer &T) {
317
330
sys::SmartScopedLock<true > L (timerLock ());
318
331
@@ -557,3 +570,7 @@ void TimerGroup::constructForStatistics() {
557
570
}
558
571
559
572
void *TimerGroup::acquireTimerGlobals () { return ManagedTimerGlobals.claim (); }
573
+
574
+ static bool isTimerGlobalsConstructed () {
575
+ return ManagedTimerGlobals.isConstructed ();
576
+ }
You can’t perform that action at this time.
0 commit comments