Skip to content
He Liu edited this page Jun 28, 2022 · 9 revisions

Valgrind

Compilation

cmake -S ${HOME}/src/foundationdb -B ${HOME}/build_output -D USE_CCACHE=ON -D USE_WERROR=ON -D USE_VALGRIND=ON -D RocksDB_ROOT=/opt/rocksdb-6.27.3 -G Ninja && ninja -C ${HOME}/build_output -j 80 fdbserver

CC=clang CXX=clang++ LD=lld cmake -S ${HOME}/src/foundationdb -B ${HOME}/cbuild_output -D USE_VALGRIND=ON -D USE_CCACHE=ON -D USE_LD=LLD -D USE_WERROR=ON -D RocksDB_ROOT=/opt/rocksdb-6.27.3 -D USE_LIBCXX=1 -G Ninja && ninja -C ${HOME}/cbuild_output -j 84

Memory Check

valgrind --track-origins=yes ${HOME}/build_output/bin/fdbserver -r simulation --crash --logsize 1024MB -f ./foundationdb/tests/fast/ConfigureLocked.toml -s 93093841 -b on

Setting the environment variable FDB_VALGRIND_PRECISE will make valgrind slower but more precise with how it tracks Arena's and FastAlloc.

FDB_VALGRIND_PRECISE=1 valgrind --track-origins=yes ./cbuild_output/bin/fdbdecode -r file:///root/backup-1970-01-01-00-01-19.684900/ --hex_prefix "\\x15\\x08\\x18\\x0bF\\x7f\\x2d\\x17\\x15\\x20\\x0f\\x00"

ASAN

For a heap-use-after-free and not use-of-uninitialized-memory error, ASAN can be better than Valgrind.

cmake -S ${HOME}/src/foundationdb -B ${HOME}/asan_build_output -D USE_CCACHE=ON -D USE_WERROR=ON -D USE_ASAN=ON -D RocksDB_ROOT=/opt/rocksdb-6.27.3 -G Ninja && ninja -C ${HOME}/asan_build_output -j 80 fdbserver

ASAN_SYMBOLIZER_PATH=/usr/local/bin/llvm-symbolizer ./asan_build_output/bin/fdbdecode -r file:///root/backup-1970-01-01-00-01-19.684900/ --hex_prefix "\\x15\\x08\\x18\\x0bF\\x7f\\x2d\\x17\\x15\\x20\\x0f\\x00"