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

gh-104341: Minor Fixes in the _thread Module #104595

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ericsnowcurrently
Copy link
Member

This is primarily cleanup in preparation for the fix for gh-104341. However, in the process I found and fixed the following:

  • PyThreadState_Delete() wasn't called at the bottom of thread_PyThread_start_new_thread()`
  • the thread count (PyInterpreterState.threads.count) wasn't getting reset after fork
  • the PyInterpreterState.threads.count field was effectively leaking the state of the threading module out into the broader runtime
  • in thread_run(), the bootstate variable wasn't freed if its a daemon thread that exits early (due to interp finalizing)

other observations:

  • unlike with bootstate, there isn't much we can do about leaking the func/args/kwargs objects in the similar case
  • in threading._after_fork(), we update thread._ident but don't update thread._native_id

@ericsnowcurrently ericsnowcurrently changed the title gh-104341: Minor Fixes in the threading Module gh-104341: Minor Fixes in the _thread Module May 18, 2023
@ericsnowcurrently ericsnowcurrently marked this pull request as draft May 18, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants