Live data from Hacker News

Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

github.com

51–60 of 366 posts

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#52
post #29

Earlier quoted context omitted.

"unsafe" is a promise to the compiler that you're going to ensure invariants that the compiler can't check. Rust only promises to eliminate UB if the invariants are held. You can still get UB by violating that promise, as this bug demonstrates.

But the title here says "in safe Rust", no? Is the unsafe code causing UB in safe code? I thought the unsafety couldn't "spread" like that in Rust.

I can't tell if you're trolling but `unsafe { crash() }` is safe from the compiler's perspective. Otherwise you wouldn't be able to achieve anything in 'safe' rust, even print to stdout.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#53
post #29

Earlier quoted context omitted.

"unsafe" is a promise to the compiler that you're going to ensure invariants that the compiler can't check. Rust only promises to eliminate UB if the invariants are held. You can still get UB by violating that promise, as this bug demonstrates.

But the title here says "in safe Rust", no? Is the unsafe code causing UB in safe code? I thought the unsafety couldn't "spread" like that in Rust.

it's more straightforward to write safe rust when rust owns everything, In real world you often are interfacing with underlying libs or systems etc, which you need to treat as invariants but also handle yousrelf manually to make guarantees to compiler. unsafe exists in tons of codebases it's just you have to make sure you encapsulate it properly, which is what this bug is.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#54
post #29

Earlier quoted context omitted.

"unsafe" is a promise to the compiler that you're going to ensure invariants that the compiler can't check. Rust only promises to eliminate UB if the invariants are held. You can still get UB by violating that promise, as this bug demonstrates.

But the title here says "in safe Rust", no? Is the unsafe code causing UB in safe code? I thought the unsafety couldn't "spread" like that in Rust.

It can spread into safe code when you build an incorrect "safe" abstraction around unsafe code. Which the Bun Rust port apparently has.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#55

Earlier quoted context omitted.

[flagged]

I'm not sure that HN is that influential that buying up a few accounts would matter. To what end?

I think HN has an outsized influence in the industry, for its size. There are a lot of big tech employees and startup founders reading it. Account purchasing absolutely happens, I've discovered and gotten banned at least a dozen years-old accounts that were blatantly sold and puppeteered by bots in the past. The comments aren't obviously bot-written this time around, so I can't conclusively prove it happened in this case, but it is a thing that happens in general and something to be aware of. There's also vote selling to promote things onto the front page. Given how cheap shilling on HN is, and the fact that many will perceive it to be organic while always viewing straightforwards ads skeptically, I wouldn't be surprised if the cost:effectiveness ratio probably beats any other form of advertising.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#56

There'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…

[deleted]

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#57

There'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…

Hmmm, given the general mood in this case, I feel like there's a lot of people keen to find any criticism of the code they can and amplify it as possible. Most of it strikes me as relatively shallow at the moment, though (that is, apart from the fact that merging such a large LLM assisted port is certainly a, uh _bold_ move (to put it lightly), there's not much that people are pointing out about the actual result that feels like it's worse than any other port in progress, but there is definitely a lot of hay being made about any issue that is found).

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#58

So Bun saga has been "Zig, let me Ai you" "no" *Ai's Zig fork, suffers from memory bugs* "Well I'm moving!" *Ai's code into Rust, suffers from memory bugs*

Sure. I'm completely unaffiliated and think Zig's AI stance is ridiculous & politically-motivated and a port is absolutely justified if they will not budge. Apparently I am deeply in the minority.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#59
post #38
post #28

Earlier quoted context omitted.

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…

OK but the title says "in safe Rust". Am I misunderstanding something? All the replies here are saying how it's allowed in unsafe Rust, which is not what the title says.

If code in an unsafe block triggers undefined behavior, then the assumptions the compiler makes regarding safety will no longer be true, and purely safe code (code with no unsafe blocks) is no longer guaranteed to be safe. This is what's happening in the example the person on Github wrote in the issue.

Re: Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"

#60
What I don't understand is if they were going to translate Zig to unsafe Rust, why not just build a translation tool for it? You could do a one-to-one mapping of language constructs, hardcoding patterns in your codebase, and as one friend put it "Tbh they could've just hooked up zig translate-c to c2rust". They would get deterministic translation, would probably have not been a heavy investment to build, and the output would have the same assurances as the input.

In this case, I would trust the output even less than the input. The input was memory-unsafe but hand-written. The output is memory-unsafe but also vibe-coded and has had no eyeballs on it. What is the point of abusing agentic AI for this use-case?

Post reply on HN