Fix incorrect one-arg Base.hash for ArgumentWrapper#694
Open
adienes wants to merge 1 commit intoJuliaParallel:masterfrom
Open
Fix incorrect one-arg Base.hash for ArgumentWrapper#694adienes wants to merge 1 commit intoJuliaParallel:masterfrom
adienes wants to merge 1 commit intoJuliaParallel:masterfrom
Conversation
Generated as part of an ecosystem-wide audit for one-arg hash methods. The `Base.hash(aw::ArgumentWrapper)` method only defines a one-arg `Base.hash`, causing the two-arg fallback to use `objectid`-based hashing. This can cause correctness issues when ArgumentWrappers are used in hash-based containers. With Julia 1.13+, the default hash seed is changing from `zero(UInt)` to a random value, which will make the one-arg method produce different results each session. This does not affect `==`/`isequal`, which compare the `.hash` field directly rather than calling `Base.hash()`. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Generated as part of an ecosystem-wide audit for one-arg hash methods.
Summary
Base.hash(aw::ArgumentWrapper)insrc/datadeps/aliasing.jlonly defines a one-argBase.hash. This means the two-arg fallbackhash(x, h::UInt)usesobjectid-based hashing instead, which can cause:ArgumentWrappers may hash differently when used as compound keys inDictorSetzero(UInt)to a random valueThis does not affect
==/isequal, which compare the.hashstruct field directly rather than callingBase.hash().Fix
Convert to a proper two-arg
hash(aw::ArgumentWrapper, h::UInt)that chains the pre-computed hash value through the seed.Test plan
==/isequaldon't depend onBase.hash()return valueThis PR was generated with the assistance of generative AI.
Co-Authored-By: Claude noreply@anthropic.com