td icon indicating copy to clipboard operation
td copied to clipboard

tdlib fails to compile with -fsanitize=leak

Open stintel opened this issue 3 years ago • 3 comments

The workaround suggested in #1733 does not work.

==170==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5328 byte(s) in 111 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x556e9dc13d33 in tree_alloc /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:73

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x556e9dc13981 in new_tree_node_var_value /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:977
    #2 0x556e9dc13981 in tree_insert_var_value /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:977

Direct leak of 22 byte(s) in 2 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x7f9cbc0944aa in __GI___strdup /var/tmp/portage/sys-libs/glibc-2.35-r8/work/glibc-2.35/string/strdup.c:42

Indirect leak of 62928 byte(s) in 1311 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x556e9dc13d33 in tree_alloc /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:73

Indirect leak of 10488 byte(s) in 945 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x556e9dc13dd4 in tree_add_child /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:81

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f9cbc201d7d in __interceptor_malloc /var/tmp/portage/sys-devel/gcc-11.3.0/work/gcc-11.3.0/libsanitizer/lsan/lsan_interceptors.cpp:56
    #1 0x556e9dc13981 in new_tree_node_var_value /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:977
    #2 0x556e9dc13981 in tree_insert_var_value /var/tmp/portage/net-libs/tdlib-1.7.9/work/td-7d41d9eaa58a6e0927806283252dc9e74eda5512/td/generate/tl-parser/tl-parser.c:977

tdlib-leaksanitizer.txt

stintel avatar Sep 04 '22 17:09 stintel

This isn't an issue. There are no reasons to detect memory leaks during compilation.

levlam avatar Sep 04 '22 18:09 levlam

I'm trying to debug crashes in Bitlbee that started occurring after I started using tdlib-purple. This is what lead me here. If these are false positives it would be nice if there's a way to silence them.

stintel avatar Sep 04 '22 19:09 stintel

We usually just disable leak detection during build phase:

export ASAN_OPTIONS=detect_leaks=0
cmake --build . --target install
unset ASAN_OPTIONS

levlam avatar Sep 04 '22 20:09 levlam