From e96838e3044b5b6034def3a859775d36a1e31867 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 8 Aug 2014 23:20:25 +0000 Subject: Fix some python shutdown / ordering issues. Differential Revision: http://reviews.llvm.org/D4826 Reviewed by: Enrico Granata llvm-svn: 215256 --- lldb/source/Interpreter/ScriptInterpreterPython.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp') diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index ec541b14a90d..598bab3f8fdc 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -1806,7 +1806,11 @@ ScriptInterpreterPython::Clear () Locker locker(this, ScriptInterpreterPython::Locker::AcquireLock, ScriptInterpreterPython::Locker::FreeAcquiredLock); - PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process = None; lldb.thread = None; lldb.frame = None"); + + // This may be called as part of Py_Finalize. In that case the modules are destroyed in random + // order and we can't guarantee that we can access these. + if (Py_IsInitialized()) + PyRun_SimpleString("lldb.debugger = None; lldb.target = None; lldb.process = None; lldb.thread = None; lldb.frame = None"); } bool -- cgit v1.2.3