4 ms·
There's so much great stuff here. First, Linux's default memory management strategy is bonkers. OOM killing rarely actually works in my experience, at least on
by IshKebab 4mo ago
There's so much great stuff here.
First, Linux's default memory management strategy is bonkers. OOM killing rarely actually works in my experience, at least on desktop. It takes ages to kick in and usually the system just freezes and you have to hard reboot. I've experienced this on every Linux system I've used, even my current one with 128GB of RAM and 64GB of swap, so don't say "it works for me". Windows and Mac do not have this issue at all, so clearly it's possible to do it better.
Has anyone tried using strict overcommit on desktop Linux?
Second, this bug is a great counterpoint to those annoying people who naysay Rust with "but not all bugs are memory safety bugs, what about logic bugs? huh?". Rust code would not have had this bug.
- man8alexd 4mo agoYes, many have tried to use strict overcommit on the desktop. It is a good footgun. https://unix.stackexchange.com/a/797888/1027 https://unix.stackexchange.com/a/797888/1027
- IshKebab 4mo agoThat doesn't really explain why it is a footgun.
- man8alexd 4mo agoThe last paragraph: > On the modern desktop, where programmers don't care about failing malloc(), disabling overcommit is shooting yourself in the foot. As you can observe, the memory allocations start failing long before the memory is exhausted.
- senfiaj 4mo agoSo it's a footgun because a lot of low quality software?
- man8alexd 4mo agoIs Firefox low quality?
- senfiaj 4mo agoWell, if Firefox also works on other OSes, it probably should gracefully handle failing allocations, isn't it?
- man8alexd 4mo agoNo, it doesn't handle failing allocations gracefully - https://unix.stackexchange.com/questions/797841/firefox-died-with-vm-enough-memory-not-enough-memory-for-the-allocation-des#comment1534064_797841 https://unix.stackexchange.com/questions/797841/firefox-died...
- silon42 4mo agoI lost cookies several times on disk-full condition...
- IshKebab 4mo agoIf a memory allocations fails with strict mode then you'll get a null pointer returns and some kind of crash or panic (in code that doesn't handle it properly). If it fails with the default mode the whole process will get killed by the OS. Is that really much better?
- man8alexd 4mo agoOOM is better. If a program doesn't handle ENOMEM properly, then its state is unpredictable and can lead to data corruption.
- IshKebab 4mo agoI don't think it's as simple as that. Killing a program can have unintended consequences too, e.g. corrupting files they were in the middle of writing.
- grg0 4mo agoWhat exactly does Rust solve here? Virtual memory is a hardware/OS feature.
- IshKebab 4mo agoThe bug that is detailed in the article. Wouldn't have happened with Rust.
- senfiaj 4mo agoThere was also a bug in the Linux kernel, or did I miss something?
- IshKebab 4mo agoYes there was. It's detailed in the article.
- senfiaj 4mo agoBut why wouldn't have happened with Rust? Sorry I can't find anything about Rust in the article. Or you mean if the Linux kernel was written in Rust and that stupid bool coercion was not possible?
- grg0 4mo agoIt's the latter; Rust won't allow the int->bool coercion. Though to be absolutely pedantic, !x is an int for x:int in C, there is no bool coercion involved; an if-statement takes an expression of any scalar value and evals to true on non-zero. Not that that helps to avoid introducing bugs anyway.
- IshKebab 4mo agoBecause Rust programmers would have used an enum or Result.
- grg0 4mo ago