Live data from Hacker News

Chess.com stopped working on 32bit iPads because 2^31 games have been played

chess.com

51–60 of 338 posts

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#51
post #37

Long long time ago, I created a poll on a small website I was maintaining. I didn't expect much traffic and, so, not thinking too much about it, I put the ID column to be a TINYINT (i.e. max value = 255)... That was a valuable lesson. (I actually generated most entries myself while testing stuff - live in prod of course - and while there were probably fewer than 255 votes, the AUTO_INCREMENT did its job and produced…

> "Long long time ago"

Seems you have learned your lesson :-)

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#52

Earlier quoted context omitted.

It's very reasonable. This way they overflow into invalid values instead of zero.

Assuming you're working in a language that defines signed integer overflow. Depending on the language, you can result in undefined behavior, instead. For that reason, I'd go with an unsigned counter, with the first million IDs being invalid or reserved for future use. That way, you get well-defined overflow into an invalid region.

When's the last time you worked with an architecture that didn't use twos complement and roll into negatives on overflow?

Your reserved bottom range is a perfectly good solution. But rolling into negatives seems fine, too.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#53
post #8

Self-confidence as a programmer is when starting a new project, storing the transaction ID as a long rather than an int...

> Self-confidence as a programmer is when starting a new project, storing the transaction ID as a long rather than an int...

uint64_t even

Or a UUID as others have suggested.

Technically C spec doesn't really say exactly how many bits int, long and long long should be. If you want specific sizes and your code to be somewhat portable use the specific bit sizes to make that clear. There are also types for size-like things (size_t) and pointer and offset like things.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#54
Hey all. Thanks for noticing :P Obviously this is embarrassing and I'm sorry about it. As a non-developer I can't really explain how or why this happened, but I can say that we do our best and are sorry when that falls short.

- Erik, CEO, Chess.com

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#55
I recently experienced a nasty bug with BLOB in MySQL. The software vendor was storing a giant json which contained the entire config in a single cell. It ran fine for months, and then when it was restarted it totally broke. Reason was: the json had been truncated the entire time in the database, so it was gone forever. It was only working because it used the config stored in memory on the local system. Nasty!

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#56

It's fascinating... the Y2K problem never came to fruition because - arguably - of the immense effort put in behind the scenes by people who understood what might have happened if they hadn't. The end result has been that the entire class of problems is overlooked, because people see it as having been a fuss over nothing. I sometimes think it would've been better if a few things had visibly failed in January 2000.

> I sometimes think it would've been better if a few things had visibly failed in January 2000. Having to spend billions of dollars on programmers' goofy means of saving a few bytes of memory is a pretty visible failure.

Nope. Definitely not goofy.

My dad was a programmer in the early days. The machines he started on in the 1960s had 8 KB of RAM. Saving a byte then is the equivalent today of saving 1 MB on an 8 GB machine.

Multiply that times, say, the thousands of customer orders you're trying to process and the goofy thing would be burning a lot of additional RAM because it might help somebody 35 years later. Who among us is writing code today worried about how it will be used in 2052?

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#58
post #46

Earlier quoted context omitted.

Similar to how much effort goes into dealing with things like dangerous strains of bird flu, only to have people complain about how much money was spent on "nothing" when an outbreak doesn't occur.

This is a whole class of problem - I wonder if there's a name for it. More examples include: talking about welfare being unnecessary because no one is starving. Or people on medications stopping because they feel better (while still on them).

The "It's Working" problem.

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#59
post #52

Earlier quoted context omitted.

Assuming you're working in a language that defines signed integer overflow. Depending on the language, you can result in undefined behavior, instead. For that reason, I'd go with an unsigned counter, with the first million IDs being invalid or reserved for future use. That way, you get well-defined overflow into an invalid region.

When's the last time you worked with an architecture that didn't use twos complement and roll into negatives on overflow? Your reserved bottom range is a perfectly good solution. But rolling into negatives seems fine, too.

Signed overflow is ub in C

Re: Chess.com stopped working on 32bit iPads because 2^31 games have been played

#60

Hey all. Thanks for noticing :P Obviously this is embarrassing and I'm sorry about it. As a non-developer I can't really explain how or why this happened, but I can say that we do our best and are sorry when that falls short. - Erik, CEO, Chess.com

2 billion is a very large number that was probably not envisioned as reachable in the near future - as a programmer I'd argue this is a pretty easy mistake to make, and that while (slightly) embarrassing, its a good learning moment.

It's also really awesome that you're here, and that you guys were so honest about the nature of the bug - this is really something that should be encouraged.

Post reply on HN