Exactly what I see at work. I have a ‘senior’ C++ team lead which I have to explain over and over that for concurrent access of variables in device drivers one needs meticulous locking of shared variables. He was helding the view that when one thread is modifying a variable and another one is only reading it, then it’s no race condition - even if the code crashes. And he still responds with generated code and suggesting names of members that don’t exist.
This would infuriate me to no end. It’s literally the definition of a data race. All data between threads needs to either be accessed through synchronization primitives (mutexes, atomic access, etc) or needs to be immutable. For the most part, this should include fds, though concurrent writes to stderr might be less of an issue (still a good idea to lock/buffer it and stdout though to avoid garbled output).
Exactly what I see at work. I have a ‘senior’ C++ team lead which I have to explain over and over that for concurrent access of variables in device drivers one needs meticulous locking of shared variables. He was helding the view that when one thread is modifying a variable and another one is only reading it, then it’s no race condition - even if the code crashes. And he still responds with generated code and suggesting names of members that don’t exist.
wow, I hate that guy
This would infuriate me to no end. It’s literally the definition of a data race. All data between threads needs to either be accessed through synchronization primitives (mutexes, atomic access, etc) or needs to be immutable. For the most part, this should include fds, though concurrent writes to stderr might be less of an issue (still a good idea to lock/buffer it and stdout though to avoid garbled output).
Exactly.
It’s been so long since I’ve had to worry about this type of race condition, and like you…it infuriates me reading that comment.