mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-112729: Correctly fail when the process is out of memory during interpreter creation (GH-139164)
This commit is contained in:
parent
2fd43a1ffe
commit
d06113c7a7
3 changed files with 19 additions and 9 deletions
|
@ -2411,17 +2411,16 @@ new_interpreter(PyThreadState **tstate_p,
|
|||
interpreters: disable PyGILState_Check(). */
|
||||
runtime->gilstate.check_enabled = 0;
|
||||
|
||||
PyInterpreterState *interp = PyInterpreterState_New();
|
||||
if (interp == NULL) {
|
||||
*tstate_p = NULL;
|
||||
return _PyStatus_OK();
|
||||
}
|
||||
_PyInterpreterState_SetWhence(interp, whence);
|
||||
interp->_ready = 1;
|
||||
|
||||
// XXX Might new_interpreter() have been called without the GIL held?
|
||||
PyThreadState *save_tstate = _PyThreadState_GET();
|
||||
PyThreadState *tstate = NULL;
|
||||
PyInterpreterState *interp;
|
||||
status = _PyInterpreterState_New(save_tstate, &interp);
|
||||
if (interp == NULL) {
|
||||
goto error;
|
||||
}
|
||||
_PyInterpreterState_SetWhence(interp, whence);
|
||||
interp->_ready = 1;
|
||||
|
||||
/* From this point until the init_interp_create_gil() call,
|
||||
we must not do anything that requires that the GIL be held
|
||||
|
@ -2498,7 +2497,7 @@ new_interpreter(PyThreadState **tstate_p,
|
|||
*tstate_p = NULL;
|
||||
if (tstate != NULL) {
|
||||
Py_EndInterpreter(tstate);
|
||||
} else {
|
||||
} else if (interp != NULL) {
|
||||
PyInterpreterState_Delete(interp);
|
||||
}
|
||||
if (save_tstate != NULL) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue