Commit d2364be6 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

logging: suppress ASAN warnings about leaking the LoggerDB singleton

Summary:
During program destruction we destroy registered log handlers (to allow them to
flush state if desired).  However we intentionally leak the LoggerDB object
itself and the LogCategory objects it contains, so it will still be safe if
static destruction code that runs later still tries to log messages.

However, when run with `ASAN_OPTIONS` set to `detect_leaks=1` ASAN complains
about the fact that we leak the LoggerDB singleton.

This changes the code to store the LoggerDB address in a static variable, to
prevent ASAN from complaining that we leak it.

Reviewed By: yfeldblum

Differential Revision: D6920772

fbshipit-source-id: 62f6837053ba4a538a89b4b61f9b1c722f253d33
parent 2518ee52
...@@ -93,7 +93,11 @@ class LoggerDBSingleton { ...@@ -93,7 +93,11 @@ class LoggerDBSingleton {
// hold resources that should be cleaned up. This also ensures that the // hold resources that should be cleaned up. This also ensures that the
// LogHandlers flush all outstanding messages before we exit. // LogHandlers flush all outstanding messages before we exit.
db_->cleanupHandlers(); db_->cleanupHandlers();
db_.release();
// Store the released pointer in a static variable just to prevent ASAN
// from complaining that we are leaking data.
static LoggerDB* db = db_.release();
(void)db;
} }
LoggerDB& getDB() const { LoggerDB& getDB() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment