CppCon 2017: Louis Brandy “Curiously Recurring C++ Bugs at Facebook”
Channel:CppCon · Length:52:01 · Published:2017-11-02 · Views:158419
Summary
Louis Brandy presents the most common and infamous recurring C++ bugs seen in Facebook's huge codebase, including shared_ptr data races and operator[] pitfalls. He explains the surprising complexity behind seemingly simple code.
Why HN recommends it
HN recommends it as a must-watch catalogue of C++ footguns, often cited in debates about Rust and C++ safety.
is a great video that covers a lot of good stuff in particular this usability bug. It's worth watching in its entirety. — HN, 2020
C, C++, Rust, Go & systems languages · Security & hacking
Subtitles (excerpt)
All right, it's 1:30, it's time. Thank you everyone for coming back from lunch through rain. I'm here today to talk about bugs. My name is Louis Brandy, I work at Facebook. I have brought to you a selection of bugs. I want to give a tiny bit of context here before, just to give you some background on why it is I have opinions on recurring bug patterns. One of the questions I get a lot, I've been getting since I've come to CppCon, is does Facebook actually have a lot of C++? Like, don't you guys just use PHP? It turns out we have an enormous amount of C++. We've actually had enormous amounts from effectively the beginning. Facebook infra has been built on C++ effectively from the beginning. It's the second most used language behind our PHP hack codebase, and our PHP hack codebase runs on something called HHVM which is a C++ process, which sort of lives in our repository. There's other languages and infra at Facebook. Python, notably, is definitely second, Java, third, and then everyone's favorite language, et cetera. There's actually quite a long tail of languages. Let's see Clicker. So our team is effectively the core C++ group at Facebook. There are two groups in this group, two logical sections.
On Hacker News
No. Sorry for being unclear. [1] is a great video that covers a lot of good stuff in particular this usability bug. It's worth watching in its entirety. If you don't want to sit through the video, here's the broken code in question: void Obj::update() noexcept { unique_lock<mutex>(m_mutex); do_the_mutation(); } "unique_lock<mutex>(m_mutex);" has no effect, but you might mistakenly think that this… — wyldfire, 2020-01
Unfortunately, operator[] on std::vector is inherently unsafe. You can potentially try to ban it (using at() instead), but that has its own problems. There’s a great talk by Louis Brandy called “Curiously Recurring C++ Bugs at Facebook” [0] that covers this really well, along with std::map’s operator[] and some more tricky bugs. An interesting question to ask if you try to watch that talk is: How… — ddulaney, 2025-04
There are many differences when it comes to safety: - Like you said, Rust doesn't let you data race on the contents of an Arc. - Rust also doesn't let you data race on the Arc itself (i.e. repointing a global Arc without synchronization). This is Bug #5 in this great talk: [VIDEO] - Rust also doesn't let you retain a reference to the contents of an Arc longer than you retain the Arc. This is the … — oconnor663, 2023-01
I'm a big fan of Scott Meyer's Effective C++ . It's a little dated now, but it was the most valuable book I'd ever read on the language. Louis Brandy's Curiously Recurring Bugs at Facebook presentation from CppCon17 has somewhat of the same feeling, though it only covers a few bugs: [VIDEO] — slavik81, 2021-06
The point of the article isn't that single-threaded non-atomic shared pointers are unfeasible in C++, it is that their usage is too dangerous. The fact that it wasn't included in the standard library for this reason is an argument for this. The fact that even `shared_ptr` has thread-safety footguns, one of which made it to the famous C++ talk, “Curiously Recurring C++ Bugs at Facebook”[1], is ano… — dureuill, 2024-02
Related videos
- Wild Tricks for Greenscreen in Blender · IanHubert · 9:50
- Blender Motion Tracking - Room Transformation! · IanHubert · 7:57
- CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++” · CppCon · 1:47:44
- But what is the Riemann zeta function? Visualizing analytic continuation · 3Blue1Brown · 20:28
- CppCon 2015: Greg Law " Give me 15 minutes & I'll change your view of GDB" · CppCon · 14:46
- CppCon 2014: Chandler Carruth "Efficiency with Algorithms, Performance with Data Structures" · CppCon · 1:13:41
- How wildlife trade is linked to coronavirus · Vox · 8:48
- How Does SHA-256 Work? · learnmeabitcoin · 22:59
- RustConf 2018 - Closing Keynote - Using Rust For Game Development by Catherine West · Rust Programming Language · 42:29
- Я позвонил своему убийце. Он признался · Алексей Навальный · 33:21
- Call Between Alexey Navalny and FSB Officer Konstantin Kudryavtsev [English Subtitles] · Bellingcat · 49:15
- Mechanical Computer (All Parts) - Basic Mechanisms In Fire Control Computers · Excelsior10000 · 41:53
- CppCon 2015: Andrei Alexandrescu “std::allocator...” · CppCon · 1:12:27
- Lexical Scanning in Go - Rob Pike · GoogleFOSSSydney · 51:17
- Behind the Scenes of iOS Security · Black Hat · 51:31
- Why Electronic Voting Is Still A Bad Idea · Tom Scott · 12:00