To this experienced multi-threaded developer the example code looks naive, and so there is no wonder it failed.
Furthermore, the amazement that the crash-dumper or debugger can lie to you (especially in a multi-threaded application) is laughable. Anyone who has ever tried to debug a SEGV crash-dump knows that what gets written to the crash-dump (aka 'core') file is little more than a hint at what was going on in the process address space at the time of the crash. Multi-threaded crash-dumps are similarly unreliable for similar reasons.
Why do I get the impression that nobody knows how to code any more ?