Repository navigation
gh-152276: Fix assert(!_Py_IsImmortal(op)) failure when BRC merge queue races with sys.intern - #152277
Closed
AnnaAr321 wants to merge 3 commits into
Closed
gh-152276: Fix assert(!_Py_IsImmortal(op)) failure when BRC merge queue races with sys.intern#152277AnnaAr321 wants to merge 3 commits into
assert(!_Py_IsImmortal(op)) failure when BRC merge queue races with sys.intern#152277AnnaAr321 wants to merge 3 commits into
Conversation
…_Py_ExplicitMergeRefcount(PyObject *, Py_ssize_t): !_Py_IsImmortal(op)` Immortal objects don't use refcounts. In the free-threaded build, when `_Py_DecRefShared` reduces an object's shared reference count to zero, it places the object into the interpreter's BRC merge queue. If another thread concurrently makes the object immortal (for example, via `sys.intern()`), `_Py_SetImmortalUntracked()` sets the object's reference fields to immortal constants. Later, when the original thread checks the eval breaker and attempts to merge the queued objects, it encounters the immortalized object and crashes on the assertion.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Member
|
Some comments about this:
|
| @@ -0,0 +1 @@ | |||
| Fix "assert(!_Py_IsImmortal(op))" failure when BRC merge queue races with objects that were recently made immortal. | |||
Contributor
There was a problem hiding this comment.
Suggested change
| Fix "assert(!_Py_IsImmortal(op))" failure when BRC merge queue races with objects that were recently made immortal. | |
| Fix non-immortal assertion failure when BRC merge queue races with objects that were made immortal later. |
| # 1 million strings will take Thread A significant time to process in map() | ||
| # giving Thread B plenty of time to drop references to strings that Thread A | ||
| # hasn't interned yet! | ||
| strings = ["race_string_massive_" + str(j) for j in range(1000000)] |
Contributor
There was a problem hiding this comment.
This test is probably too slow, I would prefer to have test which takes less time.
|
This PR is stale because it has been open for 90 days with no activity. |
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.
Fix
assert.h assertion failed at Objects/object.c:467 in Py_ssize_t _Py_ExplicitMergeRefcount(PyObject *, Py_ssize_t): !_Py_IsImmortal(op)Immortal objects don't use refcounts.
In the free-threaded build, when
_Py_DecRefSharedreduces an object's shared reference count to zero, it places the object into the interpreter's BRC merge queue. If another thread concurrently makes the object immortal (for example, viasys.intern()),_Py_SetImmortalUntracked()sets the object's reference fields to immortal constants. Later, when the original thread checks the eval breaker and attempts to merge the queued objects, it encounters the immortalized object and crashes on the assertion.assert(!_Py_IsImmortal(op))failure when BRC merge queue races withsys.intern#152276