[Lldb-commits] [lldb] r307942 - Fix a deadlock in the Python interpreter vrs. SIGINT.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 13 12:45:54 PDT 2017


Author: jingham
Date: Thu Jul 13 12:45:54 2017
New Revision: 307942

URL: http://llvm.org/viewvc/llvm-project?rev=307942&view=rev
Log:
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>

Modified:
    lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp

Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=307942&r1=307941&r2=307942&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)
+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Thu Jul 13 12:45:54 2017
@@ -539,7 +539,7 @@ private:
   std::string m_repeat_command; // Stores the command that will be executed for
                                 // an empty command string.
   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;
   char m_comment_char;
   bool m_batch_command_mode;

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=307942&r1=307941&r2=307942&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jul 13 12:45:54 2017
@@ -2475,7 +2475,7 @@ void CommandInterpreter::HandleCommandsF
 }
 
 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 (!can_create)
       return nullptr;




More information about the lldb-commits mailing list