this post was submitted on 14 Mar 2024
1283 points (98.5% liked)

Programmer Humor

19606 readers
654 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] EinfachUnersetzlich@lemm.ee 73 points 8 months ago (3 children)

If you can make safe Rust segfault you're doing something wrong.

[–] intelisense@lemm.ee 42 points 8 months ago (2 children)

To be fair, you are doing something wrong if you're app segfaults no matter what anguage you wrote it in...

[–] bamboo@lemm.ee 23 points 8 months ago

Despite that, some languages make it easier to be wrong than others.

[–] Faresh@lemmy.ml 3 points 8 months ago

I don't think so, since memory safe languages are supposed to prevent you from doing that, so it would be the language implementation's fault.

[–] xlash123@sh.itjust.works 21 points 8 months ago (1 children)

It actually is possible to segfault in safe Rust, although it is considered a bug. Proofs of concept are shown in this cve-rs crate.

If you want an explanation of why this happens, I recommend this video: https://youtu.be/vfMpIsJwpjU

[–] technom@programming.dev 9 points 8 months ago (1 children)

So you can't get a Rust program to segfault without trying really hard. I haven't observed a single segfault in the normal Rust code I wrote in the past 8 years.

[–] apt_install_coffee@lemmy.ml 6 points 8 months ago (1 children)

The code used in cve-rs is not that complicated, and it's not out of the realm of possibility that somebody would use lifetimes like this if they had just enough knowledge to be dangerous.

I'm as much a rust evangelist as the next guy, but part of having excellent guard rails is loudly pointing out subtle breakages that can cause hard to diagnose issues.

[–] technom@programming.dev -1 points 8 months ago (1 children)

If that's so trivial to trigger, people would be doing so everywhere. Have you seen it in the wild or heard of anyone doing so?

[–] apt_install_coffee@lemmy.ml 0 points 8 months ago (1 children)

If someone did, why would I hear of it?

[–] technom@programming.dev 0 points 8 months ago (2 children)

So you're just spouting some cooked up theory. Not a practical scenario.

[–] apt_install_coffee@lemmy.ml 0 points 8 months ago* (last edited 8 months ago)

No, I'm saying that when people run into strange bugs, sometimes they put together an issue (like the person behind cve-rs), and sometimes they quietly work around it because they're busy.

Seeing as I don't often trawl through issues on the language git, neither really involve notifying me specifically.

My lack of an anecdote does not equate to anecdotal evidence of no issue, just that I haven't met every rust developer.