Jeff-Lewis / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

ASan doesn't print stats after an LSan report #334

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
$ cat t.c
#include <stdio.h>
#include <stdlib.h>
int main() {
#ifndef NO_MALLOC
  char *p = malloc(64);
  printf("p: %p\n", p);
#endif
  return 0;
}

$ clang t.c -fsanitize=address -o t -DNO_MALLOC
$ ASAN_OPTIONS=print_stats=1:atexit=1 ./t
AddressSanitizer exit stats:
Stats: 0M malloced (0M for red zones) by 0 calls
...
$ clang t.c -fsanitize=address -o t 
$ ASAN_OPTIONS=print_stats=1:atexit=1 ./t
p: 0x60600000efc0

=================================================================
==19371==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x4a365b in __interceptor_malloc (/usr/local/google/ssd/chrome-git/src/t+0x4a365b)
    #1 0x4c0e89 in main (/usr/local/google/ssd/chrome-git/src/t+0x4c0e89)
    #2 0x7f2e3213178c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

(no stats printed)

Original issue reported on code.google.com by ramosian.glider@gmail.com on 19 Aug 2014 at 2:44

GoogleCodeExporter commented 9 years ago

Original comment by ramosian.glider@gmail.com on 19 Aug 2014 at 2:44

GoogleCodeExporter commented 9 years ago
It doesn't dump coverage either. The whole exit logic is a bit of a mess. I 
think we should keep using __exit() to terminate LSan on error, but call back 
into __asan_atexit() and __sanitizer_cov_dump() first (probably move the latter 
call into the former).

Incidentally, the description for the print_stats flag is incorrect:

"Print various statistics after printing an error message or if atexit=1."

In fact the flag only affects former case. When atexit=1, stats are printed 
unconditionally at exit.

Original comment by earth...@google.com on 25 Aug 2014 at 1:19

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:06