Testing RIOT


I have followed the recent advancements on debugging the network stack and wanted to suggest some additional testing tools. GCC and Clang both offer the address-, thread- and leak-sanitizer [1]. Have you considered including those in the uint tests? They modify the resulting executable and provide runtime checks to find several bugs.

The downside is that the tests run slower and not all of them are available for arm architectures. I just tried to add the flags to the `thread_basic` test and ran into loads of "undefined reference to `__asan_xxxx” errors when compiling for native. Since I am not familiar with the whole RIOT toolchain, are there any modifications that may prevent linking to the standard libs?

Before I invest more time in this: have you considered using these tools before? Is there interest in having this for the unit test (on native)?

Regards Raphael

[1] https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer


Hi Michael,

we are using asan with gcc for a c++ project. I also compiled the example in the wiki and that works as well.

The solution to the undefined reference is as obvious as it sounds, simple link the asan library. Normally it is linked by default, I guess. To compile a RIOT native example additional CFLAGS and LINKFLAGS are required.

CFLAGS +=  -fsanitize=address -O1 -fno-omit-frame-pointer -g
LINKFLAGS += -lasan

However, as soon as the program is started, a segfault occurs. Would be boring otherwise, right?

(gdb) bt
#0  0x0804d2ee in _native_syscall_enter () at /home/noir/RIOT/cpu/native/syscalls.c:102
#1  0x0804d711 in calloc (nmemb=1, size=20) at /home/noir/RIOT/cpu/native/syscalls.c:171
#2  0xf7ab4394 in ?? () from /lib32/libdl.so.2
#3  0xf7ab3e49 in dlsym () from /lib32/libdl.so.2
#4  0xf7b1eeea in ?? () from /usr/lib32/libasan.so.1
#5  0xf7af9475 in ?? () from /usr/lib32/libasan.so.1
#6  0xf7b0feb6 in __asan_init_v3 () from /usr/lib32/libasan.so.1
#7  0x0804a1d7 in _GLOBAL__sub_I_00099_1__native_rng_seed () at /home/noir/RIOT/cpu/native/startup.c:386
#8  0x0804ff2b in __libc_csu_init ()
#9  0xf79136b6 in __libc_start_main () from /lib32/libc.so.6
#10 0x08048ee1 in _start ()

Greetings Raphael