Closed dh0well closed 4 years ago
Unfortunately, it is not safe to use smart pointers (or other objects with non-trivial destructors) for globals; see, for example, https://isocpp.org/wiki/faq/ctors#construct-on-first-use-v2 for details. That's why Google's C++ style guide mandates the kind of controlled leaking https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables you observe in the crashpad project (which adheres to that style guide).
The only way this line can actually leak resources is if the calling program initialises crashpad multiple times in the same process, e.g., by calling CrashpadClient::StartHandler()
or CrashpadClient::SetHandlerIPCPipe
repeatedly. That would be a programmer error and there are bigger issues in such a situations than a mere resource leak.
"Controlled leaking" I've never heard of such a thing in my 30+ years of development. !
None of our released apps gets through testing with leaks identified by the compiler. I can't believe this is acceptable.. I guess you get what you pay for.
Through the use of the Microsoft CRT memory leak detection mechanism, I was seeing a report in our application with this announcement:
I tracked down the potential source of the leak and it would appear to be this object: https://github.com/backtrace-labs/crashpad/blob/6c9ef3e8b0cb2f7facd00ad9b786fc493139d16f/client/crashpad_client_win.cc#L554