From fd7e64b0a1ee69ddf608ed0f5ad4867f0f5277d8 Mon Sep 17 00:00:00 2001 From: Kurt Kanzenbach Date: Thu, 28 Feb 2019 11:10:23 +0100 Subject: app/debugging: add address sanitizer example The address sanitizer is a useful tool for debugging lots of memory related bugs such as heap/stack overflows, user after frees and much more. Signed-off-by: Kurt Kanzenbach --- .../debugging-tools/pres_debugging-tools_en.tex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application-devel/debugging-tools/pres_debugging-tools_en.tex b/application-devel/debugging-tools/pres_debugging-tools_en.tex index 7fc8501..ed34c3b 100644 --- a/application-devel/debugging-tools/pres_debugging-tools_en.tex +++ b/application-devel/debugging-tools/pres_debugging-tools_en.tex @@ -615,4 +615,26 @@ $ valgrind --leak-check=full ./array_access \end{verbatim} \end{frame} +\begin{frame}[fragile]{AddressSanitizer} +\begin{verbatim} +$ gcc -o array_access -fsanitize=address array_access.c +$ ./array_access +================================================================= +==5623==ERROR: AddressSanitizer: heap-buffer-overflow +READ of size 4 at 0x60400000dff8 thread T0 + #0 0x56525f56eabf in main + #1 0x7fa413d042e0 in __libc_start_main + #2 0x56525f56e949 in _start + +0x60400000dff8 is located 0 bytes to the right of 40-byte region +allocated by thread T0 here: + #0 0x7fa414144ed0 in calloc + #1 0x56525f56ea66 in main + #2 0x7fa413d042e0 in __libc_start_main + +SUMMARY: AddressSanitizer: heap-buffer-overflow in main +[...] +\end{verbatim} +\end{frame} + \input{tailpres} -- cgit v1.2.3