Skip to content

Hash collision in Utils.hashStr #82

Open

Description

@titoasty

Hi,

I just encountered a hash collision when registering a new class.
The problem is line 52 of Serializer.js with Utils.hashStr.
It returns the same hash (37) for two different strings: "Tile" & "NetworkedEventCollection"

Here is the test code :

import Utils from 'lance/lib/Utils';
console.log(Utils.hashStr('NetworkedEventCollection'));
console.log(Utils.hashStr('Tile'));

For now, hopefully, we can pass a classId to the registerClass method.
Shouldn't be hard to fix :)
Thanks

Activity

  1. titoasty commented on May 12, 2018

    @titoasty
    Author

    After some investigations, I found that the problems resides in the poor precision of the hash.
    So, instead of 8 bits (default in hashStr), it can be changed to 16 and accordingly in serialize/deserialize.
    Precision seems much better with this fix :)

  2. namel commented on May 13, 2018

    @namel
    Member

    Any chance you can provide a PR on Lance on the develop branch ?

  3. titoasty commented on May 14, 2018

    @titoasty
    Author

    I'm leaving on holidays so no promise, but I'll try when I have some time.
    If you want further details on this because it's hight priority, I'll be happy to give you details on this issue.

  4. brianchirls commented on Sep 13, 2019

    @brianchirls

    I'm seeing this problem as well. Collision on 'TwoVector' and 'Agent', both hashing to 33.

  5. namel commented on Sep 20, 2019

    @namel
    Member

    A simple workaround is to change the name of the class. So renaming 'Agent' to 'AgentObj' works around the issue until the hash function is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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