Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash collision in Utils.hashStr #82

Open
titoasty opened this issue May 12, 2018 · 5 comments
Open

Hash collision in Utils.hashStr #82

titoasty opened this issue May 12, 2018 · 5 comments

Comments

@titoasty
Copy link

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

@titoasty
Copy link
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 :)

@namel
Copy link
Member

namel commented May 13, 2018

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

@titoasty
Copy link
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.

@brianchirls
Copy link

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

@namel
Copy link
Member

namel commented Sep 20, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants