11 year old unsoundness bugs found in Rust borrow checker
github.com - 634 poäng - 364 kommentarer - 43027 sekunder sedan
Kommentarer (34)
- GrantMoyer - 34370 sekunder sedanIt's surprising this bug went unnoticed for so long, but at least it's easy to fix, since it's not a bug with the type system itself; it's just a bug in the compiler. The compiler should always have been rejecting that code according to lifetime rules of Rust's type system, so the fix is to just make it reject the code, rather than having to change the fundamental rules of lifetimes.
- weinzierl - 36434 sekunder sedanThis is remarkable but not super unusual. There are more than 100 issues labeled unsound currently. Some are long standing but from what I understand the new trait solver will unblock fixes for some of them (but probably not the one in OP).
- lambdaone - 37784 sekunder sedanPerhaps ironically, AI-based searching of the Rust compiler for bugs is likely to find more of these, pushing Rust closer and closer to the point of complete reliability.
The eventual formalization of Rust and a creation of a formally proven compiler is presumably going to be the end point of this process.
- Eridrus - 30023 sekunder sedanI feel like these things get waved around as gotchas without any sense for whether any real code is impacted.
It will be interesting to see if fixing this bug actually causes any crates to not compile.
- mrkeen - 40034 sekunder sedanType systems are hard! Check out https://counterexamples.org/
I gave it a quick scan for Rust examples; there are 11 samples among the following pages:
The first thing I always look for is mutability (combined with some other tricky feature), e.g. "Now it's a Just(3):Maybe<Int>, now it's a Nothing:Maybe<Int>, now it's a Nothing:Maybe<String>."https://counterexamples.org/eventually-nothing.html https://counterexamples.org/mutable-matching.html https://counterexamples.org/selfishness.html https://counterexamples.org/scope-escape.html https://counterexamples.org/nearly-universal.htmlI wonder if TFA's example could be reproduced without mutability.
- j4k0bfr - 37847 sekunder sedanTook me a good couple minutes to wrap my head around. Man, what a nasty bug. I guess this specific use-case is rare. Time to see if any of the big libs are affected...
- randyrand - 33366 sekunder sedanI just wish Rust handled out of memory more gracefully like a normal error.
- wat10000 - 29458 sekunder sedanThe emotional reactions to this stuff are so weird. Yeah, software has bugs, what a surprise. That doesn't mean that static safety is useless or that we should all just continue YOLOing stuff in C.
- - 30529 sekunder sedan
- gosen - 32061 sekunder sedanI'm sure we'll get more of those on other languages / frameworks too. I tend to believe that it's for good
- FuzzywarmWalnut - 40687 sekunder sedanWorked on a variance-related lint once and the scary part is how rarely anyone writes down variance by hand, so bugs there just sit untested for a decade.
- Surac - 30395 sekunder sedanThe question is. If rust used rust would that have prevented this?
- MrBuddyCasino - 40634 sekunder sedanThe heart of the matter:
I wonder if the certified compiler for safety critical uses (edit: Ferrocene) has the same issue.struct Q<T: 'static>(Option<T>); impl<T: 'static> Drop for Q<T> { fn drop(&mut self) { // Code in here has access to a non-'static &String // but assumes that it's a &'static String } } fn main() { let l = String::new(); let mut q = Q(None); q.0 = Some(&l); } - asdfman123 - 2721 sekunder sedanBeg, Borrow, or Steal: a guide to Rust object ownership
- badatnames - 40544 sekunder sedanThere is a collection of these someplace. Rust is better but it'll never be perfect, news at 10
- - 39379 sekunder sedan
- vincent-uden - 40992 sekunder sedanWhat the hell. This is not the esoteric, crazy, impractical constellation I expected to find with a title like this. The minimal example is so simple and is definitely something you'd easily come across in normal code.
- Hugsbox - 40774 sekunder sedanI don't understand how something like this could take so long to be discovered. Pretty crazy stuff.
- chelseahermes - 30082 sekunder sedan[flagged]
- kirle_pg - 24314 sekunder sedan[flagged]
- TesterVetter - 10723 sekunder sedan[dead]
- akoboldfrying - 40149 sekunder sedan[flagged]
- shevy-java - 31516 sekunder sedan[flagged]
- rvz - 39911 sekunder sedan[flagged]
- cowlevel - 40782 sekunder sedan[flagged]
- grommz - 33074 sekunder sedan[flagged]
- z3ratul163071 - 33988 sekunder sedanso now what? back to c++?
- JABVOLT - 38682 sekunder sedanvery very good job
- fnord77 - 37433 sekunder sedanHere's the weakness of compiled programs. Does this compiled code have this vulnerability? You have no idea. At least with a VM or interpreter you can scan for vulnerable versions and replace the runtime or the specific library.
With this you have to recompile everything
- Rapzid - 26712 sekunder sedan
Inspired by that Rust code.JFC I have never seen Rust code Threw up in my mouth - rurban - 32194 sekunder sedanAnd a fork fixed it before upstream rust :)
- sreekanth850 - 19801 sekunder sedanWas this done by LLM? this is a doubt. because recently we are seeing many such bug reports.
- beanjuiceII - 37826 sekunder sedanwonder what happened to this https://raphlinus.github.io/rust/2020/01/18/soundness-pledge...
- cheney_2004 - 30394 sekunder sedanI think one social issue I’m seeing is that the Rust community bashes other languages for safety but then glosses over or even completely ignores their own safety risks (see supply chain). I would rather see Rust focus on its actual features without bashing others and maybe start moving away from claiming the gold metal on security. Being less toxic is always a good thing for long term health.
Nördnytt! 🤓