[Python-Dev] PyThreadState_Delete vs PyThreadState_DeleteCurrent

Gabriel Becedillas lists at core-sdi.com
Tue Jan 10 19:27:02 CET 2006


Hi,
I started hitting Py_FatalError("Invalid thread state for this thread") 
in pystate.c when a thread bootstraps since my upgrade to Python 2.4.2 
(was using 2.4.1 previously).
I'm embedding Python in C++, using multiple interpreters and threads.
I think the problem is that PyThreadState_Delete (which is used when I 
destroy thread states and interpreters) is not making the same clean up 
that PyThreadState_DeleteCurrent is doing:

if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
	PyThread_delete_key_value(autoTLSkey);

If a thread id is reused (and this often happens), and the previous 
thread used PyThreadState_Delete instead of PyThreadState_DeleteCurrent, 
  an old and invalid value for autoTLSkey is stored, and that is 
triggering the Py_FatalError.
Thanks.

-- 


Gabriel Becedillas
Developer
CORE SECURITY TECHNOLOGIES

Florida 141 - 2º cuerpo - 7º piso
C1005AAC Buenos Aires - Argentina
Tel/Fax: (54 11) 5032-CORE (2673)
http://www.corest.com


More information about the Python-Dev mailing list