Module 11 · Lesson 1
Failure Modes and Fault Protection
Space software fails through logic, timing, resources, bad data, radiation and reused assumptions. This lesson covers how those failures are analyzed and how fault protection detects and contains them.
Learning objectives
After this lesson you will be able to:
- Identify the main ways software fails in space systems, including causes that are rare in ground-based software
- Describe how failure modes and effects analysis and fault detection, isolation and recovery are applied to software
- Write time-dependent protective logic, such as a watchdog monitor, so that it can be tested deterministically
How software fails in space
The foundation course covered hardware reliability, redundancy and safe mode. This lesson looks at the same ground from inside the software.
Software does not wear out. It fails because it is wrong for the situation it meets. In space systems those situations fall into six groups.
- Logic errors. A wrong condition, a missed case, a sign error. These are ordinary bugs with unusual consequences.
- Timing. A control loop misses its deadline, or tasks interact in an order nobody anticipated. The repeated computer resets on Mars Pathfinder in 1997 were traced to priority inversion, a scheduling problem in which a low-priority task holding a shared resource blocks a high-priority one.
- Resource exhaustion. Memory, stack, storage or message queues run out, or a counter overflows after months. A leak that takes six weeks to matter never shows in a ten-minute test.
- Bad data. A sensor returns an out-of-range value, a stale sample or a not-a-number result, and the software uses it.
- Radiation-induced upsets. A charged particle flips a bit in memory, an event called a single-event upset. A variable changes value with no defect in the code. Protection comes from error-correcting memory, from memory scrubbing that repairs single-bit errors before a second one accumulates, from checksums over code and tables, and from keeping critical values in three copies and voting.
- Assumptions inherited through reuse. Code that was correct on the last mission is wrong on this one because a range, rate, unit or sequence changed. Lesson 3 returns to this.
Only the first group consists of bugs in the usual sense. The rest are conditions the software must be designed to survive.
Analyzing failure before it happens
Failure modes and effects analysis, or FMEA, is a systematic, bottom-up review. For each element, engineers list the ways it could fail, the local and mission-level effect of each, how severe that is, how it would be detected and what would be done.
The method began with hardware. Applied to software, the elements are functions and interfaces, and the failure modes are generic: the function does not run, runs late, runs when it should not, produces a wrong value, or hangs. A fragment for a function that processes attitude sensor data might read:
| Failure mode | Effect | Detection | Response |
|---|---|---|---|
| Outputs stale data | Controller acts on an old attitude | Sample counter stops advancing | Mark sensor invalid, use another |
| Outputs out-of-range value | Controller commands a large, wrong correction | Range check | Reject the sample |
| Task hangs | No attitude updates | Watchdog expires | Restart the task, then escalate |
The value of the exercise lies in the detection column. Asking how anyone would know exposes failures that would otherwise be silent.
Threat modeling and chaos engineering are the nearest mainstream equivalents. The difference is that experiments on the production system are not available. The analysis is done on paper and confirmed by injecting faults in the simulators of the previous module. No analysis lists everything, which is why spacecraft also have a catch-all response.
Detection, isolation and recovery
Fault detection, isolation and recovery, or FDIR, is the on-board implementation of that analysis.
Detection uses limit checks, consistency checks between sensors, freshness checks and checksums. Most monitors require a condition to persist before acting, as in the previous lesson.
Isolation decides which element is at fault. A sensor reading that disagrees with expectation could mean a bad sensor or a real problem with the thing it measures. Comparing three sources, or switching one and observing, resolves it.
Recovery is layered. The software tries the least disruptive response first:
- retry the operation or reset the unit
- switch to a redundant unit
- reset or switch the flight computer
- enter safe mode
Each level hands over to the next if it fails.
Two aspects fall on the software in particular. Redundancy management means tracking which units are healthy, which are in use and which have already been tried, and keeping that record through a reboot. Without it the software can cycle endlessly between two units it has declared failed. Safe mode has to be a small, simple code path that depends on as little as possible. It should not rely on the function whose failure caused the entry.
Fault protection is itself software and can be wrong. A false trip into safe mode can cost days of mission time. Thresholds and persistence counts are therefore held in tables that operators can change, and individual monitors can be disabled by command.
Handling inputs defensively
Every value that crosses a boundary is checked for range, validity and freshness before it is used. The response to a bad value is a design decision made in advance: reject it and hold the last good value for a limited time, substitute a default, or declare the source failed.
Many server-side systems are designed to crash on an unexpected state and let an orchestrator restart them. That parallel only partly holds. A flight computer restart interrupts attitude control and is an event with consequences of its own, so flight components are generally expected to degrade and report. A clean restart remains the right answer when internal state can no longer be trusted, and arranging it is the job of the watchdog.
A practical example: a testable watchdog
The foundation course described the hardware watchdog timer. The same pattern is used in software to monitor individual tasks. Each critical task must report in, or kick the watchdog, within a deadline.
Logic that depends on time is hard to test if it reads the system clock. Passing the clock in makes the test deterministic.
type Clock = () => number; // returns milliseconds
class Watchdog {
private lastKick: number;
private expired = false;
private readonly clock: Clock;
private readonly timeoutMs: number;
private readonly onExpire: (silentMs: number) => void;
constructor(clock: Clock, timeoutMs: number, onExpire: (silentMs: number) => void) {
this.clock = clock;
this.timeoutMs = timeoutMs;
this.onExpire = onExpire;
this.lastKick = clock();
}
kick(): void { this.lastKick = this.clock(); } // called by the monitored task
check(): void { // called by an independent monitor
const silentMs = this.clock() - this.lastKick;
if (!this.expired && silentMs > this.timeoutMs) {
this.expired = true; // respond once, not on every check
this.onExpire(silentMs);
}
}
}
The test drives a simulated clock in 50 ms steps. The task kicks every 100 ms and then hangs.
let now = 0; // ms, the injected test clock
const events: string[] = [];
const watchdog = new Watchdog(() => now, 250, (silentMs) => {
events.push(`t=${now} ms: expired after ${silentMs} ms of silence`);
});
for (now = 0; now <= 1000; now += 50) {
const taskIsRunning = now <= 400; // the task hangs after 400 ms
if (taskIsRunning && now % 100 === 0) watchdog.kick();
watchdog.check();
}
console.log(events);
The output is:
[ 't=700 ms: expired after 300 ms of silence' ]
The last kick is at 400 ms. At 650 ms the silence equals the 250 ms timeout but does not exceed it, so the watchdog expires at 700 ms, and only once. The test covers a second of simulated time almost instantly and gives the same result on every run.
Three design points carry over to flight code. The response is latched, so one hang produces one recovery action. The kick belongs at the end of a completed work cycle, because a kick issued from a timer interrupt keeps arriving while the main loop is stuck. The monitor itself must be watched, usually by having it reset the hardware watchdog.
Fault protection limits the damage when software fails. The next lesson looks at the evidence used to show, before launch, that it is unlikely to fail.
Key takeaways
- Software fails through logic errors, timing, resource exhaustion, bad data, radiation-induced upsets and assumptions inherited through reuse. Only some of these are bugs in the usual sense.
- Failure modes and effects analysis asks of each function how it could fail, what would follow and how anyone would know. The last question drives the design of detection.
- Fault protection is layered. It tries the least disruptive response first and escalates through unit resets and redundant units to safe mode.
- Fault protection is software and can be wrong. Its thresholds and timing must be testable, which means injecting time and inputs instead of reading them directly.
Knowledge check
Check your understanding. These questions are not graded and you can retry as often as you like.
0 of 3 questions answered.
Glossary
Failure mode
A specific way in which a component or function can fail, such as producing no output, late output or an out-of-range value.
Failure modes and effects analysis
A systematic, bottom-up review that lists each component's failure modes, their effects, their severity and how they would be detected and mitigated. Abbreviated FMEA.
Fault detection, isolation and recovery
The on-board functions that notice a fault, identify the failed element and restore a safe or working configuration. Abbreviated FDIR.
Single-event upset
A change in a stored bit caused by a charged particle striking a memory cell or register. The hardware is not damaged, but the stored value is wrong.
Memory scrubbing
Periodically reading and rewriting memory through its error-correcting logic so that single-bit errors are repaired before a second error accumulates in the same word.
Watchdog timer
A timer that triggers a recovery action unless the monitored software resets it at regular intervals, used to detect software that has hung.
References and further reading
Finished this lesson?
Loading your progress…
Lesson version 1.0.0.