Linus Torvalds Memory Safety
From Linus Torvalds <> Date Wed, 14 Apr 2021 12:31:10 -0700 Subject Re: [PATCH 07/13] Rust: Kernel crate On Wed, Apr 14, 2021 at 11:47 AM <ojeda@kernel.org> wrote: > +#[alloc_error_handler] > +fn oom(_layout: Layout) -> ! { > + panic!("Out of memory!"); > +} > + > +#[no_mangle] > +pub fn __rust_alloc_error_handler(size: usize, align: usize) -> ! { > + panic!("Out of memory!"); > +} Again, excuse my lack of internal Rust knowledge, but when do these end up being an issue? If the Rust compiler ends up doing hidden allocations, and they then cause panics, then one of the main *points* of Rustification is entirely broken. That's 100% the opposite of being memory-safe at build time. An allocation failure in some random driver must never ever be something that the compiler just turns into a panic. It must be something that is caught and handled synchronously and results in an ENOMEM error return. So the fact that the core patches have these kinds of panic!("Out of memory!"); things in them as part of just the support infrastructure makes me go "Yeah, that's fundamentally wrong". And if this is some default that is called only when the Rust code doesn't have its error handling, then once again - I think it needs to be a *build-time* failure, not a runtime one. Because having unsafe code that will cause a panic only under very special situations that are hard to trigger is about the worst possible case. Linus panic!("Out of memory!"); here's your memory safety, bro..
На изображении Линус Торвальдс смеётся рядом со скриншотом электронного письма, посвящённого обработке ошибок выделения памяти в Rust и ядре Linux. Внизу крупно повторяется panic!("Out of memory!"); и саркастическая подпись «here's your memory safety, bro..». Мем высмеивает обещания безопасности памяти Rust, показывая, что аварийная паника при нехватке памяти якобы противоречит заявленной надёжности.
laughing man / смеющийся мужчинаcomputer screenshot / скриншот компьютераemail message / электронное письмоsource code / исходный кодcode editor text / текст редактора кодаwooden wall / деревянная стенаblack shirt / чёрная футболкаglasses / очкиlarge caption / крупная подписьRust programming language / язык программирования RustLinux kernel / ядро Linux
- @right_wing_dev_squads / 11074 2024-12-10
- @ithueti / 14780 2024-12-11
- Template
- Laughing Linus Torvalds
- Type
- image
- Size
- 800×675 · 103.3 KiB
- Mood
- sarcastic, mocking
- Language
- en
- Added