mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-104690 Disallow thread creation and fork at interpreter finalization (#104826)
Disallow thread creation and fork at interpreter finalization. in the following functions, check if interpreter is finalizing and raise `RuntimeError` with appropriate message: * `_thread.start_new_thread` and thus `threading` * `posix.fork` * `posix.fork1` * `posix.forkpty` * `_posixsubprocess.fork_exec` when a `preexec_fn=` is supplied. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
parent
eaff9c39aa
commit
ce558e69d4
8 changed files with 97 additions and 30 deletions
|
@ -1155,6 +1155,11 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
|||
"thread is not supported for isolated subinterpreters");
|
||||
return NULL;
|
||||
}
|
||||
if (interp->finalizing) {
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
"can't create new thread at interpreter shutdown");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bootstate *boot = PyMem_NEW(struct bootstate, 1);
|
||||
if (boot == NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue