File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ static SignpostEmitter &signposts();
5757static sys::SmartMutex<true > &timerLock ();
5858static TimerGroup &defaultTimerGroup ();
5959static Name2PairMap &namedGroupedTimers ();
60+ static bool isTimerGlobalsConstructed ();
6061
6162// ===----------------------------------------------------------------------===//
6263//
@@ -305,14 +306,24 @@ TimerGroup::~TimerGroup() {
305306 PrintQueuedTimers (*OutStream);
306307 }
307308
309+ auto unlink = [&]() {
310+ *Prev = Next;
311+ if (Next)
312+ Next->Prev = Prev;
313+ };
314+
315+ // If the managed instance is already dead, it means we're in the CRT
316+ // destruction, so no need to lock.
317+ if (!isTimerGlobalsConstructed ()) {
318+ unlink ();
319+ return ;
320+ }
321+
308322 // Remove the group from the TimerGroupList.
309323 sys::SmartScopedLock<true > L (timerLock ());
310- *Prev = Next;
311- if (Next)
312- Next->Prev = Prev;
324+ unlink ();
313325}
314326
315-
316327void TimerGroup::removeTimer (Timer &T) {
317328 sys::SmartScopedLock<true > L (timerLock ());
318329
@@ -557,3 +568,7 @@ void TimerGroup::constructForStatistics() {
557568}
558569
559570void *TimerGroup::acquireTimerGlobals () { return ManagedTimerGlobals.claim (); }
571+
572+ static bool isTimerGlobalsConstructed () {
573+ return ManagedTimerGlobals.isConstructed ();
574+ }
You can’t perform that action at this time.
0 commit comments