Is this a data race?

Well, it's obviously meaningful in the senses that it's a coherent definition, it's perfectly unambiguous when something is or is not a data race according to that definition (assuming we're already clear on what "read", "write", "thread", etc mean), and it's been proven implementable and optimizeable in practice.

IMO, this is just a case of us humans having intuitions that will never match any precise definition (and I do mean "us"; I certainly share the intuition that it "doesn't feel right"). Racing on "the same value" is merely the most trivial of the special cases that we are inclined to believe "should" be a "benign" data race. But even if we (and LLVM and all of the CPUs) actually endorsed and made well-defined that special case in Rust's (and their) official semantics, next up would be things like "racing on x += 1 can't possibly make x smaller, right?". You have to draw the line somewhere. AFAIK making "same value races" well-defined has no significant practical benefit, and would be hellish for CPUs/compilers to detect, thus hurting everyone's runtime and compile times, so it's outside the line.

3 Likes