New submission from Devin Jeanpierre:

If another thread is active during interpreter shutdown, it can hold the last 
reference to a handler; when it drops that reference, the weakref callback -- 
_removeHandlerRef -- will be executed in this other thread. So while this 
callback is running, the main thread is replacing module globals with None. 
This creates a data race for the globals in logging -- for example, 
_releaseLock can be replaced with None after the "_releaseLock is not None" 
check, but before it is used.

In principle I suspect this could cause a deadlock, in practice all I've seen 
are exception messages mentioning how None is not callable.

I have attached a patch that I think resolves this issue. The patch is written 
against 2.7, although I expect this issue affects all versions of Python prior 
to 3.4

BTW, the copyright for this patch belongs to my employer, Google; please let me 
know if there are any contributor agreements or such that my employer needs to 
look at.

----------
components: Library (Lib)
files: patch.diff
keywords: patch
messages: 215466
nosy: Devin Jeanpierre, gregory.p.smith
priority: normal
severity: normal
status: open
title: logging._removeHandlerRef is not threadsafe during interpreter shutdown
versions: Python 2.7
Added file: http://bugs.python.org/file34718/patch.diff

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

Reply via email to