Files
tqma6-yocto-mirror/docs/01-analysis/2038-problem-analysis.md

106 lines
3.5 KiB
Markdown
Raw Permalink Normal View History

# 2038 Compliance Analysis TQMa6UL
## Overview
The Year 2038 problem (Y2K38) occurs when a signed 32-bit integer used for
Unix timestamps overflows on **2038-01-19 03:14:07 UTC**. This affects all
32-bit ARM systems using traditional 32-bit `time_t`.
## Architecture
```
┌─────────────────────────────────────┐
│ Application Layer │
│ (all userspace uses 64-bit t) │
├─────────────────────────────────────┤
│ C Library │
│ glibc 2.39: 64-bit time_t (Y2038) │
│ musl 1.2+: 64-bit time_t (Y2038) │
├─────────────────────────────────────┤
│ Linux Kernel (Mainline 6.x) │
│ 64-bit time syscalls on ARM32 │
├─────────────────────────────────────┤
│ i.MX6 UltraLite (Cortex-A7) │
└─────────────────────────────────────┘
```
## C Library Options
### Option 1: glibc (recommended for Qt/GUI)
**Distro:** `dumpling-wayland`
**Target triplet:** `arm-tq-linux-gnueabi`
glibc provides 64-bit `time_t` on 32-bit ARM since version 2.34, when built
with `_TIME_BITS=64` (which Yocto Scarthgap enables by default). The BSP
includes glibc 2.39.
Advantages:
- Full compatibility with third-party software
- Qt5/Qt6 support
- Broader library ecosystem
### Option 2: musl (for minimal/headless)
**Distro:** `spaetzle`
**Target triplet:** `arm-tq-linux-musleabi`
musl has provided 64-bit `time_t` unconditionally on all 32-bit architectures
since version 1.2.0 (February 2020).
Advantages:
- Smaller footprint
- Simpler, no locale overhead
Limitations:
- Qt is blocked (`SKIP_RECIPE`)
- Some third-party software may not build
## Kernel Support
The mainline kernel (6.x) provides:
- 64-bit time variants of all relevant syscalls (`clock_gettime64`,
`futex_time64`, etc.)
- `CONFIG_COMPAT_32BIT_TIME=y` for backwards compatibility
- ext4 timestamps beyond 2038
## Compliance Matrix
| Component | glibc (dumpling) | musl (spaetzle) | 2038-safe? |
|-----------|-----------------|-----------------|-----------|
| Kernel | Mainline 6.x | Mainline 6.x | ✅ |
| C Library | glibc 2.39 | musl 1.2+ | ✅ |
| Userspace | 64-bit time_t | 64-bit time_t | ✅ |
| U-Boot | Mainline | Mainline | ✅ |
| Qt6 | ✅ supported | ❌ blocked | ✅ (glibc) |
## Verification
After building, verify on the target:
```bash
# Check time_t size (should print 8)
cat << 'C' > /tmp/check_time.c
#include <stdio.h>
#include <time.h>
int main() { printf("sizeof(time_t) = %zu\n", sizeof(time_t)); return 0; }
C
$CC /tmp/check_time.c -o /tmp/check_time && /tmp/check_time
```
## Risk Assessment
| Risk | Severity | Status |
|------|----------|--------|
| time_t overflow | Critical | ✅ Mitigated (both libc options) |
| Filesystem timestamps | Medium | ✅ ext4 supports >2038 |
| Network protocols (NTP) | Low | ✅ 64-bit aware |
| Third-party binaries | Medium | ⚠️ Must verify pre-built binaries |
| Qt5 compatibility | Medium | ⚠️ meta-qt5 not included, add manually |
## References
- [glibc Y2038 Design](https://sourceware.org/glibc/wiki/Y2038ProofnessDesign)
- [musl time64](https://musl.libc.org/time64.html)
- [Kernel Y2038 work](https://kernelnewbies.org/y2038)