this post was submitted on 12 Apr 2024
37 points (81.4% liked)

Open Source

30549 readers
439 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 5 years ago
MODERATORS
 

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

you are viewing a single comment's thread
view the rest of the comments
[–] radiant_bloom@lemm.ee 37 points 5 months ago* (last edited 5 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 ?

[–] BlueEther@no.lastname.nz 26 points 5 months ago* (last edited 5 months ago) (2 children)

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

[edit: spelling]

[–] velox_vulnus@lemmy.ml 32 points 5 months ago (1 children)

UNIX - Everything is a file

Rust - Everything is a memory

[–] devraza@lemmy.ml 2 points 5 months ago

I guess vpr -x would be memory-safe that way then. ;)

[–] devraza@lemmy.ml 7 points 5 months ago* (last edited 5 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.

[–] Deckweiss@lemmy.world 41 points 5 months ago* (last edited 5 months ago) (1 children)

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

[–] merthyr1831@lemmy.world 2 points 5 months ago

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

[–] steeznson@lemmy.world 4 points 5 months ago* (last edited 5 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.