mirror of
https://github.com/python/cpython.git
synced 2025-12-31 20:43:36 +00:00
[3.12] gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-125205)
Fix a crash caused by immortal interned strings being shared between
sub-interpreters that use basic single-phase init. In that case, the string
can be used by an interpreter that outlives the interpreter that created and
interned it. For interpreters that share obmalloc state, also share the
interned dict with the main interpreter.
This is an un-revert of gh-124646 that then addresses the Py_TRACE_REFS
failures identified by gh-124785 (i.e. backporting gh-125709 too).
(cherry picked from commit f2cb399470, AKA gh-124865)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
b49e902b81
commit
49da170709
10 changed files with 124 additions and 20 deletions
|
|
@ -907,6 +907,35 @@ always available.
|
|||
It is not guaranteed to exist in all implementations of Python.
|
||||
|
||||
|
||||
.. function:: getobjects(limit[, type])
|
||||
|
||||
This function only exists if CPython was built using the
|
||||
specialized configure option :option:`--with-trace-refs`.
|
||||
It is intended only for debugging garbage-collection issues.
|
||||
|
||||
Return a list of up to *limit* dynamically allocated Python objects.
|
||||
If *type* is given, only objects of that exact type (not subtypes)
|
||||
are included.
|
||||
|
||||
Objects from the list are not safe to use.
|
||||
Specifically, the result will include objects from all interpreters that
|
||||
share their object allocator state (that is, ones created with
|
||||
:c:member:`PyInterpreterConfig.use_main_obmalloc` set to 1
|
||||
or using :c:func:`Py_NewInterpreter`, and the
|
||||
:ref:`main interpreter <sub-interpreter-support>`).
|
||||
Mixing objects from different interpreters may lead to crashes
|
||||
or other unexpected behavior.
|
||||
|
||||
.. impl-detail::
|
||||
|
||||
This function should be used for specialized purposes only.
|
||||
It is not guaranteed to exist in all implementations of Python.
|
||||
|
||||
.. versionchanged:: next
|
||||
|
||||
The result may include objects from other interpreters.
|
||||
|
||||
|
||||
.. function:: getprofile()
|
||||
|
||||
.. index::
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ Debug options
|
|||
Effects:
|
||||
|
||||
* Define the ``Py_TRACE_REFS`` macro.
|
||||
* Add :func:`!sys.getobjects` function.
|
||||
* Add :func:`sys.getobjects` function.
|
||||
* Add :envvar:`PYTHONDUMPREFS` environment variable.
|
||||
|
||||
This build is not ABI compatible with release build (default build) or debug
|
||||
|
|
|
|||
|
|
@ -2301,3 +2301,14 @@ email
|
|||
check if the *strict* paramater is available.
|
||||
(Contributed by Thomas Dwyer and Victor Stinner for :gh:`102988` to improve
|
||||
the CVE-2023-27043 fix.)
|
||||
|
||||
|
||||
Notable changes in 3.12.8
|
||||
=========================
|
||||
|
||||
sys
|
||||
---
|
||||
|
||||
* The previously undocumented special function :func:`sys.getobjects`,
|
||||
which only exists in specialized builds of Python, may now return objects
|
||||
from other interpreters than the one it's called in.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue