-
-
Notifications
You must be signed in to change notification settings - Fork 32k
Subclass of extension type with reference cycle sometimes never gets GC'd on free-threaded build #125853
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
Does this occur in main as well or just 3.13? Type objects are immortalized in 3.13. This happens after the first non-main thread is created, which might make it non-deterministic with your tests. https://docs.python.org/3.13/howto/free-threading-python.html#immortalization |
I don't think any Python threads are launched by the rust tests. Maybe that's something we should try though! I just tried with a fresh build of 3.14t-dev from pyenv and I can reproduce the same issue it if I make the following additional modification to bypass the check for the maximum supported python version: diff --git a/pyo3-ffi/build.rs b/pyo3-ffi/build.rs
index 622c2707..cc7c8a30 100644
--- a/pyo3-ffi/build.rs
+++ b/pyo3-ffi/build.rs
@@ -18,7 +18,7 @@ const SUPPORTED_VERSIONS_CPYTHON: SupportedVersions = SupportedVersions {
min: PythonVersion { major: 3, minor: 7 },
max: PythonVersion {
major: 3,
- minor: 13,
+ minor: 14,
},
};
|
I'm able to reproduce the issue on 3.14 along with what looks like another assertion failure.
The tests suite runs in multiple threads concurrently, right? It doesn't matter that the threads are not created by Python's threading module. If the thread calls |
Ah, in that case it definitely is happening, any call to |
@ngoldbaum - I think this may be fixed now in 3.13 and main. I had thought that the following was a different bug: But fixing that issue seems to also avoid the "Object was not dropped" failures. I guess it makes sense that corrupting GC internal state sometimes leads to leaks in addition to crashes. Would you please verify that the issue is now fixed? |
I just let the test I shared in the issue description run for a minute and it never crashed on both 3.13t-dev and 3.14t-dev. Before it would always crash within 10 seconds maximum, so I think I would call this fixed. Closing the issue. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
ping @colesbury
Apply the following diff on top of the current PyO3 main branch:
Then do:
Eventually, one or both tests modified by the diff above will fail:
assert_drops_with_gc
does 100 loops of callinggc.collect()
and then sleeping for five milliseconds. There are other tests that make use of the same infrastructure and they always complete quickly on my machine without getting anywhere close to 100 iterations. You can also increase the hard-coded 100 in the for loop to an arbitrarily large number and the object never gets GC'd in my testing, even after waiting for longer than a minute.See PyO3/pyo3#4627 for the PyO3 issue, which has some additional details.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
The text was updated successfully, but these errors were encountered: