Skip to content

Commit

Permalink
Use arch-independent magic number as start seed for Preferences hash
Browse files Browse the repository at this point in the history
`Preferences.jl` is currently broken on 32-bit because hashing natively
uses `UInt32`'s instead of `UInt64`'s.  We allow `Preferences.jl` to
polymorph to whichever it requires here, while eliminating a confusing
large constant and simply starting from zero.
  • Loading branch information
staticfloat committed Jan 15, 2021
1 parent 35fcfda commit e679732
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1645,8 +1645,9 @@ function get_preferences(uuid::UUID)
end

function get_preferences_hash(uuid::Union{UUID, Nothing}, prefs_list::Vector{String})
# Start from the "null" hash
h = UInt64(0x6e65726566657250)
# Start from a predictable hash point to ensure that the same preferences always
# hash to the same value, modulo changes in how Dictionaries are hashed.
h = UInt(0)
uuid === nothing && return h

# Load the preferences
Expand All @@ -1659,7 +1660,8 @@ function get_preferences_hash(uuid::Union{UUID, Nothing}, prefs_list::Vector{Str
h = hash(prefs_name, h)
end
end
return h
# We always return a `UInt64` so that our serialization format is stable
return UInt64(h)
end

get_preferences_hash(m::Module, prefs_list::Vector{String}) = get_preferences_hash(PkgId(m).uuid, prefs_list)
Expand Down

0 comments on commit e679732

Please sign in to comment.