Worth knowing: Year 2038 problem
March 2022
In Unix-based systems, such as Linux or BSD, the so-called Unix time is used as standard for the time. Unix time is defined by the number of seconds elapsed since January 1, 1970, 00:00:00 UTC, resulting in a Unix time of 1640991600 seconds for January 1, 2022, 00:00:00 UTC, for example. [1]
In Unix-like systems, this Unix time was, and in some cases still is, stored as a signed 32-bit integer, resulting in a maximum capacity of 2,147,483,647 seconds, or just under 68 years.
Starting from the starting time, January 1, 1970, 00:00:00 UTC, this maximum capacity is reached on January 19, 2038, 03:14:07 UTC, and exceeded in the following second. The immediate consequence from such a counter overflow would be the change of the sign and the accompanying jump back to December 13, 1901, 20:45:52 UTC within the affected systems.
While for systems based on 64-bit architectures this problem is only relevant to a limited extent due to the increase in capacity to that of a 64-bit integer, systems based on 32-bit architectures in particular are at risk of exhibiting unpredictable, possibly erroneous behavior on January 19, 2038 [2].
This problem is particularly relevant in the area of embedded systems, since embedded systems have very long planned lifetimes of often several decades on the one hand, and on the other hand a large part of the installed hardware is still based on 32-bit architectures.
As an approach to circumvent this problem, the changeover of the Unix time data type from a 32-bit to a 64-bit integer has also proved successful for operating systems for 32-bit architectures. While this switch occurred very early in some operating systems, such as NetBSD with version 6.0 in 2012 or OpenBSD with version 5.5 in 2014, the Linux kernel has only supported 64-bit datatypes for time on 32-bit architectures since 2020 with version 5.6 [3] [4] [5].
Despite the move to 64-bit data types within kernels, some hurdles still exist for entire operating systems, including:
- Affected software libraries, most notably implementations of the C standard library, must be adapted to the new 64-bit data types and system calls.
- musl libc: full support for the new data types and system calls since version 1.2 [6]
- glibc: new data types and system calls are implemented since version 2.32, but also currently with version 2.34 not yet fully supported [7] [8]. - All programs and/or applications, which are based on these affected libraries, must be recompiled with the adapted versions of the libraries.
- With applications in which direct system calls affected by the changes are used an appropriate adjustment is necessary.
- Affected file systems, for example ext2, ext3 and partly also ext4, must be adapted if necessary or replaced by others.
Although there is also already some progress in the user space with regard to the 2038 problem, such as the partially existing implementation and support of the new 64-bit data types and system calls by the C standard libraries, the prerequisites are still missing in some places to protect both existing and new systems based on 32-bit architectures from erroneous behavior in 2038.
We will continue to closely monitor upcoming developments in this area and will inform you in a timely manner as soon as the necessary prerequisites for appropriate action have been established.
References
[1] Ed: The Open Group, "General Concepts," [Online]. Available: pubs.opengroup.org/onlinepubs/009695399/xrat/xbd_chap04.html. [Accessed 17 February 2022].
[2] Ed: The Open Group, "64-bit and Data Size Neutrality," [Online]. Available: unix.org/whitepapers/64bit.html. [Accessed 17 February 2022].
[3] Ed: OpenBSD, "OpenBSD 5.5 Changelog," [Online]. Available: www.openbsd.org/plus55.html. [Accessed 17 February 2022].
[4] Ed: NetBSD, "Announcing NetBSD 6.0," [Online]. Available: www.netbsd.org/releases/formal-6/NetBSD-6.0.html. [Accessed 17 February 2022].
[5] A. Bergmann, "[GIT PULL] y2038: core, driver and file system changes," [Online]. Available: lkml.org/lkml/2020/1/29/355. [Accessed 17 February 2022].
[6] Ed: musl libc, "musl time64 release notes," [Online]. Available: musl.libc.org/time64.html. [Accessed 17 February 2022].
[7] Ed: GNU - Free Software Foundation, "The GNU C Library version 2.32 is now available," 6 August 2020. [Online]. Available: sourceware.org/pipermail/libcannounce/2020/000029.html. [Accessed 17 February 2022].
[8] Ed: GNU - Free Software Foundation, "The GNU C Library: 64-bit time symbol handling in the GNU C Library," [Online]. Available: www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html. [Accessed 17 February 2022].