-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-122320: Add _testinternalcapi.is_dict_version_overflowed
#122324
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
Conversation
_PyDictKeys_SetVersionForCurrentState
and _testinternalcapi.reset_version
_testinternalcapi.reset_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sort of confused what the purpose of this function is... and I'm not sure I like what it's doing.
We definitely shouldn't be resetting interp->dict_state
for any reason, even an internal tests. This breaks uniqueness guarantees for all dictionary key versions, globally. So anything that does that is a non-starter.
I'm also not sure why we don't do anything if the version is nonzero... that seems to go against the function's stated purpose. I'm also not sure why dickeys->dk_version
is being set to 1
... again, that breaks serious global invariants.
We should probably just start skipping these tests when important versions start overflowing.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
_testinternalcapi.reset_version
_testinternalcapi.is_version_overflowed
I have made the requested changes; please review again |
Thanks for making the requested changes! @brandtbucher: please review the changes made to this pull request. |
_testinternalcapi.is_version_overflowed
_testinternalcapi.is_dict_version_overflowed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Maybe the overflow check logic should be moved to a static inline function in pycore_dict.h?
I suggest a few changes on how this is implemented:
|
I'd say it can be closed. Thanks for working on it though! |
The problem is that the
cache->index
field has a type ofuint16_t
:Therefore, due to overflow, the specialization (
_Py_Specialize_LoadGlobal
) will fail:I think changing the type of the
cache->index
field touint32_t
isn't worth it. The best thing we can do is reset the version.test_opcache
fails with a--forever
argument #122320