Memory leak under Clang sanitizer

14 views
Skip to first unread message

mira....@gmail.com

unread,
Oct 2, 2014, 9:35:11 AM10/2/14
to eiffelst...@googlegroups.com
Hi all,

I think I have found memory leak in Eiffel library, I guess there is some missing disposal or bad logic in class MANAGED_POINTER

Unfortunatelly I do not know how to correct it :-(

Mira

=================================================================================================

Issue: Bug
Severity: High
Reproducibility: Always

Setup: Linux Ubuntu 13.xx, Clang 3.5 or trunk, EiffelStudio 14.05.5220

mf@mf-LIFEBOOK-S762:~$ export CC="clang -g -fsanitize=address"
mf@mf-LIFEBOOK-S762:~$ export CXX="clang++ -g -fsanitize=address"
mf@mf-LIFEBOOK-S762:~$ estudio

then I build and run Example/base/calculator, the console list follows. It does not matter which example or program is tested, memory leak appears on the same place


*********************************
Calculator in reverse Polish form
*********************************
Allowable operations are:
    'a': Enter operand onto stack.
    '+': Add top two numbers on the stack
    '-': Subtract top two numbers on the stack.
    '*': Multiply top two numbers on the stack.
    '/': Divide top two numbers on the stack.
    '0': Empty the stack.
    'q': Quit.
    '?': Help.
Enter a number, followed by <return>:
q

Accumulator = 4.59163e-41

Next operation?
=================================================================
==8702==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 257 byte(s) in 1 object(s) allocated from:
    #0 0x496929 in calloc /home/mf/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:56
    #1 0x9cc4285 in F151_3568 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./ma151.c:191:8
    #2 0xa4726ea in F126_1843 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C4/./c_126.c:183:57
    #3 0x9c4270d in F164_4227 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi164.c:11474:57
    #4 0x85e061c in F230_6588 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C7/./co230.c:1642:67
    #5 0x85da528 in F230_6586 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C7/./co230.c:1481:40
    #6 0xb1af1ae in F14_184 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./st14.c:3544:40
    #7 0x4d1ab7 in F863_6978 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./st863.c:315:40
    #8 0x6201d1 in F862_6971 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:484:40
    #9 0x6123ae in F862_6967 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:239:41
    #10 0x60e21c in F862_6957 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:103:40
    #11 0x8bc88e in emain /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/einit.c:22:42
    #12 0x8bf0d9 in main /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/emain.c:37:2
    #13 0x7fe4f5ca4de4 in __libc_start_main /build/buildd/eglibc-2.17/csu/libc-start.c:260

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x496929 in calloc /home/mf/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:56
    #1 0x9cc4285 in F151_3568 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./ma151.c:191:8
    #2 0x9fc1fe6 in F162_4023 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi162.c:1411:59
    #3 0x9c2ac74 in F164_4219 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi164.c:11073:100
    #4 0x9a41e7e in F164_4066 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi164.c:387:57
    #5 0x85a5250 in F230_6569 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C7/./co230.c:256:57
    #6 0xb114b24 in F14_115 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./st14.c:219:57
    #7 0xb14f499 in F14_140 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./st14.c:1437:66
    #8 0xbab8f31 in F1_24 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./an1.c:1622:40
    #9 0x60c1d6 in F862_6957 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:83:66
    #10 0x8bc88e in emain /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/einit.c:22:42
    #11 0x8bf0d9 in main /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/emain.c:37:2
    #12 0x7fe4f5ca4de4 in __libc_start_main /build/buildd/eglibc-2.17/csu/libc-start.c:260

Direct leak of 6 byte(s) in 1 object(s) allocated from:
    #0 0x496929 in calloc /home/mf/src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:56
    #1 0x9cc4285 in F151_3568 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./ma151.c:191:8
    #2 0x9fc1fe6 in F162_4023 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi162.c:1411:59
    #3 0x9c2ac74 in F164_4219 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi164.c:11073:100
    #4 0x9a41e7e in F164_4066 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C5/./fi164.c:387:57
    #5 0x85a0680 in F230_6568 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C7/./co230.c:151:57
    #6 0xb110c44 in F14_114 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./st14.c:151:57
    #7 0xb199d8b in F14_175 /home/mf/.es/eiffel_user_files/14.05/precomp/spec/linux-x86-64/EIFGENs/base-safe/W_code/C1/./st14.c:3099:66
    #8 0x5f0570 in F871_6992 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./qu871.c:114:40
    #9 0x4c9e7c in F863_6976 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./st863.c:184:40
    #10 0x61de6e in F862_6970 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:428:40
    #11 0x612269 in F862_6967 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:237:41
    #12 0x60e21c in F862_6957 /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/C1/./ca862.c:103:40
    #13 0x8bc88e in emain /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/einit.c:22:42
    #14 0x8bf0d9 in main /home/mf/Eiffel_14.05/examples/base/calculator/EIFGENs/classic/W_code/E1/emain.c:37:2
    #15 0x7fe4f5ca4de4 in __libc_start_main /build/buildd/eglibc-2.17/csu/libc-start.c:260

SUMMARY: AddressSanitizer: 270 byte(s) leaked in 3 allocation(s).



Emmanuel Stapf

unread,
Oct 2, 2014, 9:52:41 AM10/2/14
to eiffelst...@googlegroups.com

Thanks for bringing this to us. I haven’t tried to replicate your results but I think that it has nothing to do with bad logic in MANAGED_POINTER. It is just that we make no guarantee to collect all objects upon termination of a program. So it is possible that some MANAGED_POINTER (which are onces in this case I believe) are simply not collected.

 

Regards,

Manu

 

--
For more messaging options, visit this group at http://forum.eiffel.com.
Information on the Eiffelstudio project: http://dev.eiffel.com.

mira....@gmail.com

unread,
Oct 2, 2014, 10:24:48 AM10/2/14
to eiffelst...@googlegroups.com, ma...@eiffel.com
The attachment contains listings from bootstrap attempt with sanitizer, file e_comp2 has at the end list of leaks and there are hundreds.

I do not know the internals, I still think if class calloced the memory then it is responsible for freeing memory at the end of life independent of number of occurencies

Regards
Mira

Dne čtvrtek, 2. října 2014 15:52:41 UTC+2 Emmanuel Stapf napsal(a):
Clang_address.zip
Reply all
Reply to author
Forward
0 new messages