Skip to content
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

_PyGC_ClearAllFreeLists called while other threads may be running #116397

Closed
colesbury opened this issue Mar 6, 2024 · 0 comments
Closed

_PyGC_ClearAllFreeLists called while other threads may be running #116397

colesbury opened this issue Mar 6, 2024 · 0 comments
Assignees
Labels
3.13 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error

Comments

@colesbury
Copy link
Contributor

colesbury commented Mar 6, 2024

Bug report

In the free-threaded GC, we currently call _PyGC_ClearAllFreeLists() after other threads are resumed. That's not safe because the other threads may be using their own freelists at that point.

// Clear free lists in all threads
_PyGC_ClearAllFreeLists(interp);

We should probably move the call earlier, such as immediately after handle_resurrected_objects

err = handle_resurrected_objects(state);
_PyEval_StartTheWorld(interp);

(Alternatively, we could make each thread responsible for clearing it's own freelist, but that seems more complicated given the current implementation)

cc @corona10

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-free-threading type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants