News for hackers. Stuff that matters.
Re:The Linux kernel's inability to gracefully handle low mem... by enneff on Tuesday August 06, 2019 @06:36AM (#20623940)
But any process can be trying to allocate at the time your system runs out of memory, and most applications are not authored to handle malloc failing. Process failure seems easier to work around, from what I’ve seen. Would love to hear more from someone who has contrary experience.
Re:The Linux kernel's inability to gracefully handle low mem... by AnIdiotOnTheNet on Tuesday August 06, 2019 @08:20AM (#20624444)
At least you can then properly blame the software for doing the wrong thing and potentially patch it. The kernel should not implement global behavior that encourages improper memory allocation failure handling.
Re:The Linux kernel's inability to gracefully handle low mem... by AgentOrange1234 on Tuesday August 06, 2019 @08:45AM (#20624602)
Yes so much. The overcommit approach seems to be to say, “Most people are lazy so we shouldn’t allow anyone to brush their teeth.” Handling malloc failures isn’t rocket science.
Re:The Linux kernel's inability to gracefully handle low mem... by the_why_of_y on Tuesday August 06, 2019 @03:34PM (#20628659)
Do you have an example of a nontrivial user-space project that has malloc failure handling that actually works, with tests and all? The one I'm aware of is SQLite. Then there is DBus, whose author disagrees with your assessment.

https://blog.ometer.com/2008/02/04/out-of-memory-handling-d-...

Re:The Linux kernel's inability to gracefully handle low mem... by wahern on Wednesday August 07, 2019 @08:23PM (#20640661)
Lua, various OS kernels

Like any aspect of writing software, how you approach the problem effects the complexity of the final product. If someone doesn't make a habit of handling OOM, then of course their solutions are going to be messy and complex; they're going to "solve" the problem in the most direct and naive way, which is rarely the best way.

For example, unless I have reason to use a specialized data structure, I use intrusive list and RB-tree implementations, which cuts down on the number of individual allocations many fold. Once I allocate something like a request context, I know that I can add it to various lists and lookup trees without having to worry about allocation failure. Most of my projects have more points where they do I/O operations than memory allocations. Should people just ignore whether their reads or writes failed, too?

Re:The Linux kernel's inability to gracefully handle low mem... by lokedhs on Thursday August 08, 2019 @03:43AM (#20642607)
The JVM, and any other runtime which allocates its heap up front. You could argue that's cheating, but it does give you predictable behaviour.
Re:The Linux kernel's inability to gracefully handle low mem... by pcwalton on Tuesday August 06, 2019 @12:46PM (#20626897)
Incorrectly handling malloc failures has been responsible for a lot of security problems. We are all better off acknowledging that C programmers are broadly incapable of writing correct OOM handling at scale and figuring out what to do with this fact, instead of wishing that it weren't this way.