procxx / kepka

Unofficial Telegram Desktop messaging app
https://procxx.github.io
Other
114 stars 29 forks source link

Memory leaks detected by LSan #58

Closed Randl closed 5 years ago

Randl commented 6 years ago

If we run Kepka under ASan/LSan we get some leaks

==26577==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 6656 byte(s) in 26 object(s) allocated from:
    #0 0x5bfd80 in __interceptor_malloc (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5bfd80)
    #1 0x7fb4af3e2099  (/usr/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1d099)

Direct leak of 144 byte(s) in 2 object(s) allocated from:
    #0 0x5f8330 in operator new(unsigned long) (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5f8330)
    #1 0x2602683 in internal::getImage(QPixmap const&, QByteArray) /home/vista/dev/tdesktop/Telegram/SourceFiles/ui/images.cpp:1213:9
    #2 0x187b037 in ImagePtr::ImagePtr(QPixmap const&, QByteArray) /home/vista/dev/tdesktop/Telegram/SourceFiles/ui/images.h:514:62
    #3 0x2c3accf in PhotoData::makeReplyPreview() /home/vista/dev/tdesktop/Telegram/SourceFiles/structs.cpp:1225:19
    #4 0x1890bb9 in HistoryPhoto::replyPreview() /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_media_types.cpp:657:16
    #5 0x195a9e8 in HistoryMessageReply::paint(Painter&, HistoryItem const*, int, int, int, base::flags<HistoryMessageReply::PaintFlag>) const /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_message.cpp:507:53
    #6 0x18d35f6 in HistorySticker::draw(Painter&, QRect const&, TextSelection, long long) const /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_media_types.cpp:2761:12
    #7 0x197c745 in HistoryMessage::draw(Painter&, QRect, TextSelection, long long) const /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_message.cpp:1720:11
    #8 0x17d8907 in HistoryInner::paintEvent(QPaintEvent*) /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_inner_widget.cpp:479:12
    #9 0x7fb4be040dc7 in QWidget::event(QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x194dc7)

Direct leak of 144 byte(s) in 2 object(s) allocated from:
    #0 0x5f8330 in operator new(unsigned long) (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5f8330)
    #1 0x2602463 in internal::getImage(QByteArray const&, QByteArray) /home/vista/dev/tdesktop/Telegram/SourceFiles/ui/images.cpp:1209:9
    #2 0x12878c7 in ImagePtr::ImagePtr(QByteArray const&, QByteArray) /home/vista/dev/tdesktop/Telegram/SourceFiles/ui/images.h:510:85
    #3 0x14375ca in DocumentData::checkSticker() /home/vista/dev/tdesktop/Telegram/SourceFiles/structs.h:1293:14
    #4 0x18d1615 in HistorySticker::draw(Painter&, QRect const&, TextSelection, long long) const /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_media_types.cpp:2697:9
    #5 0x197c745 in HistoryMessage::draw(Painter&, QRect, TextSelection, long long) const /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_message.cpp:1720:11
    #6 0x17d8907 in HistoryInner::paintEvent(QPaintEvent*) /home/vista/dev/tdesktop/Telegram/SourceFiles/history/history_inner_widget.cpp:479:12
    #7 0x7fb4be040dc7 in QWidget::event(QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x194dc7)

Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x5bfd80 in __interceptor_malloc (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5bfd80)
    #1 0x7fb4bad83e57 in CRYPTO_malloc (/lib/x86_64-linux-gnu/libcrypto.so.1.0.0+0x62e57)

Direct leak of 45 byte(s) in 9 object(s) allocated from:
    #0 0x5bfd80 in __interceptor_malloc (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5bfd80)
    #1 0x7fb4af3da61d in FcFreeTypeQueryFace (/usr/lib/x86_64-linux-gnu/libfontconfig.so.1+0x1561d)

Direct leak of 36 byte(s) in 1 object(s) allocated from:
    #0 0x5bfd80 in __interceptor_malloc (/home/vista/dev/tdesktop/cmake-build-debug/Telegram/Telegram+0x5bfd80)
    #1 0x7fb4ae09ae2b  (/usr/lib/x86_64-linux-gnu/libxcb.so.1+0xde2b)
Randl commented 6 years ago

Those appear to be the most obvious places to start checks with

https://github.com/procxx/kepka/blob/6ffc8d3905447a788ef139bd41ecc20f3c5797f2/Telegram/SourceFiles/history/history_message.cpp#L507 https://github.com/procxx/kepka/blob/6ffc8d3905447a788ef139bd41ecc20f3c5797f2/Telegram/SourceFiles/structs.h#L1293

ghost commented 6 years ago

Leaks reported by LSan after ~3 hours of regular usage.

Some information you may find useful:

lsan_log_3_cleaned.txt

Randl commented 5 years ago

I believe this got fixed. Feel free to reopen if needed. cc @ghost @Hexawolf @leha-bot