diff options
author | Enrico Granata <egranata@apple.com> | 2012-07-10 18:23:48 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2012-07-10 18:23:48 +0000 |
commit | a29bdad954d5439e03ee5f3ac4f844b90be1411e (patch) | |
tree | 6abe777eed37ea2b2386cda344a0dae20931a425 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | 3ee9a4c29edcad02aacdb56e601cc2ff85fbd26a (diff) | |
download | bcm5719-llvm-a29bdad954d5439e03ee5f3ac4f844b90be1411e.tar.gz bcm5719-llvm-a29bdad954d5439e03ee5f3ac4f844b90be1411e.zip |
<rdar://problem/11751427> Fixing an issue where multiple threads could concurrently try and initialize Python and cause crashes
llvm-svn: 160008
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 13493bfedcf..fb26fc493b4 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2390,6 +2390,16 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file, 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(); |