mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
gh-110481: Fix Py_SET_REFCNT() integer overflow (#112174)
If Py_NOGIL is defined and Py_SET_REFCNT() is called with a reference
count larger than UINT32_MAX, make the object immortal.
Set _Py_IMMORTAL_REFCNT constant type to Py_ssize_t to fix the
following compiler warning:
Include/internal/pycore_global_objects_fini_generated.h:14:24:
warning: comparison of integers of different signs: 'Py_ssize_t'
(aka 'long') and 'unsigned int' [-Wsign-compare]
if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) {
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
This commit is contained in:
parent
c2982380f8
commit
5f6ac2d88a
3 changed files with 26 additions and 10 deletions
|
|
@ -34,6 +34,9 @@ of Python objects.
|
|||
|
||||
Set the object *o* reference counter to *refcnt*.
|
||||
|
||||
On :ref:`Python build with Free Threading <free-threading-build>`, if
|
||||
*refcnt* is larger than ``UINT32_MAX``, the object is made :term:`immortal`.
|
||||
|
||||
This function has no effect on :term:`immortal` objects.
|
||||
|
||||
.. versionadded:: 3.9
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue