In July 1997, Mars Pathfinder landed perfectly. A few days later, its computer started rebooting itself. On Mars.
The cause was a bug every RTOS course now teaches: priority inversion.
The lander ran VxWorks. Three tasks matter here:
- High priority: bc_dist, moving data on the information bus
- Medium priority: longer-running tasks
- Low priority: ASI/MET, the weather instrument
ASI/MET took a mutex to publish its data. bc_dist needed the same mutex, so it waited. No problem: ASI/MET only holds it for a moment.
Except, very rarely, a medium-priority task woke up inside that moment. It needed no mutex and outranked ASI/MET, so it took the CPU. ASI/MET couldn't run, so it couldn't release the mutex. bc_dist was stuck behind a task with a lower priority than its own.
The scheduler saw that bc_dist had missed its cycle, treated it as a fatal error and reset the whole computer. Each reset lost data.
JPL repeated the same activities in the lab, with the trace logging already built into the software. They reproduced it in less than 18 hours.
The fix was one option: priority inheritance. The task holding the mutex borrows the priority of the task waiting for it, finishes, and releases it.
VxWorks had it all along. It was off. JPL changed the setting and uploaded the patch to the spacecraft.
What strikes me most is the trace logging. It was there before launch, and it's what made an 18-hour diagnosis possible from millions of kilometers away.
The resets had even shown up before launch, but no one could reproduce them, and they lost out to the landing software.
The software lead's lesson: "test what you fly and fly what you
Is priority inheritance on in your RTOS config?
