telegramdesktop / tdesktop

Telegram Desktop messaging app
https://desktop.telegram.org/
Other
26.23k stars 5.2k forks source link

In Linux Telegram crashes almost every time a file is downloaded #27702

Closed Jeronimo17 closed 6 months ago

Jeronimo17 commented 7 months ago

Steps to reproduce

Save a video or a file with the option to ask for the folder to save activated (I don't know if it is relevant).

Expected behaviour

No program crash

Actual behaviour

The program stops responding

Operating system

Linux Mint 21.3 x86_64 Xfce 4.18

Version of Telegram Desktop

4.16.1

Installation source

Static binary from official website

Crash ID

Crash ID: b7b85c02-006d-49cc-d1193eb0-f858eefa

Logs

No response

Aokromes commented 7 months ago

plz enable beta, restart telegram and send crash id on next start and post id here.

Jeronimo17 commented 7 months ago

Crash ID: b7b85c02-006d-49cc-d1193eb0-f858eefa

I was waiting for the Crash ID to come up, sometimes the program stops responding, I send killall Telegram and when I reopen it it does not give Crash ID.

ilya-fedin commented 7 months ago

That is likely not the answer you would like to hear... But it looks like Mint 21.3 has a memory corruption bug in some of the system libraries which trigger random crashes in the allocator. It's not clear what to do with that.

Jeronimo17 commented 7 months ago

I don't know, but it only happens to me with Telegram in 2 PCs, and I use linux for everything.

Jeronimo17 commented 6 months ago

Crash ID: 51165e09-04bb-4e25-35b3c58b-03c9b4d0

pfactum commented 6 months ago

Do you experience this while attaching/uploading (instead of downloading) a file to a chat as well?

Aokromes commented 6 months ago

try on 4.16.5

pfactum commented 6 months ago

v4.16.5 is affected for me as well.

john-preston commented 6 months ago

@pfactum Try 4.15.6 😂

john-preston commented 6 months ago

@pfactum Sorry, I (1) mistyped 4.16.6 as 4.15.6 and (2) didn't yet release 4.16.6, which will be available today, but it won't contain any crash fixes. 4.16.5 should have been working without crashes since we rolled back scudo allocator and replaced it with jemalloc, like before.

Can you provide Crash ID from 4.16.5?

pfactum commented 6 months ago

How do I get Crash ID while using Arch package please?

(I'm not sure TG crashes even, it just closes silently, no segfault trace anywhere, no nothing)

ilya-fedin commented 6 months ago

@pfactum it is available only for static binary users. Distro package users are supposed either to test the issues they have on the official builds or report to distro bugtrackers thus delegating the work of verifying the issue to the distro maintainer.

pfactum commented 6 months ago

Could be a distro-specific issue then as the static build from GitHub works.

I've reported this here: https://gitlab.archlinux.org/archlinux/packaging/packages/telegram-desktop/-/issues/10

pfactum commented 6 months ago

Distro guys obviously kicked me out stating it had nothing to do with distro.

Instead, they pointed to https://bugs.kde.org/show_bug.cgi?id=483439, which also points to https://bugs.kde.org/show_bug.cgi?id=471941.

Reading those bugs it seems TG has to be adopted to Qt6 behaviour.

pfactum commented 6 months ago
diff '--color=auto' -Naur tdesktop-4.16.5-full~/Telegram/SourceFiles/core/launcher.cpp tdesktop-4.16.5-full/Telegram/SourceFiles/core/launcher.cpp
--- tdesktop-4.16.5-full~/Telegram/SourceFiles/core/launcher.cpp    2024-04-09 16:19:44.250407858 +0200
+++ tdesktop-4.16.5-full/Telegram/SourceFiles/core/launcher.cpp 2024-04-09 16:20:15.407135589 +0200
@@ -319,6 +319,8 @@

    QApplication::setApplicationName(u"TelegramDesktop"_q);

+   QCoreApplication::setQuitLockEnabled(false);
+
 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    // fallback session management is useless for tdesktop since it doesn't have
    // any "are you sure you want to close this window?" dialogs

This fixed my issue, it seems.

ilya-fedin commented 6 months ago

This doesn't look like a right fix given that tdesktop is not using QEventLoopLocker?

pfactum commented 6 months ago

Suspiciously similar Reddit thread: https://www.reddit.com/r/kde/comments/1bvjsk2/telegram_desktop_crashing_in_kde/

UPD: Solved. For anyone that may stumble upon this thread - the solution for KDE Plasma 6 is to turn on the tray bar icon (sic!). If it is disabled, you get what is described below.

Hi everyone. KDE Plasma 6.0.3, Arch, Wayland.

When I try to open some file in telegram-desktop (installed via pacman, not flatpak), the KDE file dialogue appears (the correct one, with previews etc), but whenever I choose a file to upload or just close the dialogue, the whole app crashes. No relevant errors if started in terminal too.

Happens only in KDE, no extra env variables (like QT_QPA... etc) is used in the system.

However, if I run:

QT_QPA_PLATFORMTHEME=xdgdesktopportal telegram-desktop

in terminal, it works great, no crashes. 
pfactum commented 6 months ago

BTW, I indeed don't enable systray icon.

ilya-fedin commented 6 months ago

What I want to say is, KDE affecting the global state of Qt even though the application itself doesn't use the API in question. Why should application do a change completely unrelated to its code? It really sounds like this should be done by the code using the functionality in question, i.e. the KDE code. This is a typical example of how Qt injecting third-party code (this time from KDE) into application does a bad thing.

wolfseifert commented 6 months ago

I already commented this a couple of weeks ago https://bugs.kde.org/show_bug.cgi?id=483439#c14 and also found a solution on the kde-side that works for me https://bugs.kde.org/show_bug.cgi?id=483439#c16 but nothing happened. Maybe we need a "rise in pressure".

The problem only occurs if a KFileWidget is used, what may happen even if your application just uses a QFileDialog in code. If you run it with QT_QPA_PLATFORMTHEME=xdgdesktopportal telegram-desktop then the original qt dialog (which looks a bit different) is used and everything is fine. You can also change this by setting LD_LIBRARY_PATH to a qt-online-installed qt version. So depending on your runtime environment (plain qt vs "enhanced" kde) your application works or not.

ilya-fedin commented 6 months ago

I think this is offtopic here... This report is about memory corruption crash when opening the file dialog (according to the initial reporter's crash id).

kushagra-xo commented 6 months ago

Suspiciously similar Reddit thread: https://www.reddit.com/r/kde/comments/1bvjsk2/telegram_desktop_crashing_in_kde/

UPD: Solved. For anyone that may stumble upon this thread - the solution for KDE Plasma 6 is to turn on the tray bar icon (sic!). If it is disabled, you get what is described below.

Hi everyone. KDE Plasma 6.0.3, Arch, Wayland.

When I try to open some file in telegram-desktop (installed via pacman, not flatpak), the KDE file dialogue appears (the correct one, with previews etc), but whenever I choose a file to upload or just close the dialogue, the whole app crashes. No relevant errors if started in terminal too.

Happens only in KDE, no extra env variables (like QT_QPA... etc) is used in the system.

However, if I run:

QT_QPA_PLATFORMTHEME=xdgdesktopportal telegram-desktop

in terminal, it works great, no crashes. 

even this solution wont work for me

kushagra-xo commented 6 months ago

i just updated and i cannot reproduce this with version: 4.16.7-1 (i assume it's a fix from kde side)

Jeronimo17 commented 6 months ago

It doesn't seem to be happening anymore 4.16.8