blueprint-freespeech / ricochet-refresh

Anonymous peer-to-peer instant messaging
https://www.ricochetrefresh.net
Other
223 stars 27 forks source link

Crash when closing a chat window immediately after sending a message #150

Closed wfr closed 2 years ago

wfr commented 2 years ago

When the user closes a chat window immediately after sending a message, the GUI crashes.

Version: b0a274c07f0e8afd7b6727e3fe8428e1f9ad5249 (main)

Steps to reproduce:

ASSERT: "row >= 0" in file /home/user/ricochet-refresh/src/libtego_ui/shims/ConversationModel.cpp, line 684
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737244727552) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737244727552) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737244727552, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff491a476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff49007f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff4fd6ba3 in  () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007ffff4fd5ff0 in qt_assert_x(char const*, char const*, char const*, int) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x0000555555a87d7f in shims::ConversationModel::messageAcknowledged(unsigned int, bool) (this=0x604000254b90, messageId=3308863449, accepted=true)
    at /home/user/ricochet-refresh/src/libtego_ui/shims/ConversationModel.cpp:684
#8  0x0000555555a5e575 in operator()() const (__closure=0x602000075610) at /home/user/ricochet-refresh/src/libtego_ui/libtego_callbacks.cpp:442
#9  0x0000555555a66e76 in operator()((anonymous namespace)::run_once_task*) const (__closure=0x0, self=0x61100030a240) at /home/user/ricochet-refresh/src/libtego_ui/libtego_callbacks.cpp:64
#10 0x0000555555a66f19 in _FUN((anonymous namespace)::run_once_task*) () at /home/user/ricochet-refresh/src/libtego_ui/libtego_callbacks.cpp:61
#11 0x0000555555a5a821 in (anonymous namespace)::run_once_task::operator()() (this=0x61100030a240) at /home/user/ricochet-refresh/src/libtego_ui/libtego_callbacks.cpp:83
#12 0x0000555555a5abd3 in (anonymous namespace)::consume_tasks() () at /home/user/ricochet-refresh/src/libtego_ui/libtego_callbacks.cpp:109
#13 0x0000555555a6baf8 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (*)()>::call(void (*&)(), void**)
    (f=@0x603000675b30: 0x555555a5a97e <(anonymous namespace)::consume_tasks()>, arg=0x7fffffffcee0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:146
#14 0x0000555555a6ba2d in QtPrivate::Functor<void (*)(), 0>::call<QtPrivate::List<>, void>(void (*&)(), void*, void**)
    (f=@0x603000675b30: 0x555555a5a97e <(anonymous namespace)::consume_tasks()>, arg=0x7fffffffcee0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:256
#15 0x0000555555a6b9f8 in QtPrivate::QFunctorSlotObject<void (*)(), 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=1, this_=0x603000675b20, r=0x0, a=0x7fffffffcee0, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:443
#16 0x00007ffff523b886 in  () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007ffff522d32f in QObject::event(QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007ffff6c2a713 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff51ffe2a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007ffff52583db in QTimerInfoList::activateTimers() () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007ffff5258cdc in  () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007ffff3f43d1b in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#23 0x00007ffff3f986f8 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007ffff3f413c3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007ffff52590a8 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#26 0x00007ffff51fe74b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007ffff5206ce4 in QCoreApplication::exec() () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x0000555555751b44 in main(int, char**) (argc=1, argv=0x7fffffffdfb8) at /home/user/ricochet-refresh/src/ricochet-refresh/main.cpp:235
wfr commented 2 years ago

Video

wfr commented 2 years ago

ChatWindow.qml:

onClosed: {
    // If not also in combined window mode, clear chat history when closing
    if (!uiSettings.data.combinedChatWindow)
        chatPage.conversationModel.clear()
}

If the above is executed before the sent message is acknowledged, the following assertion is triggered:

ConversationModel.cpp:

void ConversationModel::messageAcknowledged(tego_message_id_t messageId, bool accepted)
{
    auto row = this->indexOfOutgoingMessage(messageId);
    Q_ASSERT(row >= 0);
morganava commented 2 years ago

@wfr thanks for the patch, I'll review and likely merge w/ the next release.

btw: your ricochet-irc project is neat, though I do somewhat question to decision to go through the shims in libtego_ui rather than through the libtego C API directly ^^; ( there is still the hidden qt dependency behind that C API but you know vOv )

wfr commented 2 years ago

btw: your ricochet-irc project is neat, though I do somewhat question to decision to go through the shims in libtego_ui rather than through the libtego C API directly ^^;

Thanks :) It was a good idea of yours to split Ricochet into libtego and the UI, and I concur, the irc fork should use libtego directly. It used to be based on the original Ricochet and the quickest way to forward-port it to R² was to plug into libtego_ui. I will work on it at some point.

( there is still the hidden qt dependency behind that C API but you know vOv )

libtego doesn't have many Qt GUI dependencies; it should be feasible to make it completely headless, e.g. by replacing QRegularExpressionValidator. Should we open a ticket for this endeavor?

morganava commented 2 years ago

I'd be happy to review/merge patches, but my current dev focus (beyond some current grant work) is on redoing the entire libtego backend (see https://github.com/blueprint-freespeech/gosling for the authentication part).

The next backend will be in Rust (with a C FFI) and will not be backwards compatible with the Ricochet-Refresh 3 series.

morganava commented 2 years ago

@wfr: filed https://github.com/blueprint-freespeech/ricochet-refresh/issues/154