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

> [...] almost every large C or C++ project has a WHATEVER_VERSION token (c.f. LINUX_VERSION_CODE for the kernel) that packs the version into a comparable integer literal. The bug here is that they picked an encoding that was obviously going to overflow [...]

Speaking of LINUX_VERSION_CODE, it had a similar problem recently. See the article at https://lwn.net/Articles/845120/ which was summarized in this year's LWN.net retrospective at https://lwn.net/SubscriberLink/879053/aaea44782e8c760d/ as follows:

"Sometimes the most obvious things can be the hardest to anticipate; consider, for example, the case of minor revision numbers for stable kernel releases. A single byte was set aside for those numbers, since nobody ever thought there would be more than 255 releases of a single stable series. But we live in a different world, with fast-arriving stable updates and kernels that are supported for several years. It should have been possible for us, and for the developers involved, to not only predict that those numbers would overflow, but to make a good guess as to exactly when that would happen. We were all caught by surprise anyway."



Similar, but with the important distinction that this problem was recognized months in advance and remedied with some care (or kludge, depending on your preferences), and didn't become a bug in production software.

All computers work in finite representations. All values can overflow. Good engineering is about working within that world and not trying to Quixotically design its absence.




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

Search: