15 Program failure
This chapter covers
- Wrongdoings leading to failure
- Degradation of the program state
- Unfortunate incidents
- Anticipatory error checking
- Cleanup
C programs can fail in very different ways—silently, sporadically, predictably, or with pomp and circumstance. Commonly, much emphasis is put on the things that may happen when a program fails, and attention is withdrawn from the questions of if a program fails and why. This is apparent with the term that is often (even falsely) applied to such situations: undefined behavior. This term even has an abbreviation in the jargon: UBC. As the term itself suggests, its focus is on the behavior of the program (or, better, the whole system) after an error occurred and not on the reasons that lead to the error. It’s a bit similar to trying to improve road safety by scaremongering drivers with fines or prison sentences, instead of promoting regular security checks of cars, requiring licenses, or educating drivers and passengers about the benefits of wearing a seat belt.