diff options
author | Enrico Granata <egranata@apple.com> | 2015-07-21 00:38:25 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2015-07-21 00:38:25 +0000 |
commit | fbecf1ab1a4fb16ae9e3c06b9b0ea00180c5ffc6 (patch) | |
tree | 1366a4cce852484f9fb08d5ae00c55dac79574fb /lldb/source/Interpreter/ScriptInterpreterPython.cpp | |
parent | c7ae3e03e26be3a9b1d0d373b9087abe1d4b4bd1 (diff) | |
download | bcm5719-llvm-fbecf1ab1a4fb16ae9e3c06b9b0ea00180c5ffc6.tar.gz bcm5719-llvm-fbecf1ab1a4fb16ae9e3c06b9b0ea00180c5ffc6.zip |
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
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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 |