Bug 396591

Summary: Kate crashed under Wayland
Product: [Frameworks and Libraries] kwayland Reporter: John Apple II <jappleii>
Component: clientAssignee: Martin Flöser <mgraesslin>
Status: RESOLVED WORKSFORME    
Severity: crash CC: Andreas, bilal.elmas, christoph, kde, meven29, mgraesslin, notuxius, rorus
Priority: NOR Keywords: drkonqi, wayland
Version: 5.49.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: attachment-28379-0.html

Description John Apple II 2018-07-17 07:43:52 UTC
Application: kate (17.12.2)

Qt Version: 5.10.1
Frameworks Version: 5.47.0
Operating System: Linux 4.17.5-200.fc28.x86_64 x86_64
Distribution: "Fedora release 28 (Twenty Eight)"

-- Information about the crash:
- What I was doing when the application crashed:
I have just stared using a Wayland session.  I had opened 2 files from Thunderbird e-mail attachments in Kate and I was viewing them - 1 JSON file and one .sh file.

The crash can be reproduced sometimes.

-- Backtrace:
Application: Kate (kate), signal: Aborted
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7ff5b38b9980 (LWP 25903))]

Thread 3 (Thread 0x7ff59200a700 (LWP 27113)):
[KCrash Handler]
#6  0x00007ff5c0fdef2b in raise () from /lib64/libc.so.6
#7  0x00007ff5c0fc9561 in abort () from /lib64/libc.so.6
#8  0x00007ff5c1d2bea3 in QMessageLogger::fatal(char const*, ...) const () from /lib64/libQt5Core.so.5
#9  0x00007ff5c285dde7 in qt_pixmap_thread_test() () from /lib64/libQt5Gui.so.5
#10 0x00007ff5c285de98 in QPixmap::QPixmap() () from /lib64/libQt5Gui.so.5
#11 0x00007ff5c286b56b in QPixmapIconEngine::read(QDataStream&) () from /lib64/libQt5Gui.so.5
#12 0x00007ff5c286c066 in operator>>(QDataStream&, QIcon&) () from /lib64/libQt5Gui.so.5
#13 0x00007ff5a55a278c in non-virtual thunk to QtConcurrent::RunFunctionTask<QIcon>::run() () from /lib64/libKF5WaylandClient.so.5
#14 0x00007ff5c1d62431 in QThreadPoolThread::run() () from /lib64/libQt5Core.so.5
#15 0x00007ff5c1d6511d in QThreadPrivate::start(void*) () from /lib64/libQt5Core.so.5
#16 0x00007ff5bf08c594 in start_thread () from /lib64/libpthread.so.0
#17 0x00007ff5c10a202f in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7ff5a19cf700 (LWP 25905)):
#0  0x00007ff5b9dee4b8 in g_mutex_unlock () from /lib64/libglib-2.0.so.0
#1  0x00007ff5b9da7b0e in g_main_context_iterate.isra () from /lib64/libglib-2.0.so.0
#2  0x00007ff5b9da7d10 in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#3  0x00007ff5c1f63c2b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#4  0x00007ff5c1f1212b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib64/libQt5Core.so.5
#5  0x00007ff5c1d609c6 in QThread::exec() () from /lib64/libQt5Core.so.5
#6  0x00007ff5c219a299 in QDBusConnectionManager::run() () from /lib64/libQt5DBus.so.5
#7  0x00007ff5c1d6511d in QThreadPrivate::start(void*) () from /lib64/libQt5Core.so.5
#8  0x00007ff5bf08c594 in start_thread () from /lib64/libpthread.so.0
#9  0x00007ff5c10a202f in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7ff5b38b9980 (LWP 25903)):
#0  0x00007ff5bf09252c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007ff5c1d6583b in QWaitCondition::wait(QMutex*, unsigned long) () from /lib64/libQt5Core.so.5
#2  0x00007ff5c1d610ba in QThreadPoolPrivate::waitForDone(int) () from /lib64/libQt5Core.so.5
#3  0x00007ff5c1d61645 in QThreadPool::waitForDone(int) () from /lib64/libQt5Core.so.5
#4  0x00007ff5c1f15749 in QCoreApplication::~QCoreApplication() () from /lib64/libQt5Core.so.5
#5  0x00007ff5c27ee3ed in QGuiApplication::~QGuiApplication() () from /lib64/libQt5Gui.so.5
#6  0x00007ff5c2d408e4 in QApplication::~QApplication() () from /lib64/libQt5Widgets.so.5
#7  0x0000561d041b2a6d in main ()

Reported using DrKonqi
Comment 1 Alexander Mentyu 2018-07-17 12:23:51 UTC
Possibly related bugs - https://bugs.kde.org/show_bug.cgi?id=396239 https://bugs.kde.org/show_bug.cgi?id=392401
Comment 2 Christoph Feck 2018-08-02 22:42:33 UTC
What could make KF5WaylandClient stuff run in a non-gui thread?
Comment 3 Martin Flöser 2018-08-03 15:54:55 UTC
PlasmaWindowManagement interface uses QtConcurrent, but nothing else. Kate shouldn't use that as it's not intended for applications like Kate.
Comment 4 Christoph Cullmann 2018-08-15 21:04:56 UTC
I am not aware that we use such a thing (and even less in a thread).
Is there anything specific to search for if such code slipped in?
Comment 5 Christoph Feck 2018-08-30 23:24:09 UTC
Reassigning to kwayland. In plasmawindowmanagement.cpp, QtConcurrent is indeed used to read QIcon. The QIcon class cannot be used outside the main thread. While most icons just reference a theme using a name, there exists icons that are contructed from QPixmap. Serializing it causes the error here.

A simple workaround is to check if the QIcon has name using QIcon::name(), and if not, refuse to serialize it.
Comment 6 Christoph Feck 2018-08-30 23:33:52 UTC
The proper fix would be to convert between QPixmap and QImage data before going to the "wire". The client could then, after receiving the QImage data, construct a QIcon from it in the main thread.
Comment 7 Christoph Feck 2018-09-05 00:49:17 UTC
*** Bug 397533 has been marked as a duplicate of this bug. ***
Comment 8 Christoph Feck 2018-09-05 00:49:57 UTC
*** Bug 393569 has been marked as a duplicate of this bug. ***
Comment 9 Christoph Feck 2018-09-05 00:50:08 UTC
*** Bug 386089 has been marked as a duplicate of this bug. ***
Comment 10 Christoph Feck 2018-12-27 20:27:21 UTC
*** Bug 402133 has been marked as a duplicate of this bug. ***
Comment 11 Christoph Feck 2018-12-27 20:27:27 UTC
*** Bug 401710 has been marked as a duplicate of this bug. ***
Comment 12 Méven Car 2019-10-17 07:55:29 UTC
Is this still reproducible ?
It is not (or at least I never had this crash) on my Plasma 5.17, Qt 5.12 system.

Those bugs were reported a few versions ago, Wayland support in Plasma and Qt has improved since.
Comment 13 John Apple II 2019-10-17 08:02:52 UTC
(In reply to Méven Car from comment #12)
> Is this still reproducible ?
> It is not (or at least I never had this crash) on my Plasma 5.17, Qt 5.12
> system.
> 
> Those bugs were reported a few versions ago, Wayland support in Plasma and
> Qt has improved since.

I've switched back to using KDE under X for about a year now - there are a couple of critical features for me that Wayland hasn't supported, yet, and this hasn't happened to me since.
Comment 14 Méven Car 2019-10-17 08:53:10 UTC
(In reply to John Apple II from comment #13)
> I've switched back to using KDE under X for about a year now - there are a
> couple of critical features for me that Wayland hasn't supported, yet, and
> this hasn't happened to me since.

Do you mean it hasn't happened in Wayland ?

I will probably close this if you don't or can't or won't test and reproduce it.
Comment 15 John Apple II 2019-10-17 10:04:05 UTC
Created attachment 123270 [details]
attachment-28379-0.html

On Thu, 17 Oct 2019, 19:53 Méven Car, <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=396591
>
> --- Comment #14 from Méven Car <meven29@gmail.com> ---
> (In reply to John Apple II from comment #13)
> > I've switched back to using KDE under X for about a year now - there are
> a
> > couple of critical features for me that Wayland hasn't supported, yet,
> and
> > this hasn't happened to me since.
>
> Do you mean it hasn't happened in Wayland ?
>
> I will probably close this if you don't or can't or won't test and
> reproduce
> it.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 16 John Apple II 2019-10-17 12:50:13 UTC
Sorry, accidentally replied to the last message via e-mail.  No, currently I don't have a way to test this anymore to reproduce.  Kate hasn't crashed on me in a very long time, and I've run that scenario that caused it multiple times under X.

Close it - if I can get it to occur again, I'll re-raise the bug.
Comment 17 Méven Car 2019-10-17 13:20:04 UTC
Could not reproduce anymore.
Comment 18 Christoph Feck 2019-10-17 13:21:38 UTC
Comment 5 and comment 6 are still valid; the code didn't change.
Comment 19 David Edmundson 2020-04-07 21:51:25 UTC
I don't know why Kate was ever going in this code. That was something else that was clearly wrong.

As for QIcon and threads, the retrieval of an icon is fine. 
We get it in a thread, no-one else can be using it at the same time.

The datastream serialisation doesn't use the name so we avoid the QIcon::fromTheme issue.

When we're writing we copy the icon into the new thread before starting. 

wayland supports threaded pixmaps. 

I'm not sure I see the issue.
Comment 20 Bug Janitor Service 2020-04-22 04:33:09 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 21 Bug Janitor Service 2020-05-07 04:33:14 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!