Crash: std::clamp assertion failure in MTP::SessionPrivate::onSentSome
Steps to reproduce
- Open telegram
- Wait some time (from 3-5 minutes to 2-3 hours)
- Crash
Expected behaviour
App is not crashing
Actual behaviour
App crash sometime
Operating system
Arch linux
Version of Telegram Desktop
6.6.4
Installation source
Other (unofficial) source (arch package)
Crash ID
N/a
Logs
I don't think i need logs, so here backtrace (captured by gdb with debug symbols):
[Thread 0x7fffa81e36c0 (LWP 224416) exited]
[Thread 0x7fffa89e46c0 (LWP 224415) exited]
/usr/include/c++/15.2.1/bits/stl_algo.h:3638: constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = long long unsigned int]: Assertion '!(__hi < __lo)' failed.
Thread 102 "MTP Download Se" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb69ff6c0 (LWP 223893)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44 return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1 0x00007ffff0189af3 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89
#2 0x00007ffff012f1a0 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff01165fe in __GI_abort () at abort.c:77
#4 0x00007ffff049a41f in std::__glibcxx_assert_fail (file=file@entry=0x55555bf21cd0 "/usr/include/c++/15.2.1/bits/stl_algo.h", line=line@entry=3638,
function=function@entry=0x55555c007490 "constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = long long unsigned int]",
condition=condition@entry=0x55555becb9bc "!(__hi < __lo)") at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/assert_fail.cc:41
#5 0x0000555555cd2ece in std::clamp<unsigned long long> (__val=<synthetic pointer>: <optimized out>, __lo=<synthetic pointer>: <optimized out>, __hi=<optimized out>)
at /usr/include/c++/15.2.1/bits/stl_algo.h:3638
#6 MTP::details::SessionPrivate::onSentSome (this=0x55556d086e00, size=256) at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/mtproto/session_private.cpp:1140
#7 MTP::details::SessionPrivate::sendSecureRequest (this=0x55556d086e00, request=..., needAnyResponse=true)
at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/mtproto/session_private.cpp:2698
#8 MTP::details::SessionPrivate::tryToSend (this=<optimized out>) at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/mtproto/session_private.cpp:985
#9 0x00005555579611e2 in std::function<void()>::operator() (this=<optimized out>, this=<optimized out>) at /usr/include/c++/15.2.1/bits/std_function.h:593
#10 base::unique_function<void()>::operator() (this=<optimized out>, this=<optimized out>)
at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/lib_base/base/unique_function.h:127
#11 base::InvokeQueuedEvent::invoke (this=0x55556b4e2420) at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/lib_base/base/invoke_queued.h:29
#12 Core::Sandbox::notifyOrInvoke (this=<optimized out>, receiver=<optimized out>, e=0x55556b4e2420)
at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/core/sandbox.cpp:541
#13 Core::Sandbox::notifyOrInvoke (this=0x7fffffffd490, receiver=0x55556d086e00, e=0x55556b4e2420)
at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/core/sandbox.cpp:539
#14 Core::Sandbox::notify (this=0x7fffffffd490, receiver=0x55556d086e00, e=0x55556b4e2420) at /usr/src/debug/telegram-desktop/tdesktop-6.6.4-full/Telegram/SourceFiles/core/sandbox.cpp:549
#15 0x00007ffff096bf48 in QCoreApplication::notifyInternal2 (receiver=0x55556d086e00, event=event@entry=0x55556b4e2420)
at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1109
#16 0x00007ffff096c320 in QCoreApplication::sendEvent (receiver=<optimized out>, event=0x55556b4e2420) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1549
#17 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x55556680e720) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1904
#18 0x00007ffff0c51e78 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1757
#19 postEventSourceDispatch (s=0x555566ab5a60) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:246
#20 0x00007ffff0706f4d in g_main_dispatch (context=0x555566eec0a0) at ../glib/glib/gmain.c:3565
#21 0x00007ffff0708617 in g_main_context_dispatch_unlocked (context=0x555566eec0a0) at ../glib/glib/gmain.c:4425
#22 g_main_context_iterate_unlocked (context=context@entry=0x555566eec0a0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4490
#23 0x00007ffff0708825 in g_main_context_iteration (context=0x555566eec0a0, may_block=1) at ../glib/glib/gmain.c:4556
#24 0x00007ffff0c4fcb2 in QEventDispatcherGlib::processEvents (this=0x55556318a930, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:399
#25 0x00007ffff0976cf6 in QEventLoop::processEvents (this=0x7fffb69fd430, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventloop.cpp:104
#26 QEventLoop::exec (this=0x7fffb69fd430, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventloop.cpp:186
#27 0x00007ffff0a9277e in QThread::exec (this=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread.cpp:672
#28 0x00007ffff0b31c7a in operator() (__closure=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:448
#29 (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::<lambda()> > (t=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:373
#30 QThreadPrivate::start (arg=0x555566b02870) at /usr/src/debug/qt6-base/qtbase/src/corelib/thread/qthread_unix.cpp:422
#31 0x00007ffff018797a in start_thread (arg=<optimized out>) at pthread_create.c:454
#32 0x00007ffff020b2bc in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Maybe related to #30479
plz enable beta, restart telegram and send crash id on next start and post id here.
@Aokromes Do i really need to? I think trace shows, that problem here https://github.com/telegramdesktop/tdesktop/blob/master/Telegram/SourceFiles/mtproto/session_private.cpp#L1140
Static binary from official website
The trace indeed looks good but this doesn't look right then? No way you can get debug symbols of official build.
Sorry, forgot to change it, package from main arch repo, that's there i got debug symbols (debuginfod.archlinux.org)
plz try downloading official static (non-flakpak, non-snap, non-linux distribution package) version from https://desktop.telegram.org
Issue is clearly in logic and data being passed to std::clamp, i do not see why it matters whether the package is official or unofficial if crash is caused by application logic
Just in case this is helpful, the guaranteed crash happens when you insert 2 paragraphs into a message (2 consecutive Enter or Shift+Enter presses)
/opt/rh/gcc-toolset-15/root/usr/include/c++/15/bits/stl_algo.h:3638: constexpr const _Tp& std::clamp(const _Tp&, const _Tp&, const _Tp&) [with _Tp = int]: Assertion '!(__hi < __lo)' failed.
v 6.7.1
(official binary)
@z22sh I don't think it relates to this issue, problem here was in mproto, create new issue and describe it there
@z22sh I don't think it relates to this issue, problem here was in mproto, create new issue and describe it there
Actually right after I posted this, an update was pushed within 24 hrs that completely solved the issue