I am working on a c module and would like to use GCC's address sanitizer and undefined behaviour sanitizer to verify the quality of my code. I tried to add it in the flags for my module:
Code: Select all
// File: micropython.mk
// [...]
CFLAGS_USERMOD += -fsanitize=address -fsanitize=undefined
LDFLAGS_USERMOD += -fsanitize=address -fsanitize=undefined
Or with more verbose logging:==12703==LeakSanitizer has encountered a fatal error.
==12703==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==12703==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
Are we using ptrace somehow in micropython? Has anyone else managed to build micropython with address sanitizer, or how do you usually look for memory leaks?==12705==AddressSanitizer: failed to intercept 'printf'
==12705==AddressSanitizer: failed to intercept 'snprintf'
==12705==AddressSanitizer: failed to intercept 'vprintf'
==12705==AddressSanitizer: failed to intercept 'vsnprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_printf'
==12705==AddressSanitizer: failed to intercept '__isoc99_sprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_snprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_fprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_vprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_vsprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_vsnprintf'
==12705==AddressSanitizer: failed to intercept '__isoc99_vfprintf'
==12705==AddressSanitizer: libc interceptors initialized
|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem ||
|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap ||
|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow ||
|| `[0x000000000000, 0x00007fff7fff]` || LowMem ||
MemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff
redzone=16
max_redzone=2048
quarantine_size_mb=256M
malloc_context_size=30
SHADOW_SCALE: 3
SHADOW_GRANULARITY: 8
SHADOW_OFFSET: 0x7fff8000
==12705==Installed the sigaction for signal 11
==12705==Installed the sigaction for signal 7
==12705==Installed the sigaction for signal 8
==12705==T0: stack [0x7fffb91d5000,0x7fffb99d5000) size 0x800000; local=0x7fffb99d3304
==12705==LeakSanitizer: Dynamic linker not found. TLS will not be handled correctly.
==12705==AddressSanitizer Init done
<class 'ValueError'> Failed to decode file: Failed to stat file
<class 'ValueError'> Failed to write file: Is a directory
Not a JPEG file: starts with 0x50 0x36
==12706==Could not attach to thread 12705 (errno 1).
==12706==Failed suspending threads.
==12705==LeakSanitizer has encountered a fatal error.
==12705==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==12705==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)