The Patriot's Drifting Clock

Medium

· Backend

Incident

SEV-1

BUG-DHAHRAN

Priority: Critical · reported by range safety

Time to fix: 20 min

Failing checks on the shipped build

  • the window stays open afterwards

    one second past must still be open: expected a truthy value but got false

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

Patriot missile · 1991

Inspired by the 1991 Patriot missile failure at Dhahran: the system clock counted tenths of a second, and converting ticks to seconds through binary floating point drifted ~0.34s after 100 hours — enough to miss an incoming Scud entirely.

intercept.py decides when the tracking window opens. Keep the math in ticks (integers); the shipped code converts to float seconds and compares with ==.

Code map

# Opens the tracking window once enough time has elapsed.
# Ticks are tenths of a second.

def window_open(start_ticks, now_ticks, window_seconds):
    elapsed_seconds = (now_ticks - start_ticks) * 0.1
    return elapsed_seconds == window_seconds

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.

The Patriot's Drifting Clock — Python Bug Hunt

Inspired by the 1991 Patriot missile failure at Dhahran: the system clock counted tenths of a second, and converting ticks to seconds through binary…

  • Language: Python
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Floating Point, Time
  • Modelled on: Patriot missile · 1991
  • Visible tests: the window opens exactly on time; the window stays open afterwards; too early stays closed
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical)
  • Ticket: BUG-DHAHRAN
  • Reported by: range safety
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • the window stays open afterwards — one second past must still be open: expected a truthy value but got false

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 1991 Patriot missile failure at Dhahran: the system clock counted tenths of a second, and converting ticks to seconds through binary floating point drifted ~0.34s after 100 hours — enough to miss an incoming Scud entirely.

intercept.py decides when the tracking window opens. Keep the math in ticks (integers); the shipped code converts to float seconds and compares with ==.

Bug report

BUG-DHAHRAN · Priority: Critical · Reported by: range safety

window_open(start_ticks, now_ticks, window_seconds) — ticks are tenths:

  • True once at least window_seconds have elapsed, forever after
  • exact integer arithmetic: (now - start) ticks vs window_seconds * 10

Observed: after 100 hours of uptime (3,600,000 ticks) the float conversion yields 360000.00000000006 seconds, the equality check misses, and the window NEVER opens.

Logs

[track] uptime=100h window=360000s open=False (forever)

The code as shipped

src/defense/intercept.py (editable)

# Opens the tracking window once enough time has elapsed.
# Ticks are tenths of a second.

def window_open(start_ticks, now_ticks, window_seconds):
    elapsed_seconds = (now_ticks - start_ticks) * 0.1
    return elapsed_seconds == window_seconds

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 Python bug hunts.