KEMBAR78
Fix deadlock on shutdown if test_current_{exception,frames} fails by jbower-fb · Pull Request #102019 · python/cpython · GitHub
Skip to content

Conversation

@jbower-fb
Copy link
Contributor

@jbower-fb jbower-fb commented Feb 18, 2023

These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads.

The solution is just to put the code in a try-finally block, with the existing clean-up in the finally.

@swtaarrs found and fixed this originally while working on Cinder.

Hopefully this is trivial enough to not need an issue or a NEWS blurb.

@bedevere-bot bedevere-bot added awaiting review tests Tests in the Lib/test dir labels Feb 18, 2023
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

jbower-fb and others added 2 commits February 23, 2023 13:25
These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads.

Co-authored-by: Brett Simmers <bsimmers@meta.com>
@DinoV DinoV merged commit 0c85786 into python:main Feb 23, 2023
@jbower-fb jbower-fb deleted the fix-deadlock branch February 23, 2023 23:33
JelleZijlstra pushed a commit to JelleZijlstra/cpython that referenced this pull request Sep 10, 2024
…thon#102019)

* Don't deadlock on shutdown if test_current_{exception,frames} fails

These tests spawn a thread that waits on a threading.Event. If the test fails any of its assertions, the Event won't be signaled and the thread will wait indefinitely, causing a deadlock when threading._shutdown() tries to join all outstanding threads.

Co-authored-by: Brett Simmers <bsimmers@meta.com>

* Add a news entry

* Fix whitespace

---------

Co-authored-by: Brett Simmers <bsimmers@meta.com>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip issue tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants