[Lldb-commits] [lldb] r160008 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp
Enrico Granata
egranata at apple.com
Tue Jul 10 11:23:49 PDT 2012
Author: enrico
Date: Tue Jul 10 13:23:48 2012
New Revision: 160008
URL: http://llvm.org/viewvc/llvm-project?rev=160008&view=rev
Log:
<rdar://problem/11751427> Fixing an issue where multiple threads could concurrently try and initialize Python and cause crashes
Modified:
lldb/trunk/source/Interpreter/CommandInterpreter.cpp
Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=160008&r1=160007&r2=160008&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Jul 10 13:23:48 2012
@@ -2390,6 +2390,16 @@
ScriptInterpreter *
CommandInterpreter::GetScriptInterpreter ()
{
+ // <rdar://problem/11751427>
+ // we need to protect the initialization of the script interpreter
+ // otherwise we could end up with two threads both trying to create
+ // their instance of it, and for some languages (e.g. Python)
+ // this is a bulletproof recipe for disaster!
+ // this needs to be a function-level static because multiple Debugger instances living in the same process
+ // still need to be isolated and not try to initialize Python concurrently
+ static Mutex *interpreter_mutex = new Mutex(Mutex::eMutexTypeRecursive);
+ Mutex::Locker interpreter_lock(*interpreter_mutex);
+
if (m_script_interpreter_ap.get() != NULL)
return m_script_interpreter_ap.get();
More information about the lldb-commits
mailing list