]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-116522: Stop the world before fork() and during shutdown (#116607)
authorSam Gross <colesbury@gmail.com>
Thu, 21 Mar 2024 14:01:16 +0000 (10:01 -0400)
committerGitHub <noreply@github.com>
Thu, 21 Mar 2024 14:01:16 +0000 (10:01 -0400)
commite728303532168efab7694c55c82ea19b18bf8385
treee715ba949d2dff22a62c42b175b4e4676f68565e
parent1f8b24ef69896680d6ba6005e75e1cc79a744f9e
gh-116522: Stop the world before fork() and during shutdown (#116607)

This changes the free-threaded build to perform a stop-the-world pause
before deleting other thread states when forking and during shutdown.
This fixes some crashes when using multiprocessing and during shutdown
when running with `PYTHON_GIL=0`.

This also changes `PyOS_BeforeFork` to acquire the runtime lock
(i.e., `HEAD_LOCK(&_PyRuntime)`) before forking to ensure that data
protected by the runtime lock (and not just the GIL or stop-the-world)
is in a consistent state before forking.
Modules/posixmodule.c
Python/pylifecycle.c
Python/pystate.c