248 Days to Reboot

Medium

· Backend

Incident

SEV-1

BUG-787

Priority: Critical (airworthiness) · reported by systems review

Time to fix: 20 min

Failing checks on the shipped build

  • 300 days does not wrap negative

    beyond int range: expected 2592000000 but got -1702967296

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Boeing 787

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.

Code map

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;
    }
}

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

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

Incident

  • Severity: SEV-1 (priority: Critical (airworthiness))
  • Ticket: BUG-787
  • Reported by: systems review
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • 300 days does not wrap negative — beyond int range: expected 2592000000 but got -1702967296

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

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 -> failsafe

The 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 start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Java bug hunts.