The Year 2038 Problem — Java Bug Hunt
Inspired by the countdown every 32-bit Unix system is on: at 03:14:07 UTC on January 19, 2038, signed 32-bit epoch seconds wrap negative and the clock jumps…
- Language: Java
- Layer: Backend
- Difficulty: Easy
- Concepts: Time, Overflow
- Modelled on: Unix time
- Visible tests: near-term scheduling is exact; crossing 2^31 stays positive
- Reward: 50 XP for a complete fix
Briefing
Inspired by the countdown every 32-bit Unix system is on: at 03:14:07 UTC on January 19, 2038, signed 32-bit epoch seconds wrap negative and the clock jumps to 1901.
Epoch.java schedules future timestamps. It still lives in 32 bits.
Bug report
BUG-2038 · Reported by: infra futures team
futureTimestamp(nowSeconds, deltaSeconds) must stay exact past 2^31. Scheduling 5 years from 2035 currently produces a NEGATIVE timestamp, and every TTL comparison after it inverts.
Logs
[sched] now=2051222400 (+5y) -> -2085744896The code as shipped
Epoch.java (editable)
class Epoch {
// Seconds since 1970 for a moment delta seconds in the future.
static long futureTimestamp(long nowSeconds, long deltaSeconds) {
int result = (int) (nowSeconds + deltaSeconds);
return result;
}
}Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Java bug hunts.