Author: enrico
Date: Tue Feb  4 21:19:01 2014
New Revision: 200816

URL: http://llvm.org/viewvc/llvm-project?rev=200816&view=rev
Log:
<rdar://problem/15936507>

ScriptInterpreterPython caches the lldb.embedded_interpreter module, and since 
it caches it in a refcounting-safe PythonObject, the refcount will 
appropriately go down 1 every time a ScriptInterpreterPython is deallocated
However, we were only importing the module once - in InitializePrivate(). In a 
handful of interpreter creations, the refcount on the run_one_line function 
would end up at 0, causing LLDB to crash
This fixes it by also importing the module for every interpreter, which ensures 
correct refcounting


Modified:
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=200816&r1=200815&r2=200816&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Feb  4 
21:19:01 2014
@@ -190,13 +190,17 @@ ScriptInterpreterPython::ScriptInterpret
     run_string.Clear();
     run_string.Printf ("run_one_line (%s, 'import lldb.formatters, 
lldb.formatters.cpp, pydoc')", m_dictionary_name.c_str());
     PyRun_SimpleString (run_string.GetData());
+    run_string.Clear();
 
     int new_count = Debugger::TestDebuggerRefCount();
     
     if (new_count > old_count)
         Debugger::Terminate();
 
+    run_string.Printf ("run_one_line (%s, 'import lldb.embedded_interpreter; 
from lldb.embedded_interpreter import run_python_interpreter; from 
lldb.embedded_interpreter import run_one_line')", m_dictionary_name.c_str());
+    PyRun_SimpleString (run_string.GetData());
     run_string.Clear();
+    
     run_string.Printf ("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64 
"; pydoc.pager = pydoc.plainpager')", m_dictionary_name.c_str(),
                        interpreter.GetDebugger().GetID());
     PyRun_SimpleString (run_string.GetData());
@@ -645,15 +649,9 @@ ScriptInterpreterPython::ExecuteOneLine
                     PythonObject pargs (Py_BuildValue("(Os)", 
session_dict.get(), command));
                     if (pargs)
                     {
-                        PythonObject return_value;
-                        { // scope for PythonInputReaderManager
-                            //PythonInputReaderManager 
py_input(options.GetEnableIO() ? this : NULL);
-                            return_value.Reset(PyObject_CallObject (pfunc, 
pargs.get()));
-                        }
+                        PythonObject return_value(PyObject_CallObject (pfunc, 
pargs.get()));
                         if (return_value)
-                        {
                             success = true;
-                        }
                         else if (options.GetMaskoutErrors() && PyErr_Occurred 
())
                         {
                             PyErr_Print();


_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to