Bug 449719 - KDE Connect crashes when opening a message
Summary: KDE Connect crashes when opening a message
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: messaging-application (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: Simon Redman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-06 21:47 UTC by Ray Leon
Modified: 2022-03-06 23:01 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Video of the aforementioned crash. (756.76 KB, video/webm)
2022-02-06 21:47 UTC, Ray Leon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ray Leon 2022-02-06 21:47:54 UTC
Created attachment 146359 [details]
Video of the aforementioned crash.

SUMMARY
When opening a conversation in the KDE Connect messages app, the app segfaults.


STEPS TO REPRODUCE
1. Hook up KDE Connect to your Android phone (I have a Samsung Galaxy S21 running Android 12)
2. Open the KDE Connect SMS app and click on a conversation

OBSERVED RESULT

qrc:/qml/ChatMessage.qml:109: TypeError: Cannot read property 'length' of undefined
qrc:/qml/SendingArea.qml:69:17: QML TextArea: Possible anchor loop detected on fill.

Thread 1 "kdeconnect-sms" received signal SIGSEGV, Segmentation fault.


EXPECTED RESULT
Conversation opens.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux x86_64, with all packages up to date
(available in About System)
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Backtrace (and additional stuff):
> gdb kdeconnect-sms                                                                                        
GNU gdb (GDB) 11.2
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from kdeconnect-sms...
Reading symbols from /usr/lib/debug/usr/bin/kdeconnect-sms.debug...
(gdb) run
Starting program: /usr/bin/kdeconnect-sms 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff0af2640 (LWP 802069)]
[New Thread 0x7ffff02f1640 (LWP 802070)]
[New Thread 0x7fffefaf0640 (LWP 802071)]
[New Thread 0x7fffee11d640 (LWP 802072)]
[New Thread 0x7fffde1f1640 (LWP 802073)]
[New Thread 0x7fffdd9f0640 (LWP 802074)]
[New Thread 0x7fffdd1ef640 (LWP 802075)]
[New Thread 0x7fffdc9ee640 (LWP 802076)]
[New Thread 0x7fffd17d1640 (LWP 802077)]
[New Thread 0x7fffd0fd0640 (LWP 802078)]
[New Thread 0x7fffbbfff640 (LWP 802079)]
qrc:/qml/ConversationList.qml:51: TypeError: Cannot read property 'text' of null
qrc:/qml/ConversationList.qml:267: TypeError: Cannot read property 'text' of null
qrc:/qml/ConversationList.qml:267: TypeError: Cannot read property 'text' of null
qrc:/qml/ConversationList.qml:51: TypeError: Cannot read property 'text' of null
no addresses! "A"
no addresses! "Should I bring anything?"
no addresses! ""
[New Thread 0x7fffbb7fe640 (LWP 802081)]
[New Thread 0x7fffbaffd640 (LWP 802082)]
[New Thread 0x7fffba5fc640 (LWP 802083)]
file:///usr/lib/qt/qml/org/kde/kirigami.2/templates/InlineMessage.qml:261:9: QML ActionToolBar: Binding loop detected for property "atBottom"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_aspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_aspell.so: (libaspell.so.15: cannot open shared object file: No such file or directory)"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so: (libhspell.so.0: cannot open shared object file: No such file or directory)"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_voikko.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_voikko.so: (libvoikko.so.1: cannot open shared object file: No such file or directory)"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_aspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_aspell.so: (libaspell.so.15: cannot open shared object file: No such file or directory)"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so: (libhspell.so.0: cannot open shared object file: No such file or directory)"
kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_voikko.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_voikko.so: (libvoikko.so.1: cannot open shared object file: No such file or directory)"
[New Thread 0x7fffa736a640 (LWP 802085)]
[New Thread 0x7fffa6b69640 (LWP 802086)]
[Thread 0x7fffa736a640 (LWP 802085) exited]
[Thread 0x7fffa6b69640 (LWP 802086) exited]
qrc:/qml/ChatMessage.qml:109: TypeError: Cannot read property 'length' of undefined
qrc:/qml/SendingArea.qml:69:17: QML TextArea: Possible anchor loop detected on fill.

Thread 1 "kdeconnect-sms" received signal SIGSEGV, Segmentation fault.
ConversationModel::createRowFromMessage(ConversationMessage const&, int) [clone .constprop.0] (this=this@entry=0x7fffe8003f20, message=..., pos=0) at /usr/src/debug/kdeconnect-kde-21.12.2/smsapp/conversationmodel.cpp:145
145	   ConversationAddress sender = message.addresses().first();
(gdb)
Comment 1 Ray Leon 2022-02-06 21:49:15 UTC
Actual backtrace: 
Thread 1 "kdeconnect-sms" received signal SIGSEGV, Segmentation fault.
ConversationModel::createRowFromMessage(ConversationMessage const&, int) [clone .constprop.0] (this=this@entry=0x7fffe0003f20, message=..., pos=0) at /usr/src/debug/kdeconnect-kde-21.12.2/smsapp/conversationmodel.cpp:145
145	   ConversationAddress sender = message.addresses().first();
(gdb) backtrace
#0  ConversationModel::createRowFromMessage(ConversationMessage const&, int) [clone .constprop.0] (
    this=this@entry=0x7fffe0003f20, message=..., pos=0)
    at /usr/src/debug/kdeconnect-kde-21.12.2/smsapp/conversationmodel.cpp:145
#1  0x00005555555699f5 in ConversationModel::handleConversationUpdate (msg=..., this=0x7fffe0003f20)
    at /usr/src/debug/kdeconnect-kde-21.12.2/smsapp/conversationmodel.cpp:189
#2  ConversationModel::qt_static_metacall (_o=0x7fffe0003f20, _c=<optimized out>, _id=<optimized out>, 
    _a=0x7fffffffdaf0) at /usr/src/debug/build/smsapp/kdeconnect-sms_autogen/EWIEGA46WW/moc_conversationmodel.cpp:161
#3  0x00007ffff6484ddf in ?? () from /usr/lib/libQt5Core.so.5
#4  0x00007ffff7f6e481 in OrgKdeKdeconnectDeviceConversationsInterface::conversationUpdated (_t1=..., 
    this=<optimized out>) at /usr/src/debug/build/interfaces/conversationsinterface.moc:265
#5  OrgKdeKdeconnectDeviceConversationsInterface::qt_static_metacall (_o=0x5555567a7510, _c=<optimized out>, 
    _id=<optimized out>, _a=0x7fffffffdc40) at /usr/src/debug/build/interfaces/conversationsinterface.moc:138
#6  0x00007ffff7f5b873 in OrgKdeKdeconnectDeviceConversationsInterface::qt_metacall (_a=0x7fffffffdc40, _id=4, 
    _c=QMetaObject::InvokeMetaMethod, this=0x5555567a7510)
    at /usr/src/debug/build/interfaces/conversationsinterface.moc:223
#7  DeviceConversationsDbusInterface::qt_metacall (this=0x5555567a7510, _c=QMetaObject::InvokeMetaMethod, 
    _id=<optimized out>, _a=0x7fffffffdc40)
    at /usr/src/debug/build/interfaces/kdeconnectinterfaces_autogen/EWIEGA46WW/moc_dbusinterfaces.cpp:958
#8  0x00007ffff746afae in ?? () from /usr/lib/libQt5DBus.so.5
#9  0x00007ffff6477e76 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5
#10 0x00007ffff6ec61a6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#11 0x00007ffff645416a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#12 0x00007ffff6454c69 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from /usr/lib/libQt5Core.so.5
#13 0x00007ffff649b548 in ?? () from /usr/lib/libQt5Core.so.5
#14 0x00007ffff4d64f13 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#15 0x00007ffff4dbb0d9 in ?? () from /usr/lib/libglib-2.0.so.0
#16 0x00007ffff4d62485 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#17 0x00007ffff649f44a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/libQt5Core.so.5
#18 0x00007ffff644c44b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#19 0x00007ffff6457b97 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5
#20 0x00005555555603ef in main (argc=<optimized out>, argv=0x7fffffffe218)
    at /usr/src/debug/kdeconnect-kde-21.12.2/smsapp/main.cpp:87
Comment 2 Nathan 2022-02-15 21:22:38 UTC
I have this issue all the time, and right now I need it more than ever as I dropped my phone last weekend which smashed the display. Now KDE Connect is the only way I can access the data on my old phone but because of this major bug I am unable to access the sms conversations. I have noticed that this issue seems to 'build up'. For example if I open a small length conversation, they will display fine but will segfault opening a second. If I open a large one it will immediately segfault
Comment 3 Ray Leon 2022-02-17 04:04:19 UTC
(In reply to Nathan from comment #2)
> I have this issue all the time, and right now I need it more than ever as I
> dropped my phone last weekend which smashed the display. Now KDE Connect is
> the only way I can access the data on my old phone but because of this major
> bug I am unable to access the sms conversations. I have noticed that this
> issue seems to 'build up'. For example if I open a small length
> conversation, they will display fine but will segfault opening a second. If
> I open a large one it will immediately segfault

This mirrors what I've been experiencing
Comment 4 Nathan 2022-03-05 03:40:34 UTC
Looks like no one is even reading these bug reports
Comment 5 Simon Redman 2022-03-05 03:57:33 UTC
(In reply to Nathan from comment #4)
> Looks like no one is even reading these bug reports

I read every bug report which is assigned to me and I'm sorry you get the impression that bug reports don't get read. I have an old house and a taxing job, so I don't have time or energy to act on most of them.

The problem described in this bug looks like it might be pretty simple. In ConversationModel::createRowFromMessage, it seems to be trying to take the .first() of the list of message address and failing, presumably because the list is empty. I don't know why a conversation would exist with no addresses (that's probably the more interesting thing to investigate), but a quick fix would be to just have the app check that there is at least one entry before trying to take the first.

Since I can't reproduce this, it's hard for me to work on, but if someone who can reproduce wants to try I'd be happy to support them.
Comment 6 Ray Leon 2022-03-06 17:28:34 UTC
Thanks, I think that fixed it!
Changing "ConversationAddress sender = message.addresses().first();" in conversationmodel.cpp to 
`
>ConversationAddress sender;
>if (!message.addresses().isEmpty()) {
>        sender = message.addresses().first();
>}
`
seems to prevent the crashing.
I don't really know how to commit the changes though, would you mind doing that?
P.S. how do you
Comment 7 Ray Leon 2022-03-06 17:29:03 UTC
make code blocks?
Comment 8 Bug Janitor Service 2022-03-06 22:50:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/458
Comment 9 Simon Redman 2022-03-06 22:56:22 UTC
Git commit 3ee78eadd7647748ae220402c01a062d3f56b4ef by Simon Redman.
Committed on 06/03/2022 at 22:56.
Pushed by sredman into branch 'master'.

[SMS App] Prevent crash if a conversation doesn't have any messages

## Summary

Fix crash in kdeconnect-sms if a conversation contains a message which has no addresses.

I am not sure why this would happen and there's probably something which should be fixed on the Android side to ensure that every message has addresses, but this is an easy fix to prevent user-reported crashes.

## Test Plan

### Before:
kdeconnect-sms crashes upon selecting a conversation with a message with no addresses

### After:
kdeconnect-sms does not crash

M  +9    -1    smsapp/conversationmodel.cpp

https://invent.kde.org/network/kdeconnect-kde/commit/3ee78eadd7647748ae220402c01a062d3f56b4ef
Comment 10 Simon Redman 2022-03-06 23:01:24 UTC
The commit mentioned above should resolve the issue. I expect you'll see some messages which are missing senders but at least the app won't crash.

(In reply to Ray Leon from comment #7)
> make code blocks?

I don't know if it's possible in the version of Bugzilla we're using. I can see from other Bugzilla documentation that there should be a setting in your user preferences to enable Markdown rendering, but I don't see that option on my account.