5 ms·
If you can't fail gracefully, then crash as soon as possible. Trying to sputter along is just asking for worse problems.
by Sanddancer 11y ago
If you can't fail gracefully, then crash as soon as possible. Trying to sputter along is just asking for worse problems.
- webkike 11y agoWell, considering malloc gives a NULL pointer on failure, a crash at some point is pretty clearly inevitable.
- Sanddancer 11y agoYes, but it becomes harder to tell where in the code that happened. If you run abort() or the like, you've got more information as to the circumstances of the crash.
- richm44 11y agoSadly it doesn't on linux due to overcommit. You can actually get the failure much later when you try to use the memory. The exception is when you try to allocate absolutely huge buffers. So malloc returning a valid pointer doesn't indicate success (though it returning NULL does indicate failure).
- striking 11y ago(these kinds of) Crashes can be manipulated, though. If you can't restore a stable state, you have created instability. Failing gracefully in this context means failing without creating instability or insecurity.
- teacup50 11y agoAn abort()/__builtin_trap/etc shouldn't generally be manipulable.
- AnthonyMouse 11y agoThe failure mode is the one where you terminate in the middle of an operation that was expected to be atomic or ordered and then the program restarts and does step two without finishing step one.