Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -85,7 +85,7 @@ return static_cast(script_interpreter); } -static bool g_initialized = false; +static std::atomic g_initialized(false); namespace { @@ -3194,11 +3194,12 @@ #endif void ScriptInterpreterPythonImpl::InitializePrivate() { - if (g_initialized) + bool initialized = false; + const bool exchanged = + g_initialized.compare_exchange_strong(initialized, true); + if (!exchanged) return; - g_initialized = true; - LLDB_SCOPED_TIMER(); // RAII-based initialization which correctly handles multiple-initialization,