[Lldb-commits] [lldb] r242745 - The session dictionary attached to a Python interpeter holds variables the user creates in the script interpreter

Enrico Granata egranata at apple.com
Mon Jul 20 17:38:26 PDT 2015


Author: enrico
Date: Mon Jul 20 19:38:25 2015
New Revision: 242745

URL: http://llvm.org/viewvc/llvm-project?rev=242745&view=rev
Log:
The session dictionary attached to a Python interpeter holds variables the user creates in the script interpreter
This can include objects that have complex state and need to be torn down intelligently (e.g. our SB* objects)

This will fail if the Python interpreter does not hold a valid thread state. So, acquire one, delete the session dictionary, and then let go of it on destruction

This fixes rdar://20960843


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=242745&r1=242744&r2=242745&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Mon Jul 20 19:38:25 2015
@@ -212,6 +212,14 @@ ScriptInterpreterPython::ScriptInterpret
 
 ScriptInterpreterPython::~ScriptInterpreterPython ()
 {
+    // the session dictionary may hold objects with complex state
+    // which means that they may need to be torn down with some level of smarts
+    // and that, in turn, requires a valid thread state
+    // force Python to procure itself such a thread state, nuke the session dictionary
+    // and then release it for others to use and proceed with the rest of the shutdown
+    auto gil_state = PyGILState_Ensure();
+    m_session_dict.Reset();
+    PyGILState_Release(gil_state);
 }
 
 void





More information about the lldb-commits mailing list