gh-149816: #96 Fix a race condition in invoke_gc_callback with free threading#150029
Draft
dzaramelcone wants to merge 1 commit into
Draft
gh-149816: #96 Fix a race condition in invoke_gc_callback with free threading#150029dzaramelcone wants to merge 1 commit into
dzaramelcone wants to merge 1 commit into
Conversation
… with free threading
|
The following commit authors need to sign the Contributor License Agreement: |
22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The optimization that avoided allocating an info dict when no gc callbacks were registered introduces a time of check to time of use race in free threaded mode (lineno 1943-1955). I just pulled out the check. Since info is always non-null, I also replaced XDECREF use with DECREF. (lineno 1959, lineno 1982).
I implemented a stress test for this and uncovered what I believe to be a bug with
_PyList_GetItemRef. I am following suit with python/cpython#149909 and not including the test with my PR for two reasons:_PyList_GetItemRef(but I'm happy to open an issue for it!)also, this is my first PR against CPython, I am doing it from PyCon US as part of the sprint! :) Hello world!