Another week and another customer shared how messed up their test suites were because of parallel programming. So where are we going wrong?
First, it is natural to feel confused and disoriented when a failure "escapes" into the wild. In other words, when a bug is not caught by our test suites it is natural to DEMAND an plan to correct this failure!
Second, it is common to fall back on a simple belief: an "escape" means we need MORE tests.
This is where parallelism trips us up.
Multithreading is hard. Implementation of synchronization primitives is even harder. And most advanced synchronization primitives which exploit relaxed memory models are brain damaging. So don't rely on memory barriers for synchronization. Now you will think "Ah, you are one of those folks, who constantly saying to us - don't do this, don't do that, it's too difficult, it's too dangerous, anyway you will fail". Nope, I am not. I am saying exactly the opposite - do rely on memory barriers for synchronization...