[pykd_ext_2.0] fixed : issue 14066 (dbgCommand('q') leads to windbg hung)

git-svn-id: https://pykd.svn.codeplex.com/svn@91173 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2017-02-23 11:42:16 +00:00 committed by Mikhail I. Izmestev
parent ad9a59f3b0
commit 2049c751a0
2 changed files with 13 additions and 21 deletions

View File

@ -144,11 +144,7 @@ public:
PythonInterpreter(PyModule* mod) : PythonInterpreter(PyModule* mod) :
m_module(mod) m_module(mod)
{ {
PyThreadState* state = mod->Py_NewInterpreter(); m_state = mod->Py_NewInterpreter();
m_module->PyThreadState_Swap(state);
m_state = m_module->PyEval_SaveThread();
} }
~PythonInterpreter() ~PythonInterpreter()
@ -214,6 +210,7 @@ public:
if (module->m_globalInterpreter == 0) if (module->m_globalInterpreter == 0)
{ {
module->PyEval_RestoreThread(module->m_globalState); module->PyEval_RestoreThread(module->m_globalState);
module->checkPykd();
module->m_globalInterpreter = new PythonInterpreter(module); module->m_globalInterpreter = new PythonInterpreter(module);
} }
@ -223,12 +220,12 @@ public:
else else
{ {
module->PyEval_RestoreThread(module->m_globalState); module->PyEval_RestoreThread(module->m_globalState);
module->checkPykd();
m_currentInterpreter = new PythonInterpreter(module); m_currentInterpreter = new PythonInterpreter(module);
m_currentIsGlobal = false; m_currentIsGlobal = false;
} }
m_currentInterpreter->m_module->PyEval_RestoreThread(m_currentInterpreter->m_state); module->PyThreadState_Swap(m_currentInterpreter->m_state);
m_currentInterpreter->m_module->checkPykd();
return m_currentInterpreter; return m_currentInterpreter;
} }
@ -242,7 +239,6 @@ public:
if (!m_currentIsGlobal) if (!m_currentIsGlobal)
{ {
delete m_currentInterpreter; delete m_currentInterpreter;
module->PyThreadState_Swap(module->m_globalState); module->PyThreadState_Swap(module->m_globalState);
module->m_globalState = module->PyEval_SaveThread(); module->m_globalState = module->PyEval_SaveThread();
} }
@ -255,11 +251,6 @@ public:
return m_modules.find(std::make_pair(majorVersion, minorVersion)) != m_modules.end(); return m_modules.find(std::make_pair(majorVersion, minorVersion)) != m_modules.end();
} }
void checkPykd()
{
m_currentInterpreter->m_module->checkPykd();
}
void stopAllInterpreter() void stopAllInterpreter()
{ {
for (auto m : m_modules) for (auto m : m_modules)
@ -490,6 +481,8 @@ PyModule::PyModule(int majorVesion, int minorVersion)
Py_Initialize(); Py_Initialize();
PyEval_InitThreads(); PyEval_InitThreads();
checkPykd();
m_globalState = PyEval_SaveThread(); m_globalState = PyEval_SaveThread();
} }
@ -518,9 +511,13 @@ void PyModule::deactivate()
{ {
delete m_globalInterpreter; delete m_globalInterpreter;
m_globalInterpreter = 0; m_globalInterpreter = 0;
}
PyThreadState_Swap(m_globalState); PyThreadState_Swap(m_globalState);
}
else
{
PyEval_RestoreThread(m_globalState);
}
if (m_pykdInit) if (m_pykdInit)
{ {
@ -597,11 +594,6 @@ void stopAllInterpreter()
PythonSingleton::get()->stopAllInterpreter(); PythonSingleton::get()->stopAllInterpreter();
} }
void checkPykd()
{
PythonSingleton::get()->checkPykd();
}
void __stdcall Py_IncRef(PyObject* object) void __stdcall Py_IncRef(PyObject* object)
{ {
PythonSingleton::get()->currentInterpreter()->m_module->Py_IncRef(object); PythonSingleton::get()->currentInterpreter()->m_module->Py_IncRef(object);

View File

@ -3,7 +3,7 @@
#define PYKDEXT_VERSION_MAJOR 2 #define PYKDEXT_VERSION_MAJOR 2
#define PYKDEXT_VERSION_MINOR 0 #define PYKDEXT_VERSION_MINOR 0
#define PYKDEXT_VERSION_SUBVERSION 0 #define PYKDEXT_VERSION_SUBVERSION 0
#define PYKDEXT_VERSION_BUILDNO 8 #define PYKDEXT_VERSION_BUILDNO 9
#define __VER_STR2__(x) #x #define __VER_STR2__(x) #x
#define __VER_STR1__(x) __VER_STR2__(x) #define __VER_STR1__(x) __VER_STR2__(x)