248 Days to Reboot — Java Bug Hunt
Inspired by the Boeing 787 directive ordering a power cycle at least every 248 days — the generator control units kept an internal counter in hundredths of…
- Language: Java
- Layer: Backend
- Difficulty: Medium
- Concepts: Overflow, Counters
- Modelled on: Boeing 787
- Visible tests: one day converts exactly; 248 days is still positive and precise; 300 days does not wrap negative
- Reward: 50 XP for a complete fix
Briefing
Inspired by the Boeing 787 directive ordering a power cycle at least every 248 days — the generator control units kept an internal counter in hundredths of a second, in a 32-bit signed integer. 2,147,483,647 centiseconds ≈ 248.55 days. Then it wraps negative.
Uptime.java does the same conversion — in int.
Bug report
BUG-787 · Priority: Critical (airworthiness) · Reported by: systems review
centisAfterDays(days) must be exact for mission-length uptimes:
- 300 days = 2,592,000,000 centiseconds — bigger than any int.
Observed: 300 days comes back NEGATIVE, and the watchdog logic downstream treats the system clock as corrupted.
Logs
[gcu] uptime(300d) = -1702967296 centis
[gcu] watchdog: clock corruption suspected -> failsafeThe code as shipped
Uptime.java (editable)
class Uptime {
static final int CENTIS_PER_DAY = 24 * 60 * 60 * 100;
// Total centiseconds of uptime after the given whole days.
static long centisAfterDays(int days) {
int total = days * CENTIS_PER_DAY;
return total;
}
// True once uptime exceeds the mandated safe window.
static boolean rebootRequired(long centis) {
return centis >= 248L * CENTIS_PER_DAY;
}
}Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Java bug hunts.