[New-bugs-announce] [issue17263] crash when tp_dealloc allows other threads

Albert Zeyer report at bugs.python.org
Thu Feb 21 03:37:51 CET 2013


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 <report at bugs.python.org>
<http://bugs.python.org/issue17263>
_______________________________________


More information about the New-bugs-announce mailing list