To avoid this insidious bug:
std::lock_guard<std::mutex>(m); // guard is immediately thrown away
versus the correct std::lock_guard<std::mutex> g(m); // hold mutex til end of scope