question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hash collision in Utils.hashStr

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
titoastycommented, May 12, 2018

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 😃

0reactions
namelcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is there no collision in a HashMap when different keys ...
You are confusing a collision - case when hashes of keys are the same (or to be precise, when hashes are withing the...
Read more >
Issue 13703: Hash collision security issue - Python tracker
msg150522 ‑ (view) Author: Barry A. Warsaw (barry) * Date: 2012‑01‑03 19:36 msg150525 ‑ (view) Author: Christian Heimes (christian.heimes) * Date: 2012‑01‑03 20:19 msg150526 ‑...
Read more >
How does Python's built-in hash() function compare to other ...
For integers and floats hash collisions wont happen - if two values have the same hash, they will have the same value. For...
Read more >
Hashtable (Java Platform SE 8 ) - Oracle Help Center
java.util. ... This class implements a hash table, which maps keys to values. ... Note that the hash table is open: in the...
Read more >
How to Implement a Hash Map in JavaScript | by Jake Zhang
Additionally, we've supplied the below hashing function hashStr . It tries to avoid collision, but is not perfect. It takes in a string...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found