Curiously Recurring C++ Bugs at Facebook
summary
Facebook C++ history shows concrete failure modes: using map's square‑bracket inserts missing keys and silently returns zero; folly's findWithDefault variants led to dangling references to temporaries and AddressSanitizer with fsanitize=address finds dozens of such bugs; shared_ptr separates object and shared_ptr control block (refcount) so unsynchronized reads/writes of the pointer corrupt state; unnamed RAII guards that shadow mutex members compile and leave mutexes unlocked (detectable with Wshadow or a clang‑tidy check). Tools and library changes, not platitudes, stop these bugs.
AI-written summary · about
chapters (14)
- 0:00Introduction and context
- 2:12Why these bugs matter
- 3:34Audience perspectives on bugs
- 4:35Square bracket operator pitfalls
- 7:07Map operator square bracket trap
- 12:22Mitigating map operator issues
- 17:20The volatile keyword debate
- 20:09Is shared_ptr thread-safe?
- 28:34Shared_ptr lifetime bugs
- 29:17RAII lock guard shadowing
- 39:39Mitigating RAII shadowing
- 42:08Tools and teaching for prevention
- 44:24Address Sanitizer impact
- 45:08Q&A on excluded bugs
related talks
01h 01mWill Your Code Survive the Attack of the Zombie Pointers?
51mMemory Model: Get your shared data under control
01h 01mGeneric Locking in C++
55m“A lock-free concurrency toolkit for deferred reclamation and optimistic speculation"
55mWhat Can C++ Learn About Thread Safety From Other Languages?
01h 08mThinking Outside the Synchronisation Quadrant
34mExploiting Race Conditions Using the Scheduler
53m“The Importance of Being const"
