15 comments

  • mrkeen 56 minutes ago
    Type 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:

      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.html
    
    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>."

    I wonder if TFA's example could be reproduced without mutability.

    • vrighter 14 minutes ago
      so what I take from this is that the rust compiler does not guarantee the stuff it claims to. Because new features of the type system is just being yolod instead of formally proven
      • csande17 2 minutes ago
        [delayed]
      • thfuran 6 minutes ago
        No mainstream compiler is formally proven. If you want a verified compiler, you pretty much have to choose between using a subset of standardml or a subset of C and the one proven compiler for each.
  • lambdaone 19 minutes ago
    Perhaps 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.

  • j4k0bfr 20 minutes ago
    Took 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...
  • vincent-uden 1 hour ago
    What 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.
    • insanitybit 1 hour ago
      For a long time `loop {}` was undefined behavior. Lots of l-unsounds are really nuts but a few are not.

      The reality is that if this were actually code that people wrote, well, it wouldn't have sat around for a decade.

    • LoganDark 1 hour ago
      I wonder if the reason it works is because you'd easily come across it in normal code, and someone didn't realize that saving the effort of implementing a check for this would result in unsoundness.
    • jvanderbot 1 hour ago
      Not really. I've worked with rust for 4 years, systems side, and never had to write a custom drop implementation. That's the gotcha here, not the rigamarole with the static+Send option type (which _would_ be something you'd encounter in prod).
      • bryanlarsen 54 minutes ago
        I've written dozens of custom Drop implementations. Well, many of them are named cleanup because of the async Drop mess in Rust, but...
      • neysofu 41 minutes ago
        That's easily the exception rather than the rule. I've seen custom `Drop` implementations in almost every non-trivial Rust codebase I worked on.
      • gspr 31 minutes ago
        A custom `Drop` appears very quickly with FFI code. Suppose for example you interface with some C library that expects you to call a function to release some resources.
  • Hugsbox 1 hour ago
    I don't understand how something like this could take so long to be discovered. Pretty crazy stuff.
    • lelanthran 50 minutes ago
      > I don't understand how something like this could take so long to be discovered.

      Maybe they wrote it in C :-)

      On a serious note, old software is generally more trustworthy than new software, because bugs are discovered over time and with usage.

      • zaphar 23 minutes ago
        Old C software is generally more trustworthy than new C software. I don't think this rule of thumb transfers across languages very well. And the definition of new vs old has a fairly large effect. If a language has been under constant change it doesn't matter when it was started a large part of the codebase is "new".
  • beanjuiceII 19 minutes ago
    • jeremyjh 1 minute ago
      I think it has no relevance here at all. Actix was unsound because of prolific use of unsafe. That was a poor design decision but a conscious one. TFA is just a bug.

      Having ideals does not mean there are never bugs.

    • ModernMech 14 minutes ago
      What do you mean?
  • fnord77 13 minutes ago
    Here'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

  • FuzzywarmWalnut 1 hour ago
    Worked 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.
  • badatnames 1 hour ago
    There is a collection of these someplace. Rust is better but it'll never be perfect, news at 10
    • zer00eyz 34 minutes ago
      Rust is good, I generally do not dislike it - but it does have flaws.

      I will happily continue to write things in Golang first. I don't enjoy refactors in Rust, and it's rare that I see things that genuinely need its raw performance.

      Cloudflare's Oxy is a stellar example of build in Golang till your design is settled and then port over for performance when you need it.

  • MrBuddyCasino 1 hour ago
    The heart of the matter:

      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);
      }
    
    I wonder if the certified compiler for safety critical uses (edit: Ferrocene) has the same issue.
    • afdbcreid 34 minutes ago
      > I wonder if the certified compiler for safety critical uses has the same issue.

      It uses the same code, so yes.

      (Although I don't know what are their guidelines, it might be that they require avoiding code relying on implied bounds, for example).

    • high_na_euv 1 hour ago
      which compiler?
    • wg0 50 minutes ago
      DeepSeek v4.1 Flash thinks it should NOT compile. Whereas in reality it DOES compile which is why it is filed as a bug.
      • jug 39 minutes ago
        They're seriously using AI as a judge for what to file?
        • afdbcreid 35 minutes ago
          The issue and none of the comments mention AI. It is pretty clear your parent said it by themselves.
        • wg0 35 minutes ago
          I was just checking what outcome an LLM would have based on the patterns in its probabilistic distribution it has seen the wild.

          Most LLMs would probably say this piece of code won't compile.

          • ChickeNES 4 minutes ago
            chatgpt and grok linked to the the soundness issue, claude I am in usage timeout, and gemini shit the bed as usual: "The compiler rejects the program with error[E0597] on the assignment q.0 = Some(&l)"
  • JABVOLT 34 minutes ago
    very very good job
  • akoboldfrying 58 minutes ago
    As an old C++ guy, my take is: Heh heh heh.

    ETA: Downvoters, I salute you. Without your selfless courage, the forces of light humour would surely prevail.

    • fg137 5 minutes ago
      This is not the first soundness bug. Some bugs aren't fixed for years. The Rust community is well aware that such bugs exist, will be found, and address them just like other high impact bugs. In other words, if you paid the slightest attention to the development of Rust language, you would know this is surprising but not unexpected, and has happened many times.
    • wg0 27 minutes ago
      You got my upvote and this one decade old issue:

      https://github.com/rust-lang/rust/issues/25860

    • mrlonglong 34 minutes ago
      You got my upvote.
    • rvz 46 minutes ago
      Yeah. A reminder that no language is a silver bullet even if it is heavily marketed. Especially with the “written in XYZ™” tag line.
  • rvz 54 minutes ago
    This should not be a surprise at all given the amount of soundness bugs that were collected in the Rust compiler but no-one cared. [0]

    [0] https://arxiv.org/abs/2608.28713

    • optionalsquid 39 minutes ago
      It looks like 18 of the 30 issues listed in table 4 had already been fixed when that paper was released, and there is activity in most of the rest. One was recently flagged as being fixed by -Znext-solver, and another has the submitter write that it is fixed, but the issue is not closed. And that's before you consider the impact of the individual issues; how many of the remaining issues impact "real" code?

      So I don't think it's fair to claim that "no-one cared".

    • purplesyringa 39 minutes ago
      I don't think "no one cared" is a fair characterisation. The paper doesn't support this conclusion, and from experience I'd say that the two difficulties in fixing unsoundness are doing so without breaking existing code (Rust guarantees stability unless the code is unsound, and introducing previously missing checks can cause sound code to stop compiling, which is a problem if it occurs often) and doing so in a reliable way that can be supported long-term. Rust is currently in the progress of stabilizing next-solver and Polonius, both of which fix multiple long-standing bugs and have been worked on for years now due to intrinsic complexity, performance considerations, compatibility issues, etc. It's not that no one cares, it's just that this stuff is hard and takes time.
  • cowlevel 1 hour ago
    Rust is not a memory-safe language. cve-rs proved it years ago but commenters always argue that cve-rs is too contrived to matter, or that it's a compiler bug so it doesn't count.
    • insanitybit 1 hour ago
      lol do you think that cve-rs was required? there is literally an l-unsound tag on rustc's github, this isn't some embarrassing or secret thing.

      Safe rust is safe, granting `unsafe` and compiler errors. This isn't a secret.

    • high_na_euv 1 hour ago
      in compare to c and cpp? it is
      • cowlevel 59 minutes ago
        And in absolute terms?
        • qweqwe14 49 minutes ago
          Literally nothing can be anything in absolute terms, what's your point? The fact is that Rust is miles better than any other language in terms of memory safety & performance ratio. That's all that matters.
        • high_na_euv 24 minutes ago
          cmon, it is time move on.

          it has been discussed bilion times

    • david-gpu 55 minutes ago
      Let us not conflate a bug in an implementation (rustc) with a defect in the language (Rust).
      • mrkeen 47 minutes ago
        AFAIK there isn't a language spec. Rustc is the language for now.
        • afdbcreid 32 minutes ago
          But bugfixes are also allowed. So the fair conclusion is that the implementation is broken, but the language is not - because it's possible to fix, and it's possible for all known soundness issues (including the cve-rs one). For this one specifically, I've heard people are already working on a fix.
          • cowlevel 21 minutes ago
            If the compiler is the language that implies there is currently a bug in the language, which will be fixed when the compiler is fixed.
        • david-gpu 28 minutes ago
          My understanding is that it is work in progress, via Ferrocene.
          • beanjuiceII 14 minutes ago
            Ferrocene has his same flaw
            • david-gpu 1 minute ago
              If that's the case then I was wrong.
      • cowlevel 48 minutes ago
        Which clause of the language specification is being violated?
        • lkey 26 minutes ago
          Lifetimes can be effectively erased via covariant assignment. It's in the title. Even a beginner could understand these assignments are not in spec? Are you just being contrary to be contrary?
          • csande17 15 minutes ago
            If that's the definition you're using, then C is also a safe programming language. In fact, C is even safer, because it actually does have a specification that lists all the invariants that the programmer has to uphold themselves because the compiler doesn't check them.
          • cowlevel 21 minutes ago
            So point to the spec
            • beanjuiceII 13 minutes ago
              this is probably a great opportunity for rust to get one, if they want to be taken seriously