-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
GC aborts in debug no-gil build #126312
Comments
Confirmed on the main branch and 3.13. Interestingly, this doesn't seem to happen on any other objects passed to |
The easiest fix would be to disallow |
That doesn't seem to fix it on my end. It looks like freezing is entirely broken on the free-threaded builds: import gc
gc.freeze()
0/0 # Abort |
I will test it and try to fix it when I have time. (This does not affect other people to fix it.) |
Ah, I found the problem. The free-threaded GC only ignores a block if that object itself is frozen, but triggering the |
So, there are actually two bugs at play here. One is the problem that I described above, but then another is that objects that have deferred reference counting enabled seem to have some weird issues when getting frozen. A small reproducer for that: import gc
import unittest
class Test(unittest.TestCase):
def test_something(self):
gc.freeze()
gc.collect()
gc.unfreeze()
if __name__ == "__main__":
unittest.main()
Edit: OK, nevermind. As it turns out, the fix was easy. My PR now fixes freezing for DRC as well. |
…126338) Also, _PyGC_Freeze() no longer freezes unreachable objects. Co-authored-by: Sergey B Kirpichev <[email protected]>
…eaded build (pythonGH-126338) Also, _PyGC_Freeze() no longer freezes unreachable objects. (cherry picked from commit d4c72fe) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]>
…build (GH-126338) (#126866) * Fix merge conflicts. * [3.13] gh-126312: Don't traverse frozen objects on the free-threaded build (GH-126338) Also, _PyGC_Freeze() no longer freezes unreachable objects. (cherry picked from commit d4c72fe) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Sergey B Kirpichev <[email protected]> --------- Co-authored-by: Sergey B Kirpichev <[email protected]>
The two reproducer scripts of the first message no longer crash Python. I close the issue. Thanks @devdanzin for the bug report and @ZeroIntensity for the fix. |
…uild (python#126338) Also, _PyGC_Freeze() no longer freezes unreachable objects. Co-authored-by: Sergey B Kirpichev <[email protected]>
Crash report
What happened?
In debug no-gil builds with
PYTHON_GIL=0
, it's possible to trigger the three assertions here with simple code:cpython/Python/gc_free_threading.c
Lines 550 to 558 in c84a136
For this code:
We get:
For this code:
We get:
Lastly, for code I haven't minimized yet (but can, if it helps), we get:
Found using fusil by @vstinner.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ experimental free-threading build (heads/main:d467d9246c, Nov 1 2024, 09:05:56) [GCC 11.4.0]
Linked PRs
The text was updated successfully, but these errors were encountered: