Skip to content

Instantly share code, notes, and snippets.

@jackpoz
Last active December 29, 2018 21:45
Show Gist options
  • Save jackpoz/7c4ad34bbad619596c17 to your computer and use it in GitHub Desktop.
Save jackpoz/7c4ad34bbad619596c17 to your computer and use it in GitHub Desktop.
valgrind/helgrind/ASan
cmake valgrind:
cmake .. -DCMAKE_INSTALL_PREFIX=/home/jackpoz/trinity -DWITH_COREDEBUG=FALSE -DWITH_WARNINGS=TRUE -DCMAKE_BUILD_TYPE=Debug -DNOJEM=TRUE -DSCRIPTS=static -DTOOLS=FALSE -DVALGRIND_INCLUDE_DIR=/home/jackpoz/valgrind/include
cmake valgrind jemalloc:
cmake .. -DCMAKE_INSTALL_PREFIX=/home/jackpoz/trinity -DWITH_COREDEBUG=FALSE -DWITH_WARNINGS=TRUE -DCMAKE_BUILD_TYPE=Debug -DNOJEM=FALSE -DSCRIPTS=static -DTOOLS=FALSE -DVALGRIND_INCLUDE_DIR=/home/jackpoz/valgrind/include
cmake helgrind:
cmake .. -DCMAKE_INSTALL_PREFIX=/home/jackpoz/trinity -DWITH_COREDEBUG=FALSE -DWITH_WARNINGS=TRUE -DCMAKE_BUILD_TYPE=Debug -DNOJEM=TRUE -DSCRIPTS=static -DTOOLS=FALSE -DVALGRIND_INCLUDE_DIR=/home/jackpoz/valgrind/include -DHELGRIND=TRUE
cmake helgrind jemalloc:
cmake .. -DCMAKE_INSTALL_PREFIX=/home/jackpoz/trinity -DWITH_COREDEBUG=FALSE -DWITH_WARNINGS=TRUE -DCMAKE_BUILD_TYPE=Debug -DNOJEM=FALSE -DSCRIPTS=static -DTOOLS=FALSE -DVALGRIND_INCLUDE_DIR=/home/jackpoz/valgrind/include -DHELGRIND=TRUE
cmake ASan
cmake .. -DCMAKE_INSTALL_PREFIX=/home/jackpoz/trinity -DWITH_COREDEBUG=FALSE -DWITH_WARNINGS=TRUE -DCMAKE_BUILD_TYPE=RelWithDebInfo -DNOJEM=TRUE -DSCRIPTS=static -DTOOLS=FALSE -DCMAKE_CXX_FLAGS="-fno-omit-frame-pointer -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope" -DCMAKE_C_FLAGS="-fno-omit-frame-pointer -fsanitize=address -fsanitize-recover=address -fsanitize-address-use-after-scope"
valgrind worldserver:
/home/jackpoz/valgrind/bin/valgrind --tool=memcheck --verbose --freelist-vol=100000000 --log-file=world.`date +%Y%m%d-%H%M%S`.log --num-callers=20 ./worldserver
valgrind worldserver more variable details
/home/jackpoz/valgrind/bin/valgrind --tool=memcheck --verbose --read-var-info=yes --freelist-vol=100000000 --log-file=world.`date +%Y%m%d-%H%M%S`.log --num-callers=20 ./worldserver
valgrind worldserver memory leak check
/home/jackpoz/valgrind/bin/valgrind --tool=memcheck --leak-check=full --verbose --freelist-vol=100000000 --log-file=world.`date +%Y%m%d-%H%M%S`.log --num-callers=20 ./worldserver
valgrind worldserver uninitialized values details
/home/jackpoz/valgrind/bin/valgrind --tool=memcheck --verbose --freelist-vol=100000000 --track-origins=yes --log-file=world.`date +%Y%m%d-%H%M%S`.log --num-callers=20 ./worldserver
helgrind worldserver
/home/jackpoz/valgrind/bin/valgrind --tool=helgrind --verbose --log-file=worldhel%p.log --gen-suppressions=all --suppressions=helgrind.supp ./worldserver
ASan worldserver
ASAN_OPTIONS=halt_on_error=0:verbosity=1:log_path=worldasan:detect_stack_use_after_return=1 LSAN_OPTIONS=verbosity=1:log_threads=1 ./worldserver
@jackpoz
Copy link
Author

jackpoz commented Dec 29, 2017

ToDo: add ASan options:

  • CFLAGS += -fsanitize-address-use-after-scope
  • ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
  • ASAN_OPTIONS=detect_stack_use_after_return=1 for "Stack used after function return", used more memory and slightly slower
  • ASAN_OPTIONS=check_initialization_order=1:strict_init_order=1 for "Check initialization order for global variables" .

Valgrind should still be used for uninitialized values as it's a pain to use MemorySanitizer to do the same check (2 different tools that do 2 different things after all)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment