You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Possible RecursionError during signal cleanup #294
I've tried running the test suite with Python 3.8.0a3 (on Fedora 30, pytest-cov master, pytest==4.5.0, coverage==4.5.3). While digging into failures I noticed the following race condition.
Solving it doesn't quite fix the tests for me, but I believe it's valid.
Trace when cleanup is called (with _cleanup_in_progress False and _pending_signal None):
_cleanup_in_progress = True
a signal is delivered now
_signal_cleanup_handler runs
_cleanup_in_progress is True, so the handler only sets _pending_signal
_cleanup(_active_cov) runs
_active_cov = None
_cleanup_in_progress = False
_pending_signal is set, so we call _signal_cleanup_handler(), with _cleanup_in_progress False and _pending_signal set:
_cleanup_in_progress is False, so we call cleanup():
_cleanup_in_progress = True
_cleanup(_active_cov)
_active_cov = None
_cleanup_in_progress = False
_pending_signal is still set, so call _signal_cleanup_handler(), again with _cleanup_in_progress False and _pending_signal set. This leads to infinite recursion.
The solution could be setting _cleanup_in_progress = False after the if _pending_signal block, or setting _pending_signal = None before calling _signal_cleanup_handler.
I'm not very familiar with the code and what it's trying to do, so I don't know what a good fix would be (if any).
Activity
ionelmc commentedon May 15, 2019
Hmmm indeed. This should fix it:
The goal of that contrived code was to avoid signal handling to interrupt coverage's shutdown machinery (it's fragile).
Avoid getting into infinite recursion when clearing off _pending_sign…
Oooof ... fix this finally (save it into a variable that doesn't get …
Merge #97
Merge #77
Merge #12 #13 #14
Merge #12
Merge #16
Merge #5
Merge #22 #23
Merge #6
Merge #22 #23