6 ms·
If the variables are word-sized, sure. But what if they are larger? Now a race condition between one thread writing and another thread reading or writing a vari
by dodobirdlord 1y ago
If the variables are word-sized, sure. But what if they are larger? Now a race condition between one thread writing and another thread reading or writing a variable is a memory safety issue.
- kazinator 1y agoDon't have such things, if you know what's good for you, or else don't have threads.
- zozbot234 1y ago> Now a race condition between one thread writing and another thread reading or writing a variable is a memory safety issue. No it isn't, because the torn write cannot have arbitrary effects that potentially break the program. It only becomes such if you rely on such a variable to establish an invariant about memory that's broken if a torn write occurs (such as by encoding a ptr+len in it), which is just silly. Don't do that!
- gpderetta 1y ago> which is just silly. Don't do that! tell that to the Go runtime, which relies on slices always being valid and not being able to create invalid ones.