-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Free-threading QSBR delayed free mem fails in high thread turnover environment #130794
Comments
ping @colesbury |
Thanks for the bug report. Typically, each thread periodically processes their queue of memory blocks to be freed. This happens every 254 calls to
The fix is relatively straightforward: when the thread exits and merges its queue into the shared per-interpreter queue, it should also take the opportunity to process the shared queue. |
…yed. This avoids a case where the interpreter's queue of memory to be freed could grow rapidly if there are many short lived threads.
…h-130808) This avoids a case where the interpreter's queue of memory to be freed could grow rapidly if there are many short lived threads.
…donDelayed. (pythongh-130808) This avoids a case where the interpreter's queue of memory to be freed could grow rapidly if there are many short lived threads. (cherry picked from commit 2f6e0e9) Co-authored-by: Sam Gross <colesbury@gmail.com>
Closing as it was fixed by #130808 and backported. |
Crash report
What happened?
When cycling a lot of threads and modifying objects which use
PyMem_FreeDelayed()
in those threads the queues of memory blocks to free build up without ever being freed until the process runs out of memory, unless something else causes them to be freed. For example in the reproducer below commenting in thegc.collect()
or thefor
loop will cause the delayed blocks to be freed correctly. Note that this is an extreme case.Reproducer:
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a5+ experimental free-threading build (heads/main:b3c18bfd828, Mar 3 2025, 09:13:46) [GCC 11.4.0]
Linked PRs
The text was updated successfully, but these errors were encountered: