-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Refleaks on free-threaded builds #134557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yeah, I'll be home soon and will take a look. |
Any ideas on why there would be leaks only on free-threaded builds? Also, FWIW, the leaks may actually originate in gh-133482. |
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. |
Ah, @ericsnowcurrently, this looks like a leak: cpython/Modules/_interpretersmodule.c Line 233 in 77eade3
|
I tried adding a decref after that but the tests still show a refleak. |
FWIW, the results have been consistent for me across runs, so it doesn't seem like a race is involved. |
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.) |
While reviewing the new code, I saw that cpython/Modules/_interpretersmodule.c Lines 877 to 885 in 393773a
should use Py_SETREF instead. I don't think it's the cause of the leak though
|
In test_capi (test_capi.test_misc), the leak is manifesting exclusively in test_isolated_subinterpreter (specifically the first two subtests). |
I minimized the leaky test in test_capi. The following leaks: def test_subinterp_leak(self):
interpid = _interpreters.create()
self.addCleanup(lambda: _interpreters.destroy(interpid))
timeout = time.time() + 30
_interpreters.run_string(interpid, f"""if True:
import time
time.time() < {timeout}
""") but the following does not: def test_subinterp_leak(self):
interpid = _interpreters.create()
self.addCleanup(lambda: _interpreters.destroy(interpid))
timeout = 30000000000
_interpreters.run_string(interpid, f"""if True:
import time
time.time() < {timeout}
""") nor does: def test_subinterp_leak(self):
interpid = _interpreters.create()
self.addCleanup(lambda: _interpreters.destroy(interpid))
_interpreters.run_string(interpid, f"""if True:
import time
time.time() < 30000000000
""") |
I'm reverting for now, but I suspect there's still an existing leak to be fixed. |
FWIW the valgrind report for your minimal reproducer is:
So perhaps an interpreter is not getting freed? |
It should be freed during test cleanup. |
At least for test_sys and test_capi, only scripts built using the |
Ugh, why is it that subinterpreter changes seem to cause undebuggable buildbot failures. I can't reproduce a leak when running that test manually with import _interpreters
import time
interpid = _interpreters.create()
timeout = time.time() + 30
_interpreters.run_string(interpid, f"""if True:
import time
time.time() < {timeout}
""")
_interpreters.destroy(interpid) |
Are you using a free-threading build? |
Yeah, I'm getting |
|
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
The nogil refleak buildbots have started failing for main and 3.14 with leaks in
test_sys
,test_capi
and a few others.See e.g. https://buildbot.python.org/#/builders/1714/builds/90
I bisected this to 09e72cf, cc @ericsnowcurrently
CPython versions tested on:
CPython main branch, 3.14
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: