DEV Community

Discussion on: Address Sanitizer not detect leaks in struct`s field array

Collapse
ac000 profile image
Andrew Clayton

Hmm, works here

$ gcc -Wall -pedantic -Wno-long-long -g -std=c99 -fsanitize=address code.c
Enter fullscreen mode Exit fullscreen mode
$ ./a.out

=================================================================
==14659==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2500 byte(s) in 1 object(s) allocated from:
    #0 0x7f1a6ab5c3cf in __interceptor_malloc (/lib64/libasan.so.6+0xab3cf)
    #1 0x401205 in S_create /tmp/code.c:23
    #2 0x4012fc in main /tmp/code.c:39
    #3 0x7f1a6a90e1e1 in __libc_start_main ../csu/libc-start.c:314

SUMMARY: AddressSanitizer: 2500 byte(s) leaked in 1 allocation(s).
Enter fullscreen mode Exit fullscreen mode

That was under Fedora 33 with gcc version 10.2.1 20201125 (Red Hat 10.2.1-9) (GCC) and libasan 10.2.1 (F33 package).