You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying Leak sanitizer with Asan using clang version : 14.0.0-1ubuntu1 test 1:
__attribute__((noinline))
void my_leak(){
int **p=(int **)malloc(7*sizeof(int *));
p[2] = (int*)malloc (17*sizeof(int ));
}
int main() {
my_leak();
return 0;
}
when I compiled : clang -g -m64 -fsanitize=address memory-leak.c -o memory-leak.clang.m64
when I run it : ./memory-leak.clang.m64 , 2 leaks was detected as expected:
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x55696842a14e in __interceptor_malloc ((mypath)/memory-leak.clang.m64+0xa114e) (BuildId: c3a46fdb8fa5c44dc8fec15e9bcc65f245a4af1f) #1 0x556968464eb1 in my_leak (mypath)/memory-leak.c:139:19 #2 0x556968464f23 in main (mypath)/memory-leak.c:150:3 #3 0x7f565ca67d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
Indirect leak of 68 byte(s) in 1 object(s) allocated from:
#0 0x55696842a14e in __interceptor_malloc ((mypath)/memory-leak.clang.m64+0xa114e) (BuildId: c3a46fdb8fa5c44dc8fec15e9bcc65f245a4af1f) #1 0x556968464ebf in my_leak (mypath)/memory-leak.c:140:16 #2 0x556968464f23 in main (mypath)/memory-leak.c:150:3 #3 0x7f565ca67d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: 124 byte(s) leaked in 2 allocation(s).
but when I'm compiling with the same flags the same leak with wrapper function and run it ,no leak was detected: test 2:
Moreover when I trying to force the detection with __lsan_do_leak_check() sometimes it help and sometimes it's not test 3: 2 leaks was detected as expected
I'm trying Leak sanitizer with Asan using clang version : 14.0.0-1ubuntu1
test 1:
when I compiled : clang -g -m64 -fsanitize=address memory-leak.c -o memory-leak.clang.m64
when I run it : ./memory-leak.clang.m64 , 2 leaks was detected as expected:
=================================================================
==59354==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x55696842a14e in __interceptor_malloc ((mypath)/memory-leak.clang.m64+0xa114e) (BuildId: c3a46fdb8fa5c44dc8fec15e9bcc65f245a4af1f)
#1 0x556968464eb1 in my_leak (mypath)/memory-leak.c:139:19
#2 0x556968464f23 in main (mypath)/memory-leak.c:150:3
#3 0x7f565ca67d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
Indirect leak of 68 byte(s) in 1 object(s) allocated from:
#0 0x55696842a14e in __interceptor_malloc ((mypath)/memory-leak.clang.m64+0xa114e) (BuildId: c3a46fdb8fa5c44dc8fec15e9bcc65f245a4af1f)
#1 0x556968464ebf in my_leak (mypath)/memory-leak.c:140:16
#2 0x556968464f23 in main (mypath)/memory-leak.c:150:3
#3 0x7f565ca67d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: 124 byte(s) leaked in 2 allocation(s).
but when I'm compiling with the same flags the same leak with wrapper function and run it ,no leak was detected:
test 2:
why this is happening?
Moreover when I trying to force the detection with __lsan_do_leak_check() sometimes it help and sometimes it's not
test 3: 2 leaks was detected as expected
so if leaks exist and Lsan know it, why sometime the leak was reported and sometimes no?
additionally when compiling with m32 flag:
test 4: 1 leak was detected as expected
test 5 : no leak was detected....
test 5: 1 leak was detected by force
test 6: no leak was detected....
The text was updated successfully, but these errors were encountered: