Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python: Add a missing Py_INCREF() in nxt_python_start()
On some Python 3.11 systems, 3.11.9 & 3.11.10, we were seeing a crash triggered by Py_Finalize() in nxt_python_start() when running one of our pytests, namely test/test_python_factory.py::test_python_factory_invalid_callable_value 2024/09/12 15:07:29 [alert] 5452#5452 factory "wsgi_invalid_callable" in module "wsgi" can not be called to fetch callable Fatal Python error: none_dealloc: deallocating None: bug likely caused by a refcount error in a C extension Python runtime state: finalizing (tstate=0x00007f560b88a718) Current thread 0x00007f560bde7ad0 (most recent call first): <no Python frame> 2024/09/12 15:07:29 [alert] 5451#5451 app process 5452 exited on signal 6 (core dumped) It seems this was caused by Py_XDECREF(nxt_py_stderr_flush); in nxt_python_atexit(). We never explicitly INCREF() this variable (though there are plenty of other cases of doing DECREF()'s with no previous INCREF()'s). However in this case adding an INCREF() for this variable does fix the crash. I'm not sure we really need to reference count this variable, it's only used in nxt_python_print_exception(), but it's perhaps the safest course of action. Cc: Konstantin Pavlov <[email protected]> Closes: #1413 Signed-off-by: Andrew Clayton <[email protected]>
- Loading branch information