zlacker

[parent] [thread] 5 comments
1. diarrh+(OP)[view] [source] 2025-12-02 19:49:24
> This is a non sequitur. Both Rust and Zig and any other language has the ability to end in an exception state.

There are degrees to this though. A panic + unwind in Rust is clean and _safe_, thus preferable to segfaults.

Java and Go are another similar example. Only in the latter can races on multi-word data structures lead to "arbitrary memory corruption" [1]. Even in those GC languages there's degrees to memory safety.

1: https://go.dev/ref/mem

replies(2): >>dranne+X >>ignora+yL3
2. dranne+X[view] [source] 2025-12-02 19:53:08
>>diarrh+(OP)
I'll take a small panic and unwind any day over a total burnout crash. Matters in code and life.
3. ignora+yL3[view] [source] 2025-12-03 21:23:25
>>diarrh+(OP)
> A panic + unwind in Rust is clean and _safe_, thus preferable to segfaults

Curious about safety here: Are kernel / cross-thread resources (ex: a mutex/futex/fd) released on unwind (assuming the stack being unwound acquired those)?

replies(1): >>diarrh+AY4
◧◩
4. diarrh+AY4[view] [source] [discussion] 2025-12-04 08:04:47
>>ignora+yL3
Good question. For fds their Drop implementation closes them, yes. Rust Mutexes will be poisoned on panic (not unlocked). Not sure about futexes.
replies(1): >>reacto+T1a
◧◩◪
5. reacto+T1a[view] [source] [discussion] 2025-12-05 17:29:33
>>diarrh+AY4
But if Rust panic’s, the entire process is dead, so everything gets reclaimed on exit by the kernel. Total annihilation.

All modern OS’s behave this way. When your process starts and is assigned an address, you get an area. It can balloon but it starts somewhere. When the process ends, that area is reclaimed.

replies(1): >>diarrh+UOa
◧◩◪◨
6. diarrh+UOa[view] [source] [discussion] 2025-12-05 21:18:49
>>reacto+T1a
The OS is my GC. It's why I segfault liberally.
[go to top]