diff --git a/intern/guardedalloc/intern/memory_usage.cc b/intern/guardedalloc/intern/memory_usage.cc index 71987ac38d9..0848250b264 100644 --- a/intern/guardedalloc/intern/memory_usage.cc +++ b/intern/guardedalloc/intern/memory_usage.cc @@ -52,10 +52,15 @@ struct alignas(64) Local { * This is a singleton that stores global data. */ struct Global { + ~Global() + { + locals_mutex_alive = false; + } /** * Mutex that protects the vector below. */ std::mutex locals_mutex; + bool locals_mutex_alive{true}; /** * All currently constructed #Local. This must only be accessed when the mutex above is * locked. Individual threads insert and remove themselves here. @@ -128,6 +133,7 @@ Local::Local() Local::~Local() { Global &global = get_global(); + assert(global.locals_mutex_alive); std::lock_guard lock{global.locals_mutex}; /* Unregister self from the global list. */