I thought Rust treated undefined behaviour as a compiler bug? Does anyone know what's actually happening here?
Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
31–40 of 366 posts
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#32Earlier quoted context omitted.
That kind of error was entirely avoidable. There are well-known tools in the Rust ecosystem that detect this kind of error and while the tools do not detect all instances of UB caused by mistakes in unsafe blocks, it's still considered good practice to run them.
>There are well-known tools in the Rust ecosystem that detect this kind of error Yes, tools like Miri, which this very post is about.
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#33There's a book that changed a lot of the way I think about attention and media [0]. The book isn't very good, but it flags something relevant here. There is a huge asymmetry between the reach of a big, flashy announcement (here: bun was re-written in memory-safe rust in a couple weeks), and the relatively small reach of a correction (often just a footnote on an old article, here a GH issue). This asymmetry is well un…
> a big, flashy announcement (here: bun was re-written in memory-safe rust in a couple weeks) Did they even claim it was "memory-safe"? Every discussion of this topic has had dozens of comments noting that their vibed codebase is bursting at the seams with unaudited unsafe blocks, lightly reviewed by people who seem to not only seem to not understand Rust, but who seem incensed at the idea of needing to understand an…
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#34In fact using the word "rewrite" itself is pretty inaccurate.
As has been mentioned the goal was a port so they "could" eventually rewrite most of it to be idiomatic rust. The main benefit of this now is the compiler and being able to use these tools to fix issues that were already being hidden when it was in zig.
If you go into this codebase expecting to see idiomatic rust and get angry when it's not there, you are going in with the entirely incorrect attitude.
It's understandable how people see it as AI slop or whatever given the division among developers at the moment. But please see it for what it is instead of just jumping to conclusions.
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#35Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#36This had to happen, for many reasons: - Its a throw thing at the wall and see what sticks situation - LLMs will improve* - Using LLMs in an agentic way will improve (git worktrees, sliced PRs, spec driven steps) So what happened here is a mess, but you gotta break a few eggs to make a souffle. It's a learning step and I am glad it happened, there will be so many things to debrief from this. I don't use Bun or Rust bu…
A souffle has not been made
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#37This Bun rewrite feels like a potential Mythos marketing stunt.
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#38I thought Rust treated undefined behaviour as a compiler bug? Does anyone know what's actually happening here?
Safe Rust does. Unsafe Rust allows you to tell the compiler “hold my beer”. It’s a concession to the reality that the normal restrictions of Rust disallow some semantically valid programs that you might otherwise want to write. The safeguards work great in most cases, but in some they’re overly restrictive. In practice, the overwhelming majority of code is able to be written in safe Rust and the compiler can have you…
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#39This doesn't seem surprising, given the straight translation that they prompted. Couldn't a case be made that it's better to get Bun to the to the language with the stronger type system first and, once there, use that stronger type system as leverage for these kinds of improvements as a follow-on effort? It seems preferable to requiring perfection on the very first step.
What is a bit disappointing is that the Rust code apparently has APIs that aren't marked unsafe but may cause UB anyway. When doing this kind of translation, I'd always err on the side of caution and start by marking all/most things unsafe. Or prompt the slopbots to do the same I guess.
Then you can go in and verify the safety of individual bits step by step.
Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
#40This doesn't seem surprising, given the straight translation that they prompted. Couldn't a case be made that it's better to get Bun to the to the language with the stronger type system first and, once there, use that stronger type system as leverage for these kinds of improvements as a follow-on effort? It seems preferable to requiring perfection on the very first step.