Skip to content

Hash collision for constants #287

@karlwessel

Description

@karlwessel

I am using the latest version from ale/3.0 branch and spend a few hours tracking down a bug caused by a hash collision of two constants.

Here is a minimal working example:

julia> using Metatheory

julia> a = [0x0000000000000080, 0x0000000000100000, 0x0000000000000400, 0x0000000000000100]
4-element Vector{UInt64}:
 0x0000000000000080
 0x0000000000100000
 0x0000000000000400
 0x0000000000000100

julia> b = [0x0000000000000100, 0x0000000000100000, 0x0000000000000080, 0x0000000000000400]
4-element Vector{UInt64}:
 0x0000000000000100
 0x0000000000100000
 0x0000000000000080
 0x0000000000000400

julia> a == b
false

julia> hash(a) == hash(b)
true

julia> EGraph(:($a - $b))
EGraph{Expr, Nothing} with 2 e-classes:
  1 => [UInt64[0x0000000000000080, 0x0000000000100000, 0x0000000000000400, 0x0000000000000100]]
  2 => [%1 - %1]

I don't know how to solve this problem since VecExpr of a constant only stores the hash, I think, and therefore can't be used to point to the correct constant.

PS: Thanks to mxhbl from discourse for documenting a simple hash collision in julia :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions