A bit of inspiration most weekdays for exploring your mindset .

crash or not

Khem Raj December 18, 2024 #meta

In software programming sometimes we are faced with situations where we can write logic to recover from an unexpected situation or simply crash the program

We see often patches submitted to projects (GNU Glibc comes to mind) to add a check for an error condition and try to emit an error message and continue. Some developers have the view that it should crash if it has entered an unknown state because a program which is in bad state can do more damages then a crashed program. There can be a parent program which can be used to do data recovery and restart if needed.

Other argument goes, sending a human-readable message is good because it can be used by the users of library or program to take action. It is good to recover and only die gracefully. The recovery can be quite complex logic and change the data in uncertain ways. It might have abused resources (memory/io/CPU) etc.

So there is no one way, it will depend upon what the software program is supposed to do and the constrained where it is to operate.