this post was submitted on 18 Dec 2025
-12 points (44.7% liked)

Programmer Humor

27965 readers
1154 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 2 years ago
MODERATORS
 
top 11 comments
sorted by: hot top controversial new old
[–] MotoAsh@piefed.social 44 points 4 days ago* (last edited 4 days ago) (2 children)

Wait, is rust supposed to have intrinsic race condition protection? I thought its big feature was figuring out freeing memory for the dev instead of relying on runtime solutions or manual instructions... If it's not supposed to magically fix possible race conditions, I don't know how this issue is the language's fault.

[–] tyler@programming.dev 81 points 4 days ago (1 children)

It’s not. It’s literally code in an unsafe block. The OP is either trolling or actually ignorant.

[–] FishFace@piefed.social 5 points 3 days ago (1 children)

It is, in large part. The rules on ownership and borrowing mean that it is not supposed to be possible to change memory that something else can be concurrently reading from. That means you are forced to obtain references through protective mechanisms, which should protect from race conditions.

All of that can go out of the window if you use unsafe.

[–] MotoAsh@piefed.social 6 points 3 days ago (2 children)

Note how the ticket cited is in an unsafe block, because it uses the OS scheduler, not its own. It is not Rust's fault.

[–] anton@lemmy.blahaj.zone 4 points 3 days ago

Rust doesn't have a scheduler.
The issue is the false assumption, that the remove operation can safely be done without taking a lock. This can be done in some specific data structures using atomic operations, but here the solution was to just take the lock. The same thing could have happened in a C code base but without the unsafe block indicating where to look for the bug.

[–] FishFace@piefed.social 3 points 3 days ago

Yeah, I'm not saying it's rust's fault. Restricting this to unsafe makes it a lot easier to reason about where such problems can occur.

I just don't think anyone should give the impression that rust's memory safety is not about race conditions.

[–] BassTurd@lemmy.world 38 points 4 days ago

Bad code is bad code. We'll see more of this as rust is implemented into core software.

[–] flamingo_pinyata@sopuli.xyz 6 points 4 days ago
[–] technocrit@lemmy.dbzer0.com 6 points 3 days ago

The point is weak but I'm upvoting for the meme usage.