Skip to content

bpo-39877: Fix PyEval_RestoreThread() for daemon threads#18811

Merged
vstinner merged 1 commit intopython:masterfrom
vstinner:daemon_thread_runtime2
Mar 8, 2020
Merged

bpo-39877: Fix PyEval_RestoreThread() for daemon threads#18811
vstinner merged 1 commit intopython:masterfrom
vstinner:daemon_thread_runtime2

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Mar 6, 2020

  • exit_thread_if_finalizing() does now access directly _PyRuntime
    variable, rather than using tstate->interp->runtime since tstate
    can be a dangling pointer after Py_Finalize() has been called.
  • exit_thread_if_finalizing() is now called before calling
    take_gil(). There is no need to protect the call with the GIL.
  • Add ENSURE_TSTATE_NOT_NULL() macro to check that tstate is not NULL
    at runtime. Check tstate earlier. take_gil() is now responsible to
    check that tstate is not NULL.

Cleanup:

  • PyEval_RestoreThread() no longer saves/restores errno: it's already
    done inside take_gil().
  • PyEval_AcquireLock(), PyEval_AcquireThread(),
    PyEval_RestoreThread() and _PyEval_EvalFrameDefault() now check if
    tstate is valid with the new is_tstate_valid() function which uses
    _PyMem_IsPtrFreed().

https://bugs.python.org/issue39877

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants