y2k38

2,147,483,647 seconds

The largest value a signed 32-bit integer can hold, and the instant it runs out: 2038-01-19 03:14:07 UTC. One second later, systems that still count seconds in an int wrap to 1901.

overflow.c

$ gcc overflow.c && ./a.out

time_t now = 2147483647

2038-01-19T03:14:07Z

now + 1 = -2147483648

1901-12-13T20:45:52Z

segmentation fault (core dumped)

is my timestamp safe?

seconds since epoch
2 147 483 647

explainer

Why 2038 happens

Unix time has traditionally been stored in a C time_t, and on most 32-bit systems that is a signed 32-bit integer. The maximum is 2,147,483,647, and counting one second at a time from 1970 reaches it on 19 January 2038 at 03:14:07 UTC. The next increment wraps to −2,147,483,648, which is 13 December 1901.

The fix is not exotic: use a 64-bit integer. Every modern 64-bit operating system already does, which is why your laptop is fine. The problem lives in the long tail — embedded devices, older 32-bit Linux installs, binary file formats with a 32-bit field, databases with an INT column, and protocols that still specify a 32-bit seconds value.

Where to look in your own stack

  • Columns: MySQL INT for a timestamp, or SQLite integers built by a 32-bit tool.
  • Binary formats: anything writing a 32-bit seconds field — some archive and telemetry formats do.
  • Embedded: 32-bit ARM or MIPS devices with long service lives: meters, controllers, vehicles.
  • APIs: a field declared as int32 in a schema will overflow even if the server stores 64 bits.

Testing it now

Set a device or container clock past 2038-01-19 and see what breaks. You do not have to wait: changing the system clock is enough, because the bug is arithmetic, not elapsed time. Values between 2,147,483,648 and 4,294,967,295 survive only in unsigned 32-bit storage, which pushes the limit to 2106-02-07 06:28:15 UTC — a reprieve, not a fix.

// not the same as y2k

Y2K was about two-digit years in display and storage formats. Y2K38 is a hard arithmetic limit on a counter. There is no ambiguity to patch around — the field either has room for the number or it does not.

overflow.c — the whole problem in nine lines
#include <stdio.h>
#include <time.h>

int main(void) {
    time_t now = 2147483647;      /* 2038-01-19T03:14:07Z */
    printf("%s", ctime(&now));

    now = now + 1;                /* signed overflow */
    printf("%s", ctime(&now));    /* 1901-12-13T20:45:52Z */
    return 0;
}

advertisement