15 ms·
Rust’s borrow checker has been mathematically verified to be always sound.[0] These are edge case implementation bugs that user code is unlikely to touch. I hav
by quamserena 1y ago
Rust’s borrow checker has been mathematically verified to be always sound.[0] These are edge case implementation bugs that user code is unlikely to touch. I have never had a soundness hole/segfault from safe Rust, and I am not aware of any code in the wild which stumbled into one of these soundness holes either. The main bug is [1], which is very contrived lifetime shenanigans that wouldn't appear in real code. Some bugs [2] are miscompilations coming from the LLVM side. If implemented perfectly, all safe Rust code would be sound, but of course all programs have bugs. The important part is that 99.9% of safe Rust code is sound.
[0] https://hal.science/hal-01633165v2/document https://hal.science/hal-01633165v2/document
[1] https://github.com/rust-lang/rust/issues/25860 https://github.com/rust-lang/rust/issues/25860
[2] https://github.com/rust-lang/rust/issues/107975 https://github.com/rust-lang/rust/issues/107975
- leoh 1y agoDitto. I have literally never encountered a segfault in Rust in almost 2y except when calling C code via FFI.
- wolvesechoes 1y agoSo it is not 100% contrary to some bombastic claims floating around.
- galangalalgol 1y agoI don't feel I was bombastic, simply ignorant. I knew there had been unsoundness bugs in the past, but I thought they had all been fixed at this point. I see why it is taking them so long to fix this one, but yes it is not 100%. I will rather say that I have had no segfaults from safe rust in the decade I've been using it, and that even after 35 years in c++ I still average a couple a month. Probably worse now because I'm rusty when I go back to use it for something. It could be argued I'm really bad at c++, and maybe that is true, but then maybe I shouldn't be using it, and should use rust instead, it allows me to get the same job done.