mirror of
https://github.com/python/cpython.git
synced 2025-12-31 12:33:28 +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
|
|
@ -24,7 +24,13 @@ struct _py_object_state {
|
|||
* together via the _ob_prev and _ob_next members of a PyObject, which
|
||||
* exist only in a Py_TRACE_REFS build.
|
||||
*/
|
||||
PyObject refchain;
|
||||
PyObject *refchain;
|
||||
/* In most cases, refchain points to _refchain_obj.
|
||||
* In sub-interpreters that share objmalloc state with the main interp,
|
||||
* refchain points to the main interpreter's _refchain_obj, and their own
|
||||
* _refchain_obj is unused.
|
||||
*/
|
||||
PyObject _refchain_obj;
|
||||
#endif
|
||||
int _not_used;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -132,15 +132,8 @@ extern PyTypeObject _PyExc_MemoryError;
|
|||
.context_ver = 1, \
|
||||
}
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
# define _py_object_state_INIT(INTERP) \
|
||||
{ \
|
||||
.refchain = {&INTERP.object_state.refchain, &INTERP.object_state.refchain}, \
|
||||
}
|
||||
#else
|
||||
# define _py_object_state_INIT(INTERP) \
|
||||
{ 0 }
|
||||
#endif
|
||||
|
||||
|
||||
// global objects
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue