# HG changeset patch # User František Kučera # Date 1537789622 -7200 # Node ID 0e791c64f38b00484f39c4e16b3725d4266feafe # Parent ba16fce7ef20ecf493320b752fe7da5b0f7117cd add ASan AddressSanitizer to detect memory leaks diff -r ba16fce7ef20 -r 0e791c64f38b nbproject/configurations.xml --- a/nbproject/configurations.xml Mon Sep 24 13:37:30 2018 +0200 +++ b/nbproject/configurations.xml Mon Sep 24 13:47:02 2018 +0200 @@ -67,8 +67,7 @@ false - + @@ -80,7 +79,6 @@ build/Debug/src/relpipe-out-chart - src build/Debug/src diff -r ba16fce7ef20 -r 0e791c64f38b src/CMakeLists.txt --- a/src/CMakeLists.txt Mon Sep 24 13:37:30 2018 +0200 +++ b/src/CMakeLists.txt Mon Sep 24 13:47:02 2018 +0200 @@ -1,1 +1,6 @@ +# Add ASan AddressSanitizer +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") +set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") +# From ASan wiki: "To get nicer stack traces in error messages add -fno-omit-frame-pointer." + add_executable (relpipe-out-chart relpipe-out-chart.cpp) diff -r ba16fce7ef20 -r 0e791c64f38b src/relpipe-out-chart.cpp --- a/src/relpipe-out-chart.cpp Mon Sep 24 13:37:30 2018 +0200 +++ b/src/relpipe-out-chart.cpp Mon Sep 24 13:47:02 2018 +0200 @@ -2,5 +2,6 @@ int main(int argc, char**argv) { std::cout << "TODO: relpipe-out-chart..." << std::endl; + // char * x = new char[1000]; // simulate a memory leak and test that ASan is working return 0; }