Therac-25: two tasks, one setting, eight seconds
An operator fixed a one-letter typo in a few seconds. One part of the program never saw the fix, and a radiation machine fired at full power with nothing in the way. Try to beat the race yourself.
- Ref
- EP-04
- Date
- Module
- Post-Mortem Lab
- Source
- ep-04
▶ Watch · the episode
On 21 March 1986, at the East Texas Cancer Center in Tyler, Texas, a man lay face down for his ninth radiation treatment. In the next room, the operator started the machine, a Therac-25. It stopped after a moment with a message that said only “Malfunction 54”. The patient felt something like an electric shock. In fact he had received a massive overdose. Three weeks later, it happened again to another patient at the same hospital. Both men died from their overdoses.
Between 1985 and 1987, the Therac-25 gave six known massive overdoses. The Tyler accidents were traced to a race in its software, and they are the ones this episode rebuilds.
Beat the race
The operator typed X by mistake, then fixed it to E. Press Run to watch what each part of the program sees. Then move the sliders: start the fix later, or take longer. Can you find the timings that are safe? Then switch on a fix.
- Screen says
- X-ray
- Beam power set for
- —
- Turntable
- X-ray
What happened
Every step comes from Leveson and Turner’s investigation (IEEE Computer, 1993).
- Software instead of hardware. The older Therac-20 had independent protective circuits and mechanical locks to stop unsafe beams. The Therac-25 was designed around its computer and relied on software for those jobs.
- Tasks sharing memory. The software ran several tasks, started every tenth of a second, that shared variables with no proper way to stop them reading and writing at the same moment.
- Read once. When data entry was complete, the treatment task read the mode, set the beam’s power from it, then spent about 8 seconds setting the bending magnets. While doing that, it was meant to watch for edits, but a flag was cleared on the first pass, so it stopped watching almost immediately.
- A quick fix of a typo. The operator was experienced and fast. She typed “x” for X-ray, noticed she meant “e”, moved the cursor up, changed it and returned, all within 8 seconds.
- Two parts, two answers. The task moving the turntable followed the screen and moved the target out of the way. The beam was still set for X-ray power. Nothing checked that the two agreed.
- A message nobody could read. “Malfunction 54” wasn’t explained in the manuals, and a pause could be resumed with one key. Operators saw malfunctions so often that, as one testified, it “was not out of the ordinary for something to stop the machine”.
- Found by the hospital. The manufacturer couldn’t reproduce the first accident and said an overdose was impossible. After the second, the hospital physicist, Fritz Hager, worked with the operator until they could trigger Malfunction 54 at will: the edit had to be fast.
Fix it
| Fix | What changes |
|---|---|
| Keep watching for edits for all 8 seconds | The fast edit is noticed; the beam is set up again for electrons |
| A hardware lock that checks the target before firing | The beam is blocked, even with the bug still in the software |
The manufacturer’s first response was a letter telling hospitals to remove the cursor-up key cap and tape its contacts open. The full corrective plan that followed included more than 20 changes, among them hardware interlocks, and the FDA rated it a Class I recall. The same bug was later found in the Therac-20’s software. There, it only blew fuses, because the hardware locks stopped the beam.
In the lab, the toolkit’s Scheduler runs the tasks in fixed steps of a tenth of a second, so the race happens the
same way every time. That turns a bug that once took days to reproduce into an ordinary failing test.
What I simplified
The paper says the edit happened “within 8 seconds” but not the exact keystroke times, so those are illustrative. Setup after the magnets is one step, and an edit that starts after setup has finished sends treatment back to data entry (only fast edits caused the overdose). Doses aren’t modelled. The other four overdoses, including a different software flaw at Yakima in 1987, aren’t simulated.
Further reading
Primary sources first. Everything here is free to read or watch.
- PaperAn Investigation of the Therac-25 AccidentsNancy Leveson & Clark Turner · IEEE Computer, July 1993
- VideoHistory's Worst Software ErrorKyle Hill (YouTube)
- VideoWhen Software Kills: Fatal Bugs in the Therac-25Dave's Garage (YouTube)