3 ms·
“...Rust in the kernel is dependent on *kernel* rules”
- Smaug123 4y agoPreviously discussed at https://news.ycombinator.com/item?id=33056077 https://news.ycombinator.com/item?id=33056077; to quote myself from that discussion: > I think a much better email from the thread to link to would be the earlier https://lkml.org/lkml/2022/9/19/840 https://lkml.org/lkml/2022/9/19/840, where Linus actually talks about some of the challenges of kernel programming and how they differ from user-space programming.
- turtleyacht 4y ago(https://news.ycombinator.com/item?id=33056761 https://news.ycombinator.com/item?id=33056761)
- AnimalMuppet 4y agoIs this a rule that applies more generally than the kernel? "What you're trying to do is more important than the language you're trying to do it in", maybe? I'm not quite happy with the way I put that. If you have better wording, feel free to chime in.
- flumpcakes 4y agoI think it's a battle of ideologies: Rust wants to be safe, and as a part of that it prefers to Panic than have undefined behavior/memory corruption. Personally I would prefer my pacemaker to miscount a beat than shutdown completely... There are some people who would prefer the purity of "Panic" on a memory corruption/error, and there are some people who are operating space craft and safety critical systems where a "Panic" could lose lives. This is why I don't buy-in completely with claims of safety, when we've been using Assembly/C/C++/Ada/etc. for decades. It's a trade off and you're not going to stop cosmic rays flipping your bits.
- dmm 4y ago> Personally I would prefer my pacemaker to miscount a beat than shutdown completely... A panic doesn't imply shutting down. If my api panics a system above it(systemd, docker, k8s) restarts the api from a known good state. Memory corruption can do much worse.
- AnimalMuppet 4y agoOr a hardware watchdog. "A system above it" doesn't have to be software.
- salawat 4y agoCool, what'a above the kernel? Note: Hypervisor is not the right answer.
- flumpcakes 4y agoWhen an OS kernel panics it usually means some kind of catastrophic loss, often requiring a reboot. Precisely because the Linux kernel tries to continue in all cases. As Linus has made quite direct comments on this: a language with run time panics will not be accepted into the Linux kernel.
- fiedzia 4y ago> There are some people who would prefer the purity of "Panic" on a memory corruption/error, If the OS will encounter memory corruption, it cannot reliably do anything but restart. Anything else will risk further corruption and will make any investigation more difficult and effects more distant from the cause. > and there are some people who are operating space craft and safety critical systems where a "Panic" could lose lives. So could erratic behaviour.
- josephcsible 4y agoI disagree with "Not completing the operation at all, is not really any better than getting the wrong answer." Getting the wrong answer can lead to security vulnerabilities and subtle but pervasive data corruption.
- flumpcakes 4y agoHardware also corrupts data. I would always want a kernel to continue as best it can, than flat out panic. This isn't an electron app, this is software that can be deployed to anything and everything. Any kernel that did panic would stop getting used by the majority of people pretty fast as being "too unreliable".
- fiedzia 4y ago> Any kernel that did panic would stop getting used by the majority of people pretty fast as being "too unreliable". So will kernel that corrupts data, but panic is much easier to fix than corrupted data because it's closer to the source of the problem.
- 2OEH8eoCRo0 4y agoThey don't say it's not better, they say it's not really better.
- samgranieri 4y agoDisclaimer: I've written very little C, some C++ in high school and college (20 years ago) and I'm just starting to play around with rust. I'm honestly not surprised a discussion like this is popping up on LKML. At least Torvalds isn't up and swearing at these new contributors like he used to