top | item 46387954

(no title)

K0nserv | 2 months ago

Changes to multi-word pointers can cause UB due to race conditions in Go because only changes at the word level are atomic.

See: https://blog.stalkr.net/2015/04/golang-data-races-to-break-m...

discuss

order

lomase|2 months ago

Does Rust not have race conditions?

tekne|2 months ago

One of Rust's core guarantees is that a race condition in safe code will never cause UB. It might return a nondeterministic result, but that result will be safe and well-typed (for example, if it's a Vec, it will be a valid Vec that will behave as expected and, once you have a unique reference, is guaranteed not to change out from under you).

Dylan16807|2 months ago

When talking about the kind that lead to torn memory writes, no it doesn't have those. To share between threads you need to go through atomics or mutexes or other protection methods.

steveklabnik|2 months ago

Rust prevents data races, but not race conditions.