Fix a deadlock in the Python interpreter vrs. SIGINT.

The interpreter gets invoked in the sigint handler to cancel
long-running Python operations.  That requires the interpreter
lock, but that may be held by the Python operation that's getting
interrupted, so the mutex needs to be recursive.

<rdar://problem/33179086>

llvm-svn: 307942
This commit is contained in:
Jim Ingham 2017-07-13 19:45:54 +00:00
parent 28a4d0b981
commit 30bac79162
2 changed files with 2 additions and 2 deletions

View File

@ -539,7 +539,7 @@ private:
std::string m_repeat_command; // Stores the command that will be executed for std::string m_repeat_command; // Stores the command that will be executed for
// an empty command string. // an empty command string.
lldb::ScriptInterpreterSP m_script_interpreter_sp; lldb::ScriptInterpreterSP m_script_interpreter_sp;
std::mutex m_script_interpreter_mutex; std::recursive_mutex m_script_interpreter_mutex;
lldb::IOHandlerSP m_command_io_handler_sp; lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char; char m_comment_char;
bool m_batch_command_mode; bool m_batch_command_mode;

View File

@ -2475,7 +2475,7 @@ void CommandInterpreter::HandleCommandsFromFile(
} }
ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) { ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
std::lock_guard<std::mutex> locker(m_script_interpreter_mutex); std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
if (!m_script_interpreter_sp) { if (!m_script_interpreter_sp) {
if (!can_create) if (!can_create)
return nullptr; return nullptr;