mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
[3.14] gh-134557: Suppress immortalization in _PyCode_GetScriptXIData under free-threading (gh134738)
Disable immortalization around Py_CompileString*(). The same approach as332356bthat fixed the refleaks in compile() and eval(). E:09e72cfcan pass test_capi, test_sys and test__interpchannels with this patch for me. (cherry picked from commitc60f39ada6, AKA gh-134686) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
This commit is contained in:
parent
bc3d892113
commit
c6cc28299e
1 changed files with 7 additions and 0 deletions
|
|
@ -908,8 +908,15 @@ get_script_xidata(PyThreadState *tstate, PyObject *obj, int pure,
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
#ifdef Py_GIL_DISABLED
|
||||||
|
// Don't immortalize code constants to avoid memory leaks.
|
||||||
|
((_PyThreadStateImpl *)tstate)->suppress_co_const_immortalization++;
|
||||||
|
#endif
|
||||||
code = Py_CompileStringExFlags(
|
code = Py_CompileStringExFlags(
|
||||||
script, filename, Py_file_input, &cf, optimize);
|
script, filename, Py_file_input, &cf, optimize);
|
||||||
|
#ifdef Py_GIL_DISABLED
|
||||||
|
((_PyThreadStateImpl *)tstate)->suppress_co_const_immortalization--;
|
||||||
|
#endif
|
||||||
Py_XDECREF(ref);
|
Py_XDECREF(ref);
|
||||||
if (code == NULL) {
|
if (code == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue