The Missing Table Rows — Python Bug Hunt

Inspired by the 1994 Pentium FDIV bug: five entries missing from a division lookup table inside the chip, wrong answers on rare inputs, a $475M recall.

  • Language: Python
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Lookup Tables, Null Safety
  • Modelled on: Intel Pentium · 1994
  • Visible tests: table hits divide fast and exact; a table hole falls back to real division
  • Reward: 50 XP for a complete fix

Briefing

Inspired by the 1994 Pentium FDIV bug: five entries missing from a division lookup table inside the chip, wrong answers on rare inputs, a $475M recall. The table here is locked — some entries really are missing. The lookup path must fall back to real division when it hits a hole.

Fix fastdiv.py.

Bug report

BUG-FDIV · Priority: Recall-grade · Reported by: verification

estimate(a, d) — divide a by digit d (1..9) using the reciprocal table:

  • table hit -> round(a * reciprocal, 6)
  • table hole (None) -> round(a / d, 6) fallback

Observed: dividing by 7 crashes with a TypeError — exactly the class of rare input the table forgot.

Logs

[calc] 4195835 / 3145727 path -> TypeError: unsupported operand

The code as shipped

src/chip/fastdiv.py (editable)

table = bug_require("./table")

def estimate(a, d):
    return round(a * table.RECIPROCALS[d], 6)

Read-only context: src/chip/table.py.

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Python bug hunts.