Skip to content

Commit 7647ab5

Browse files
authored
Use arch-independent magic number as start seed for Preferences hash (#39274)
`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.
1 parent bea5e6e commit 7647ab5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

base/loading.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,9 +1645,10 @@ function get_preferences(uuid::UUID)
16451645
end
16461646

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

16521653
# Load the preferences
16531654
prefs = get_preferences(uuid)
@@ -1659,7 +1660,8 @@ function get_preferences_hash(uuid::Union{UUID, Nothing}, prefs_list::Vector{Str
16591660
h = hash(prefs_name, h)
16601661
end
16611662
end
1662-
return h
1663+
# We always return a `UInt64` so that our serialization format is stable
1664+
return UInt64(h)
16631665
end
16641666

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

0 commit comments

Comments
 (0)