[New-bugs-announce] [issue42913] asyncio.ProactorEventLoop mishandles signal wakeup file descriptor
report at bugs.python.org
Tue Jan 12 16:43:53 EST 2021
New submission from Michel Hidalgo <hid.michel at gmail.com>:
asyncio.ProactorEventLoop uses a socket.socketpair and signal.set_wakeup_fd to wake up a loop that's polling I/O. However it does so with no consideration for file descriptors previously set (i.e. no signal number forwarding). Either by user code or by another instance of asyncio.ProactorEventLoop.
The following snippet is enough for the above to cause the loop to hang forever:
The first asyncio.ProactorEventLoop instance sets a signal wakeup file descriptor on construction (see https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L632). The second instances does the same, dropping the file descriptor set by the first one (not good, not necessarily bad). When the garbage collector purges the first instance, signal wakeups are disabled completely (see https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L679). The loop cannot be interrupted with Ctrl+C anymore (bad).
components: Windows, asyncio
nosy: asvetlov, hidmic, paul.moore, steve.dower, tim.golden, yselivanov, zach.ware
title: asyncio.ProactorEventLoop mishandles signal wakeup file descriptor
versions: Python 3.8
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce