From fbecf1ab1a4fb16ae9e3c06b9b0ea00180c5ffc6 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 21 Jul 2015 00:38:25 +0000 Subject: 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 llvm-svn: 242745 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 8f60793550c..88b98f66a79 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -212,6 +212,14 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete 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 -- cgit v1.2.3