A friend of mine writes firmware for embedded devices like automatic door controls. Besides having very well designed and redundant hardware (multiple PSUs etc.) the software does a lot of things to keep itself running robustly. For example, the microcontroller regularly tests its own memory for bad blocks and compensates accordingly - similiar to what flash memory controllers do.
So yeah, even if you don't go into space or inside a nuclear reactor software can be written to tolerate a lot of harware failures.