[Lldb-commits] [lldb] r200486 - Fixed b18655: cleaned up script interpreter file reference handling.
Todd Fiala
tfiala at google.com
Thu Jan 30 12:19:23 PST 2014
Author: tfiala
Date: Thu Jan 30 14:19:22 2014
New Revision: 200486
URL: http://llvm.org/viewvc/llvm-project?rev=200486&view=rev
Log:
Fixed b18655: cleaned up script interpreter file reference handling.
This change addresses shutdown crashes in the python lldb module when
the script interpreter was hanging on to saved file references after
leaving a session. It also gets rid of extra references to the
stdin/stdout/stderr python file objects that are created when entering
the session.
This change also moves the bundled pyexpect 2.4 library to the front
of the python library path so that a python distribution default
pyexpect (2.3 in Ubuntu 12.04) is not picked up first.
Modified:
lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
lldb/trunk/test/dotest.py
Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=200486&r1=200485&r2=200486&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Jan 30 14:19:22 2014
@@ -352,11 +352,20 @@ ScriptInterpreterPython::LeaveSession ()
if (sys_module_dict)
{
if (m_saved_stdin)
+ {
sys_module_dict.SetItemForKey("stdin", m_saved_stdin);
+ m_saved_stdin.Reset ();
+ }
if (m_saved_stdout)
+ {
sys_module_dict.SetItemForKey("stdout", m_saved_stdout);
+ m_saved_stdout.Reset ();
+ }
if (m_saved_stderr)
+ {
sys_module_dict.SetItemForKey("stderr", m_saved_stderr);
+ m_saved_stderr.Reset ();
+ }
}
}
@@ -422,8 +431,10 @@ ScriptInterpreterPython::EnterSession (b
if (in)
{
m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
-
- sys_module_dict.SetItemForKey ("stdin", PyFile_FromFile (in, (char *) "", (char *) "r", 0));
+
+ PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", 0);
+ sys_module_dict.SetItemForKey ("stdin", new_file);
+ Py_DECREF (new_file);
}
else
m_saved_stdin.Reset();
@@ -433,7 +444,10 @@ ScriptInterpreterPython::EnterSession (b
if (out)
{
m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout"));
- sys_module_dict.SetItemForKey ("stdout", PyFile_FromFile (out, (char *) "", (char *) "w", 0));
+
+ PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", 0);
+ sys_module_dict.SetItemForKey ("stdout", new_file);
+ Py_DECREF (new_file);
}
else
m_saved_stdout.Reset();
@@ -443,10 +457,13 @@ ScriptInterpreterPython::EnterSession (b
if (err)
{
m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr"));
- sys_module_dict.SetItemForKey ("stderr", PyFile_FromFile (err, (char *) "", (char *) "w", 0));
+
+ PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", 0);
+ sys_module_dict.SetItemForKey ("stderr", new_file);
+ Py_DECREF (new_file);
}
else
- m_saved_stdout.Reset();
+ m_saved_stderr.Reset();
}
if (PyErr_Occurred())
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=200486&r1=200485&r2=200486&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Jan 30 14:19:22 2014
@@ -873,10 +873,13 @@ def setupSysPath():
pluginPath = os.path.join(scriptPath, 'plugins')
pexpectPath = os.path.join(scriptPath, 'pexpect-2.4')
- # Append script dir, plugin dir, and pexpect dir to the sys.path.
+ # Put embedded pexpect at front of the load path so we ensure we
+ # use that version.
+ sys.path.insert(0, pexpectPath)
+
+ # Append script dir and plugin dir to the sys.path.
sys.path.append(scriptPath)
sys.path.append(pluginPath)
- sys.path.append(pexpectPath)
# This is our base name component.
base = os.path.abspath(os.path.join(scriptPath, os.pardir))
More information about the lldb-commits
mailing list