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
obj needs to decref'd on the successful path. I'm not sure if that's the cause of the buildbots failures, though. No idea why it would only fail under free-threading (maybe it's because the object structure is bigger?)
_PyCode_Fini() seems to follow _PyXI_Exit(), which would affect the stat?
(Unlike main, 09e72cf runs _PyCode_Init() and _PyCode_Fini() on different threads.)
Activity
[-]refleaks on free-threaded builds[/-][+]Refleaks on free-threaded builds[/+]ericsnowcurrently commentedon May 23, 2025
Yeah, I'll be home soon and will take a look.
ericsnowcurrently commentedon May 23, 2025
Any ideas on why there would be leaks only on free-threaded builds?
Also, FWIW, the leaks may actually originate in gh-133482.
ZeroIntensity commentedon May 23, 2025
Hm, I don't see any obvious leaks on the PRs. I wouldn't be surprised if it only revealed an existing leak on free-threading.
ZeroIntensity commentedon May 23, 2025
Ah, @ericsnowcurrently, this looks like a leak:
cpython/Modules/_interpretersmodule.c
Line 233 in 77eade3
objneeds to decref'd on the successful path. I'm not sure if that's the cause of the buildbots failures, though. No idea why it would only fail under free-threading (maybe it's because the object structure is bigger?)emmatyping commentedon May 23, 2025
I tried adding a decref after that but the tests still show a refleak.
ericsnowcurrently commentedon May 23, 2025
FWIW, the results have been consistent for me across runs, so it doesn't seem like a race is involved.
ericsnowcurrently commentedon May 23, 2025
It may be due to interned strings. The only refleak-failing test in test_sys is test_subinterp_intern_dynamically_allocated.
(Thus this is more likely to be an existing bug than one introduced yesterday.)
picnixz commentedon May 23, 2025
While reviewing the new code, I saw that
cpython/Modules/_interpretersmodule.c
Lines 877 to 885 in 393773a
should use
Py_SETREFinstead. I don't think it's the cause of the leak thoughericsnowcurrently commentedon May 23, 2025
In test_capi (test_capi.test_misc), the leak is manifesting exclusively in test_isolated_subinterpreter (specifically the first two subtests).
9 remaining items
ZeroIntensity commentedon May 24, 2025
Yeah, I'm getting
[0 refs, 0 blocks]on both FT or GIL-ful builds.neonene commentedon May 24, 2025
_PyCode_Init()->intern_one_constant(), which interns the floattimeout:cpython/Objects/codeobject.c
Lines 3088 to 3095 in 7b1010a
_PyCode_Fini():cpython/Objects/codeobject.c
Lines 3245 to 3252 in 7b1010a
_interpreters.run_string()->_PyXI_Exit()->_exit_session():cpython/Python/crossinterp.c
Lines 2345 to 2351 in 7b1010a
_PyCode_Fini()seems to follow_PyXI_Exit(), which would affect the stat?(Unlike main, 09e72cf runs
_PyCode_Init()and_PyCode_Fini()on different threads.)ericsnowcurrently commentedon May 26, 2025
Thanks for tracking down the leak, @neonene! That's some impressive sleuthing.
Revert "[3.14] pythongh-134557: Revert "[3.14] pythongh-132775: Use _…
gh-134557: Suppress immortalization in _PyCode_GetScriptXIData under …
pythongh-134557: Suppress immortalization in _PyCode_GetScriptXIData …
[3.14] gh-134557: Suppress immortalization in _PyCode_GetScriptXIData…
pythongh-134557: Revert "pythongh-132775: Use _PyCode GetScriptXIData…
pythongh-134557: Suppress immortalization in _PyCode_GetScriptXIData …
pythongh-134557: Revert "pythongh-132775: Use _PyCode GetScriptXIData…
pythongh-134557: Suppress immortalization in _PyCode_GetScriptXIData …
pythongh-134557: Revert "pythongh-132775: Use _PyCode GetScriptXIData…
pythongh-134557: Suppress immortalization in _PyCode_GetScriptXIData …