You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
commit 9769b7ae064a0546a98cbcbec2561dbaba20cd23 (HEAD)
Author: Petr Viktorin <encukou@gmail.com>
Date: Mon Jun 24 20:24:19 2024 +0200
[3.13] gh-113993: Allow interned strings to be mortal, and fix related issues (GH-120520) (GH-120945)
Thanks for the bisect!
Immortalizing in intern_strings (a.k.a. the first part of the diff) fixes this for me. That is used for names and localsplusnames; it should be OK to immortalize those (and accept that the memory for these strings will not be reclaimed if the code object is GCd). See discussion in #113993.
PR: #121903
intern_strings(PyObject *tuple) looks suspect to me, not because of the interning, but because it modifies a tuple.
That is risky as other code might (rightly) assume that tuples are immutable.
Have you tried having it return a new tuple?
Activity
da-woods commentedon Jul 16, 2024
Just checking - the code here crashes when run with Python and you don't need to compile with Cython to get the bug?
vstinner commentedon Jul 16, 2024
Regression introduced by commit 9769b7a.
cc @encukou
vstinner commentedon Jul 16, 2024
The reproducer doesn't need Cython at all. Only these few lines of Python code without any import.
vstinner commentedon Jul 16, 2024
The bug can be worked around by reverting codeobject.c changes:
pythongh-121863: Immortalize names in code objects to avoid crash
encukou commentedon Jul 17, 2024
Thanks for the bisect!
Immortalizing in
intern_strings(a.k.a. the first part of the diff) fixes this for me. That is used for names and localsplusnames; it should be OK to immortalize those (and accept that the memory for these strings will not be reclaimed if the code object is GCd). See discussion in #113993.PR: #121903
markshannon commentedon Jul 17, 2024
intern_strings(PyObject *tuple)looks suspect to me, not because of the interning, but because it modifies a tuple.That is risky as other code might (rightly) assume that tuples are immutable.
Have you tried having it return a new tuple?
encukou commentedon Jul 17, 2024
I'll investigate that. I'd still like to merge the quick partial revert for 3.13.0b4 today.
gh-121863: Immortalize names in code objects to avoid crash (GH-121903)
pythongh-121863: Immortalize names in code objects to avoid crash (py…
[3.13] gh-121863: Immortalize names in code objects to avoid crash (G…
encukou commentedon Jul 18, 2024
intern_stringscan indeed modify existing tuples. It's not a 3.13 regression, so I filed a new issue: #121954The regression is fixed, to the best of my knowledge.
[3.12] pythongh-121863: Immortalize names in code objects to avoid cr…