[3.12] gh-116510: Fix a Crash Due to Shared Immortal Interned Strings (gh-124865)
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. (cherry picked from commit f2cb39947093feda3ff85b8dc820922cc5e5f954)
Co-authored-by: Eric Snow [email protected]
- Issue: gh-116510
@nascheme I thought the backport wouldn't apply cleanly, but here we are. Do you recall what was different about the 3.12 fix?
Please don't merge until the TraceRefs regression is fixed: https://github.com/python/cpython/pull/124865#issuecomment-2404820325
I think this can be merged now with GH-125709 applied on top or squashed into it.
@ericsnowcurrently, is this the way you'd do it in 3.12?
:robot: New build scheduled with the buildbot fleet by @encukou for commit e9591b2f3d5ab4c75d4ca4f6d14a01db3767889c :robot:
If you want to schedule another build, you need to add the :hammer: test-with-buildbots label again.
The failed buildbots aren't applicable to 3.12, or fail for unrelated & pre-existing reasons.
@ericsnowcurrently, is this the way you'd do it in 3.12?
This should be good to go. It is backport of gh-124865 + gh-125709. There shouldn't be anything particular to 3.12 that would need to be addressed differently.