liveBook · Manning

Program state degradation

As explained in Modern C, Third Edition

Program state degradation is a worsening of the execution state that progressively reduces the program's ability to continue correctly.

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

How Modern C, Third Edition covers it

How deep it goes
Explains causes, escalation, detection, and safeguards, but stops short of specifying a general recovery algorithm.
Examples
Uses traffic congestion, brake malfunction, stack or heap exhaustion, and unbounded recursion as concrete illustrations.
What it assumes
Assumes familiarity with C operations, library calls, errno, recursion, and basic program execution.
What you can do after
Diagnose degradation by checking preconditions, inspecting error returns and errno, and limiting damage after failure.
How it connects
Connects program failure with resource exhaustion, recursion, error handling, signals, termination functions, and Byzantine failure.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.