3 ms·
I disagree. Not handling failures correctly is a time honored tradition in programming. It is so easy to miss. For example, how often have you seen a malloc c
by cogman10 6y ago
I disagree.
Not handling failures correctly is a time honored tradition in programming. It is so easy to miss.
For example, how often have you seen a malloc check for `ENOMEM`?
Even though that is something that could be semi common. Even though that's definitely something you might be able to handle. Instead, most code will simply blow chunks when that sort of condition happens. Is the person that wrote it "wrong"? That's debatable.
Some languages like Go make it even trickier to detect that someone forgot to handle an error condition. Nothing obvious in the code review (other than knowledge of the API in question) would get someone senior to catch those sorts of issues.
So the question is, HOW do you catch those problems?
The answer seems obvious to me, you simulate problems in integration tests. What happens when Service X simply disappears. What happens when a server restarts mid communication? Is everything handled or does this cause the apps to go into an non-recoverable mode?
This are all great infrastructure tests that can catch a lot of edge case problems that may have been missed in code reviews. Even better, that sort of infrastructure testing can be generalized and apply to many applications. Making rare events common in an environment makes it a lot easier to catch hard to notice bugs that everyone writes.
It's basically just Fuzz testing but for infrastructure. Fuzz testing has been shown to have a ton of value, infrastructure fuzzing seems like a natural valuable extension of that. Especially when high reliability and low maintenance is something everyone should want.
- im3w1l 6y agoAs a community we have basically decided against handling of out of memory; that it's better to crash, and design the program so that such a crash will not cause corrupt state. Consider over-commit. It means that the malloc call will succeed even if there isn't available memory. Instead the system just hopes you wont make use of the memory you asked for. And if you do make use of it, well then the OS might kill you. Just like that. No opportunity for error handling.
- eru 6y agoReliably crashing _is_ a way to handle out of memory errors. When you don't handle it, you get something closer to undefined behaviour instead.
- perl4ever 6y ago>For example, how often have you seen a malloc check for `ENOMEM`? I've never concerned myself with that, but it's apparently a lot more complicated than just doing that check. See: https://news.ycombinator.com/item?id=20143277 https://news.ycombinator.com/item?id=20143277 https://scvalex.net/posts/6/ https://scvalex.net/posts/6/ Some of the thread is hilarious, for instance: "malloc is not allowed to return a non-null pointer to a memory block that cannot be written to. Linux does it anyway, and in doing so blatantly violates the standard. ... That is my point, it doesn't fail. Either the kernel finds out a way to map the memory and it succeeds, or it kill the program and the instruction never runs. Code that doesn't run can't violate the standard."