The production bug that made me care about undefined behavior
Discussions: /r/programming, lobsters.
Years ago, I maintained a big C++ codebase at my day job. This product was the bread winner for the company and offered a public HTTP API for online payments. We are talking billions of euros of processed payments a year.
I was not a seasoned C++ developer yet. I knew about undefined behavior of course, but it was an abstract concept, something only beginners fall into. Oh boy was I wrong.
Please note that I am not and never was a C++ expert, and it's been a few years since I have been writing C++ for a living, so hopefully I got the wording and details right, but please tell me if I did not.
In this article I always say 'struct' when I mean 'struct or class'.
So, one day I receive a bug report. There is this HTTP endpoint that returns a simple response to inform the client that the operation either succeeded or had an error:
{ "error": false, "succeeded": true, }
or
{ "error": true, "succeeded": false, }
... continue reading