this post was submitted on 12 Apr 2024
1 points (66.7% liked)

Open Source

28952 readers
346 users here now

All about open source! Feel free to ask questions, and share news, and interesting stuff!

Useful Links

Rules

Related Communities

Community icon from opensource.org, but we are not affiliated with them.

founded 4 years ago
MODERATORS
 

"Anything that can be written in Rust will eventually be written in Rust"

top 15 comments
sorted by: hot top controversial new old
[–] [email protected] 3 points 2 months ago* (last edited 2 months ago) (3 children)

Someone has to explain how rm, which doesn’t allocate any memory (as far as I can tell), isn’t memory safe ?

[–] [email protected] 1 points 2 months ago* (last edited 2 months ago)

In GNU coreutils the implementation of rm doesn't allocate memory however I believe alternative implementations do.

Here's an example from the OpenBSD source code - https://github.com/openbsd/src/blob/222e275fb89ffb67abe0726dee2b107220092dc3/bin/rm/rm.c#L335

Presumably other *BSDs use something similar? Didn't check out FreeBSD or anything.

Edit: So I suppose if you are using a BSD-type system (maybe including macOS?), and memory safety was important to you (to the point of extreme paranoia), then you might want to look into this rust project. Or just use the GNU implementation.

[–] [email protected] 0 points 2 months ago* (last edited 2 months ago) (1 children)

If I cant remember what dir I'm in, then rm is mot very memory safe is it?

[edit: spelling]

[–] [email protected] 2 points 2 months ago (1 children)

UNIX - Everything is a file

Rust - Everything is a memory

[–] [email protected] 0 points 2 months ago* (last edited 2 months ago) (1 children)

I don't know whether rm is memory-safe or not, but vpr is. By 'memory-safe alternative' I meant that this alternative is memory-safe, but not that rm isn't.

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago) (1 children)

Reminds me of when they started printing "vegan" and "gluten free" on water bottles.

[–] [email protected] 2 points 2 months ago

ive heard they've even started putting halal water in my taps!

[–] [email protected] 2 points 2 months ago (1 children)

To think that something i used to completely nuke my homeserver one time can be written in 112 lines of rust. thats the power of linux right there

[–] [email protected] 1 points 2 months ago (1 children)

Well, I’m not sure how many lines of C rm is written in but I think that rm being only around 4kb (iirc) is something to consider.

But still, storage probably matters least in this day and age. Oh, and…

something I used to completely nuke my home server

If I’m reading this right, then I hope you had backups ready :)

[–] [email protected] 1 points 2 months ago

Lol thankfully i stopped before it ate any important info, but now I finally have all of that vital stuff being backed up to a hetzner storage box weekly now :)

[–] [email protected] 1 points 2 months ago (1 children)

Can you share what would be a concrete example of the risk taken by running a RM program with a memory leak or dangling pointers? I fail to see, by my own ignorance, the benefit of memory safety everywhere. But I do enjoy the rust rewrites of shell tools because of the ergonomics, speed, and new functionalities. I'm asking because the first thing you mentioned as a benefit was memory safety.

[–] [email protected] 1 points 2 months ago

Unfortunately, I don’t remember the source so we may need to go digging. But I recall reading that something like 1/3 of all bugs are related to memory safety. And those bugs translate to things like buffer overflow and privilege escalation attacks.

The proclaimed advantage is that by making the entirety of Rust memory safe, that entire class of bugs simply won’t exist for projects written in Rust. When they do happen, the bugs will be addressed by the language rather than many thousands of downstream projects. It should be an enormous gain in development performance for the world.

I think the idea makes sense. Time will tell us how well that works.

[–] [email protected] -1 points 2 months ago (1 children)
[–] [email protected] -1 points 2 months ago

Nah, no way. :)