diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ea0fc8f3..86dedbc11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ add_gcc_compiler_cxxflags("-fno-exceptions -fno-rtti") add_gcc_compiler_cxxflags("-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual") add_gcc_compiler_cflags("-Wchar-subscripts -Wwrite-strings") if(WITH_ASAN) - add_gcc_compiler_flags("-fsanitize=address") + add_gcc_compiler_flags("-fsanitize=address -DWITH_ASAN") endif() string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) diff --git a/src/main.cpp b/src/main.cpp index 0618cefae..2563c843b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,6 +28,10 @@ #include "gui/MainWindow.h" #include "gui/MessageBox.h" +#ifdef WITH_ASAN +#include +#endif + #ifdef QT_STATIC #include @@ -130,6 +134,14 @@ int main(int argc, char** argv) } } } - - return app.exec(); + + int exitCode = app.exec(); + +#ifdef WITH_ASAN + // do leak check here to prevent massive tail of end-of-process leak errors from third-party libraries + __lsan_do_leak_check(); + __lsan_disable(); +#endif + + return exitCode; }