[New-bugs-announce] [issue47195] importlib lock race issue in deadlock handling code
Richard Purdie
report at bugs.python.org
Fri Apr 1 16:23:24 EDT 2022
New submission from Richard Purdie <richard.purdie at linuxfoundation.org>:
We've seen tracebacks in production like:
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load(name='oe.gpg_sign', import_=<built-in function __import__>)
File "<frozen importlib._bootstrap>", line 158, in _ModuleLockManager.__enter__()
File "<frozen importlib._bootstrap>", line 110, in _ModuleLock.acquire()
KeyError: 139622474778432
and
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load(name='oe.path', import_=<built-in function __import__>)
File "<frozen importlib._bootstrap>", line 158, in _ModuleLockManager.__enter__()
File "<frozen importlib._bootstrap>", line 110, in _ModuleLock.acquire()
KeyError: 140438942700992
I've attached a reproduction script which shows that if an import XXX is in progress and waiting at the wrong point when an interrupt arrives (in this case a signal) and triggers it's own import YYY, _blocking_on[tid] in importlib/_bootstrap.py gets overwritten and lost, triggering the traceback we see above upon exit from the second import.
I'm using a signal handler here as the interrupt, I don't know what our production source is as yet but this reproducer proves it is possible.
----------
components: Interpreter Core
files: testit2.py
messages: 416517
nosy: rpurdie
priority: normal
severity: normal
status: open
title: importlib lock race issue in deadlock handling code
versions: Python 3.10
Added file: https://bugs.python.org/file50714/testit2.py
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47195>
_______________________________________
More information about the New-bugs-announce
mailing list