Skip to content

Fix incorrect one-arg Base.hash for ArgumentWrapper#694

Open
adienes wants to merge 1 commit intoJuliaParallel:masterfrom
adienes:fix-hash-one-arg
Open

Fix incorrect one-arg Base.hash for ArgumentWrapper#694
adienes wants to merge 1 commit intoJuliaParallel:masterfrom
adienes:fix-hash-one-arg

Conversation

@adienes
Copy link

@adienes adienes commented Mar 19, 2026

Generated as part of an ecosystem-wide audit for one-arg hash methods.

Summary

Base.hash(aw::ArgumentWrapper) in src/datadeps/aliasing.jl only defines a one-arg Base.hash. This means the two-arg fallback hash(x, h::UInt) uses objectid-based hashing instead, which can cause:

  • Correctness bugs: equal ArgumentWrappers may hash differently when used as compound keys in Dict or Set
  • Performance issues: excessive method invalidation across the ecosystem
  • Julia 1.13+ breakage: the default hash seed is changing from zero(UInt) to a random value

This does not affect ==/isequal, which compare the .hash struct field directly rather than calling Base.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

  • Verified ==/isequal don't depend on Base.hash() return value

This PR was generated with the assistance of generative AI.

Co-Authored-By: Claude noreply@anthropic.com

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant