Program state degradation is a worsening execution state produced by the interaction of several actions rather than one isolated mistake. As degradation accumulates, the program becomes less able to continue correctly. section 15.2
Resource exhaustion
After stack or heap exhaustion, continuing execution can degrade state further and make the system react erratically, potentially causing harm beyond the current execution. section 15.3.1
Manage degradation by applying these rules:
- Check preconditions before operations that could fail, and execute an alternative when they are not satisfied. section 15.5
- Check error returns from resource-exhausting operations, including C library calls; a nonzero errno can also indicate failure. section 15.5
- Detect state degeneration after it occurs, then use available recovery or termination mechanisms to limit damage. section 15.5
- Define recursion progress and a reliable base condition so function-call resources do not become exhausted. section 15.2.1
