From 61aa47da906566bc08397280ce7d31f4adbe1403 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 20 Oct 2020 10:38:22 +0200 Subject: [PATCH] Add memcheck/asan/ubsan to readme --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 78970a5fb..6d4f7af85 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,25 @@ sudo cp *.a /usr/lib To run the tests you must target `run_tests` with make: `make run_tests` +Using AddressSanitizer + UndefinedBehaviourSanitizer or Valgrind's Memcheck +--------------------------------------------------------------------------- +ASan+UBSan and Memcheck are useful to find code problems more easily. Please use them to test your changes if you can. + +For ASan+UBSan compile with: +```bash +CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" cmake -DCMAKE_BUILD_TYPE=Debug . +make +``` +and run with: +```bash +UBSAN_OPTIONS=log_path=./SAN:print_stacktrace=1:halt_on_errors=0 ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 ./DDNet +``` + +Check the SAN.\* files afterwards. This finds more problems than memcheck, runs faster, but requires a modern GCC/Clang compiler. + +For valgrind's memcheck compile a normal Debug build and run with: `valgrind --tool=memcheck ./DDNet` +Expect a large slow down. + Building on Windows with Visual Studio --------------------------------------