Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System tests: fix hang #7373

Closed
Tom-Willemsen opened this issue Sep 21, 2022 · 1 comment
Closed

System tests: fix hang #7373

Tom-Willemsen opened this issue Sep 21, 2022 · 1 comment
Assignees
Labels

Comments

@Tom-Willemsen
Copy link
Contributor

Where?

As a developer I would like the system_tests and system_tests_debug builds on the build server not to hang and therefore hit timeouts.

How to Test

verbose instructions for reviewer to test changes
(Add before making a PR)

@Tom-Willemsen
Copy link
Contributor Author

Tom-Willemsen commented Sep 22, 2022

Hang is in python interpreter exit, specifically here: https://github.com/python/cpython/blob/3.10/Python/pylifecycle.c#L2017. This makes it quite tricky to debug using standard python tooling, as if you connect a debugger the bug will move to debugger exit rather than program exit, and the hang is not in python code anyway. I had more success connecting the VS debugger to python (with appropriate symbols loaded) to get to the bottom of this.

We have a deadlock due to a subtle behaviour change in python 3.9+; before python 3.9. a ThreadPoolExecutor would join all of it's threads using an atexit hook. Because atexit hooks are run in LIFO order, as long as we added an exit hook for stopping infinite processes after importing threading (which was the case), our hook would run first, and this meant we could set a flag to stop the thread. Now in python 3.9+, there is a separate threading._register_atexit hook that is run before all atexit hooks, and this is now where ThreadPoolExecutor attempts to join it's worker thread(s). So we now have a deadlock because python won't run our atexit hook until all threads are stopped, but the thread won't stop until we run our atexit hook.

@Tom-Willemsen Tom-Willemsen changed the title System tests: make pass System tests: fix hang Sep 22, 2022
@Tom-Willemsen Tom-Willemsen added 5 and removed 3 labels Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants