New submission from Albert Zeyer:

If you have some Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS in some tp_dealloc 
and you use such objects in thread local storage, you might get crashes, 
depending on which thread at what time is trying to cleanup such object.

I haven't fully figured out the details but I have a somewhat reduced testcase. 
Note that I encountered this in practice because the sqlite connection object 
does that (while it disconnects, the GIL is released).

This is the C code with some dummy type which has a tp_dealloc which just 
sleeps for some seconds while the GIL is released: 
https://github.com/albertz/playground/blob/master/testcrash_python_threadlocal.c

This is the Python code: 
https://github.com/albertz/playground/blob/master/testcrash_python_threadlocal_py.py

The Python code also contains some code path with a workaround which I'm using 
currently to avoid such crashes in my application.

----------
components: Interpreter Core
messages: 182577
nosy: Albert.Zeyer
priority: normal
severity: normal
status: open
title: crash when tp_dealloc allows other threads
type: crash
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17263>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to