C++ Error Reporting: The Best It Can Do
Description
This meme uses the popular 'Best I can do is' format featuring Rick Harrison from the TV show 'Pawn Stars'. The top panel sets up the scenario with text: 'Me: Hey can you show me what is the err- C++:'. The main image shows Rick Harrison looking skeptical, with his catchphrase 'Best I can do is' at the bottom. Overlaid on the image is a small window from a desktop environment, likely a Linux distribution, titled 'test'. The window displays a classic C++ error message: 'Segmentation fault (core dumped)', followed by 'Process returned 139 (0x8B)' and 'Press ENTER to continue.'. The humor lies in personifying C++ as a shrewd pawn shop owner who offers the least helpful information possible when a developer asks for error details. A segmentation fault is a notoriously vague error for anyone working with C++ or other low-level languages, indicating a memory access violation without pointing to the cause, making it a universally painful and relatable experience for senior developers
Comments
7Comment deleted
Modern languages give you a stack trace, a detailed error, and a link to a probable solution. C++ gives you a segfault, which is the programming equivalent of your car making a weird noise and then just exploding
C++ is the only colleague who, when asked for a status update, hands you a 2-gig core file, says “best I can do,” and reminds you the line numbers were optimized out three builds ago
After 20 years in the industry, I've learned that C++ error messages follow the Pawn Stars negotiation model: you ask for a helpful stack trace with line numbers, and the best it can do is dump core and leave you to divine the issue from assembly code and a cryptic exit code that basically means 'something touched memory it shouldn't have' - which in a million-line codebase is about as helpful as being told 'the bug is somewhere in the code.'
C++ developers know that 'Segmentation fault (core dumped)' is just the compiler's way of saying 'I've narrowed down your bug to somewhere between line 1 and EOF - you're welcome.' It's the programming equivalent of a doctor saying 'the problem is somewhere in your body' after a full examination. At least Rust would've caught this at compile time and written you a dissertation about why your code is unsafe, complete with helpful suggestions and a link to the documentation. But here we are, staring at exit code 139, firing up GDB for the third time today, and wondering if that pointer arithmetic from 2 hours ago was really as clever as we thought
Asking C++ for a readable error is how you learn that 139 = 128 + SIGSEGV - enjoy spelunking a 2GB core in gdb because you forgot -g and ASan
Me: can you show me the error? C++: best I can do is a core dump - bring gdb, ASan, and the compiler flags for that one .so someone built in 2016
C++ error reporting: a full postmortem dump before you've even autopsied the bug