-
Notifications
You must be signed in to change notification settings - Fork 1.3k
FRR with Address Sanitizer
Address Sanitizer is another tool similar to Valgrind to find memory corruption, leaks, buffer overflows etc. See Address Sanitizer Homepage for more details
Pass --enable-address-sanitizer
to ./configure
. You are done.
This is tested with GCC on Ubuntu 16.04, but should work on most other distributions. Make sure to have a recent GCC version to get the latest features for Address Sanitizer
-
./bootstrap.sh
(as normal) -
Define some extra flags for build
export CC=gcc export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" export LD=gcc export LDFLAGS="-g -fsanitize=address -ldl"
-
Run configure with your required options and disable shared images
--enable-shared=no
./configure --enable-shared=no <and your other options>
-
(Newer FRR with clippy - if
lib/clippy.c
exists): Build clippy without Address Sanitizer:make -C lib CFLAGS="-g -O2" LDFLAGS="-g" clippy
-
make
andmake install
as usual -
(Optional) To verify the address sanitizer build, check the binaries with
ldd
and look forlibasan.so
By default, if there are any memory corruption, buffer overflows etc detected, then Address Sanitized will abort the program and output a detailed error to stderr. Memory Leaks will not cause an abort, but will be reported when the
program ends normally. (Hint: Do a kill
or killall
with normal SIGTERM
of the daemons at the end)
Most daemons are designed to run in the background and the output to stderr is lost. To force Address Sanitizer to write to a file instead, start the daemons with extra options:
ASAN_OPTIONS=log_path=/tmp/asan.zebra /usr/local/sbin/zebra -d
(and similar for other daemons)
This will force the output to a file named /tmp/asan.zebra. instead of stderr
For other Options, run any of the daemons [after compiling with address sanitizer] with
ASAN_OPTIONS=help=1 /usr/local/sbin/zebra