Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was also confused by this as a commit id is deterministic. I suspect that the OP may be confused about how git hashes are computed.

But thinking deeper, given that the hash is computed from a small amount of entropy (the commit time), plus a seed (the committed code changes), and the previous value (previous commit hash), this is actually fairly similar to the definition of a PRNG.

That is to say, it's not an RNG, but for some approximations it's indistinguishable from one.



> I suspect that the OP may be confused about how git hashes are computed.

I don't think they are. The use of "RNG" is referring to how a "random" commit sha lead to this bug. Commit SHAs are, for all intents and purposes, random.

You could test this against thousands of SHAs and never encounter one that meets the criteria to trigger the bug.


It's way less than thousands.

To get this specific bug - one 'e' in the 7th digit and 9 digits less than 'a' - is 1/16*(10/16)^9 = 0.009095. Just under 1 in 1000. But if the 'e' is in the 2nd,3rd,4th,5th,6th you'd get the same bug, so actually about 6 in 1000.

But around 1% of the hashes will be all decimal digits and will parse as numbers ((10/16)^10 = 0.009). That's common enough that I've seen that one cause errors in our code too (somebody had code reading the hash then trying to append it to a string).


This was my thinking, yeah; been playing too much Hearthstone lately so I had RNG on my mind o_o




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: