Skip to main content
  1. Today I Learned/

Year 2038 problem

·139 words·1 min
Classic buffer overflow bug

Most computer systems measure unix time- the number of seconds elapsed since the Unix epoch (00:00:00 UTC on 1 January 1970) – and store it in a signed 32-bit integer However the data type can only store numbers from -(231) and (232 - 1) (random trivia: this number is the eighth Mersenne prime).

This means the latest time that can be properly encoded is (232 - 1) seconds after epoch, ehich translates to 03:14:07 UTC on 19 January 2038. Attempting to increment to the following second (03:14:08) will cause the integer to overflow, setting its value to −(231) which systems will interpret as 231 seconds before epoch (20:45:52 UTC on 13 December 1901)

This is the year 2038 problem, many systems (old ones surely) if not patched will break in unexpected ways on that date.