2 ms·
I agree with this 100%. Crashes are a way of not-so-subtly reminding you that your code is still buggy, and exactly where it crashed is usually a good indicator
by userbinator 10y ago
I agree with this 100%. Crashes are a way of not-so-subtly reminding you that your code is still buggy, and exactly where it crashed is usually a good indicator of where to start debugging.
Rule of Repair: Repair what you can — but when you must fail, fail noisily and as soon as possible.
To take this example to the extreme, imagine if the default state of the runtime/OS were configured so that invalid memory accesses didn't cause segfaults, but e.g. yielded -1 or 0 or some other value and simply let the code continue... by the time you see something wrong, it's probably very far away from what originally caused it.
It's funny to see OpenBSD's printf doing this explicit null-checking and that they are considering to remove it, when AFAIK Microsoft's C library printf has always done the IMHO sane thing of just reading and writing to whatever addresses it's been given --- and if they turn out to be invalid, like null, then it crashes as it should.
- MagnumOpus 10y agoRule of Real World Developmen: Repair what you can and keep it running with kludges, because if your program fails noisily and soon, it gets uninstalled, and you get fired.