Closing Krita normally always result in "Krita closed unexpectedly" notification on Plasma

Bug #1874096 reported by Falling Snowdin
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
krita
Fix Released
High
krita (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

Using Kubuntu 20.04 Beta with Krita 4.2.9+dfsg-1

KDE Plasma Version: 5.18.4
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8

Steps to re-produce:
1. Open Krita.
2. Close Krita.

Expected result: Krita closes cleanly without any error notifications.

What happened: On Plasma, closing Krita will always result in a Dr. Konqi error notification "Krita closed unexpectedly". This does not cause any data loss or repercussions afaik, so it seems to be just an annoyance to be fixed.

This does not happen with the Krita AppImage downloaded from krita.org so it looks to be a downstream problem with the Krita package in the Kubuntu repository. I've also attached a KCrash report.

Tags: focal groovy
Revision history for this message
In , genstorm (andreas-sturmlechner) wrote :
Download full text (11.5 KiB)

Application: krita (4.2.8)
 (Compiled from sources)
Qt Version: 5.14.1
Frameworks Version: 5.67.0
Operating System: Linux 5.5.2-gentoo-r1 x86_64
Windowing system: X11
Distribution: "Gentoo Base System release 2.7"

-- Information about the crash:
- What I was doing when the application crashed:

Just starting krita, then closing again (without doing anything else) will lead to it crashing every time. I hope the stacktrace contains enough information.

The crash can be reproduced every time.

-- Backtrace:
Application: Krita (krita), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7efeb29487c0 (LWP 11875))]

Thread 8 (Thread 0x7efe8b7fe700 (LWP 11900)):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007efeb78ca530 in QtLinuxFutex::_q_futex (val3=0, addr2=0x0, val2=0, val=<optimized out>, op=0, addr=<optimized out>) at thread/qfutex_p.h:133
#2 QtLinuxFutex::futexWait<QBasicAtomicInteger<unsigned int> > (expectedValue=<optimized out>, futex=...) at thread/qfutex_p.h:135
#3 futexSemaphoreTryAcquire_loop<true> (u=..., curValue=<optimized out>, nn=8589934593, timeout=<optimized out>) at thread/qsemaphore.cpp:219
#4 0x00007efeb78ca2a6 in futexSemaphoreTryAcquire<true> (timeout=<optimized out>, n=<optimized out>, u=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9/bits/atomic_base.h:539
#5 QSemaphore::tryAcquire (this=0x55c9b72a8fb0, n=<optimized out>, timeout=<optimized out>) at thread/qsemaphore.cpp:484
#6 0x00007efeb8d1668a in KisTileDataSwapper::run() () from /usr/lib64/libkritaimage.so.18
#7 0x00007efeb78c836b in QThreadPrivate::start (arg=0x7efeb90060e0) at thread/qthread_unix.cpp:342
#8 0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#9 0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 7 (Thread 0x7efea8fd0700 (LWP 11897)):
#0 0x00007efeb7497bc3 in __GI___poll (fds=0x7efe98004200, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1 0x00007efeb4da85de in g_main_context_poll (priority=<optimized out>, n_fds=1, fds=0x7efe98004200, timeout=<optimized out>, context=0x7efe98000c20) at ../glib-2.60.7/glib/gmain.c:4228
#2 g_main_context_iterate (context=context@entry=0x7efe98000c20, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib-2.60.7/glib/gmain.c:3922
#3 0x00007efeb4da86ff in g_main_context_iteration (context=0x7efe98000c20, may_block=may_block@entry=1) at ../glib-2.60.7/glib/gmain.c:3988
#4 0x00007efeb7ac5cbb in QEventDispatcherGlib::processEvents (this=0x7efe98000b60, flags=...) at kernel/qeventdispatcher_glib.cpp:425
#5 0x00007efeb7a70a9b in QEventLoop::exec (this=this@entry=0x7efea8fcfdb0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:136
#6 0x00007efeb78c733e in QThread::exec (this=this@entry=0x7efeb5629da0 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at ../../include/QtCore/../../src/corelib/global/qflags.h:118
#7 0x00007efeb55a7507 in QDBusConnectionManager::run (this=0x7efeb5629da0 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holde...

Revision history for this message
In , genstorm (andreas-sturmlechner) wrote :

Created attachment 125883
New crash information added by DrKonqi

krita (4.2.8) using Qt 5.14.1

Same crash as the previous one, more debug symbols.

-- Backtrace (Reduced):
#7 0x00007f409b87a98e in QGestureManager::cleanupCachedGestures (this=this@entry=0x559ca0e8b050, target=target@entry=0x559ca225b170, type=<optimized out>) at kernel/qgesturemanager.cpp:170
#8 0x00007f409b86a6f8 in QWidget::~QWidget (this=0x559ca225b170, __in_chrg=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qmap.h:534
#9 0x00007f409b86abc9 in QWidget::~QWidget (this=0x559ca225b170, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1408
#10 0x00007f409ae8eeac in QObjectPrivate::deleteChildren (this=this@entry=0x559ca3b8daa0) at kernel/qobject.cpp:2123
#11 0x00007f409b86a9d6 in QWidget::~QWidget (this=0x559ca3b8da60, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1530

Revision history for this message
In , genstorm (andreas-sturmlechner) wrote :

Interestingly, a laptop that consumes all the binary packages produced by the system (binhost) where this report is coming from, does not exhibit the same issue. So maybe this is hinged on local config (which exists from way back on the binhost).

Revision history for this message
In , Boudewijn (boud) wrote :

I suspect that it's a build issue... It's not something I can reproduce in any case.

Revision history for this message
In , genstorm (andreas-sturmlechner) wrote :

Yes, I'll experiment with it some more and re-open this once I can be sure it is not a downstream cause.

Revision history for this message
In , Bug-janitor (bug-janitor) wrote :

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!

Revision history for this message
In , Boudewijn (boud) wrote :

*** Bug 418530 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Boudewijn (boud) wrote :

Okay, it's an issue that's new in Qt 5.14, but now that neon is updated, I can reproduce it and try to find a workaround.

Revision history for this message
In , Boudewijn (boud) wrote :

Git commit b26525b369bf6cdf6cd4bb8c39aa4d0c783470cc by Boudewijn Rempt.
Committed on 08/03/2020 at 13:38.
Pushed by rempt into branch 'master'.

"Work around" a bug in Qt 5.14 where Krita crashes on exit

M +4 -0 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/kde/krita/commit/b26525b369bf6cdf6cd4bb8c39aa4d0c783470cc

Revision history for this message
In , Boudewijn (boud) wrote :

Git commit ea079899c0007ab63386f56fdbdc32d2da6786d6 by Boudewijn Rempt.
Committed on 08/03/2020 at 13:38.
Pushed by rempt into branch 'krita/4.2'.

"Work around" a bug in Qt 5.14 where Krita crashes on exit
(cherry picked from commit b26525b369bf6cdf6cd4bb8c39aa4d0c783470cc)

M +4 -0 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/kde/krita/commit/ea079899c0007ab63386f56fdbdc32d2da6786d6

Revision history for this message
Falling Snowdin (falling-snowdin) wrote :
Rik Mills (rikmills)
Changed in krita (Ubuntu):
importance: Undecided → Low
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in krita (Ubuntu):
status: New → Confirmed
Paul White (paulw2u)
tags: added: focal groovy
Revision history for this message
In , Info-themeditationcenter (info-themeditationcenter) wrote :

Created attachment 128631
New crash information added by DrKonqi

krita (4.2.9) using Qt 5.12.8

- What I was doing when the application crashed:
Just opened and closed Krita. Along with this application I had Firefox and Clementine running and nothing else.

- Custom settings of the application:
There was no custom settings, it was a fresh install.

-- Backtrace (Reduced):
#11 0x00007f62a05ce908 in QWidget::~QWidget() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007f62a05cee1d in QWidget::~QWidget() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007f629fba201e in QObjectPrivate::deleteChildren() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007f62a05cec29 in QWidget::~QWidget() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
[...]
#16 0x00007f629fba201e in QObjectPrivate::deleteChildren() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

Revision history for this message
In , Rik Mills (rikmills) wrote :
Revision history for this message
In , Boudewijn (boud) wrote :
Revision history for this message
In , Boudewijn (boud) wrote :
Revision history for this message
In , Boudewijn (boud) wrote :

According to that stackoverflow link, this bug should be fixed in PyQt 5.14, which is the one that I have installed, and I don't have any crashes on exit. packages.ubuntu.org says that eoan has 5.12, which is buggy and shows this problem.

Curiously, we build our binaries with 5.13.1, which according that article is also buggy, but our binaries don't show the issue.

Anyway, not much we can do about it -- it isn't our bug.

Revision history for this message
In , Rik Mills (rikmills) wrote :

For practical purposes I am not overly bothered where blame for the crash lies, as long as there is an effective fix.

As the launchpad bug backtrace with Qt 5.12.8 is the same as the original backtrace here with Qt 5.14.1, which was fixed (or worked around) with:

https://invent.kde.org/graphics/krita/-/commit/ea079899c0007ab63386f56fdbdc32d2da6786d6

extending that fix to cover Qt 5.12 seems a logical step.

I can confirm after a rebuild with that applied for Ubuntu 20.04 focal, that it does indeed fix the crash on exit.

So I will consider applying that as a bugfix stable release update for Krita in 20.04

Thanks :)

Changed in krita:
importance: Unknown → High
status: Unknown → Won't Fix
Revision history for this message
In , Boudewijn (boud) wrote :

*** Bug 422974 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Boudewijn (boud) wrote :

*** Bug 424559 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Amy-i (amy-i) wrote :

*** Bug 438842 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Amy-i (amy-i) wrote :

Reopening this bug because, with PyQt 5.15.4, PtQt5_sip 12.9 and SIP 6.1, this arose again.

Revision history for this message
In , Amy-i (amy-i) wrote :

Git commit a6296beb25c98d9a4b5a136e0088959bf51d550a by L. E. Segovia.
Committed on 18/06/2021 at 15:38.
Pushed by lsegovia into branch 'master'.

Apply the PyKrita workaround to Qt 5.12

This should've been done previously but it was marked as UPSTREAM.

M +2 -2 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/graphics/krita/commit/a6296beb25c98d9a4b5a136e0088959bf51d550a

Revision history for this message
In , Alvin-l (alvin-l) wrote :

Could there be a more proper way to fix this? Perhaps we should explicitly unload the KritaPyQtPlugin before destructing KisApplication?

Revision history for this message
In , Amy-i (amy-i) wrote :

As far as I understand it, this is a race condition inside PyQt5 related to the order of destruction of Python-based QObject instances. Since the call that trigger the crash is the destruction of the plugin itself (which in turn stops the Python engine, etc... as your stacktrace shows), I believe only the PyQt5 authors can solve it.

Revision history for this message
In , Alvin-l (alvin-l) wrote :

In my understanding, it is not so much of the random destruction order or QObject's, but that all QObject's in Python has to be destructed before QCoreApplication. PyQt already solved it if the QCoreApplication is created from the Python side, by ensuring all QObject's destruction before QCoreApplication. but since in our case QCoreApplication is not created from Python, their solution doesn't do anything for us.

In our case, the KritaPyQtPlugin destructor (and thus PyKrita::finalize) is called during the destructor of QCoreApplication, which might be triggering UB? So I wonder if the proper way to clean up is to call PyKrita::finalize earlier, perhaps we can use the QCoreApplication::aboutToQuit signal?

Revision history for this message
In , Alvin-l (alvin-l) wrote :

Git commit a0c29913114164ff3f2ba4e255ccee1c52cb3e86 by Alvin Wong.
Committed on 19/06/2021 at 08:32.
Pushed by alvinwong into branch 'master'.

Fix PyKrita cleanup using qApp::aboutToQuit to prevent crash

Suspecting that we can't have Python clean up its QObject's inside
QCoreApplication's destructor, but must be done before it.

M +10 -5 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/graphics/krita/commit/a0c29913114164ff3f2ba4e255ccee1c52cb3e86

Changed in krita:
status: Won't Fix → Fix Released
Revision history for this message
In , Alvin-l (alvin-l) wrote :

Git commit c936b8a489a5139ed36fb8ec56a5bd07ff542bba by Alvin Wong.
Committed on 22/06/2021 at 09:58.
Pushed by alvinwong into branch 'master'.

Disable PyKrita cleanup again to prevent crash

Cleaning up on qApp::aboutToQuit still causes crashes for some, see:
https://invent.kde.org/graphics/krita/-/commit/a0c29913114164ff3f2ba4e255ccee1c52cb3e86#note_260688

M +3 -1 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/graphics/krita/commit/c936b8a489a5139ed36fb8ec56a5bd07ff542bba

Revision history for this message
In , Dmitry Kazakov (dimula73) wrote :

*** Bug 436724 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Dmitry Kazakov (dimula73) wrote :

Git commit 86a38621fbbf96edf489a0efd2b9c24c123e2051 by Dmitry Kazakov.
Committed on 03/08/2021 at 08:57.
Pushed by dkazakov into branch 'krita/4.3'.

Disable finalizing of the PyQt to prevent crash on exit

M +4 -5 plugins/extensions/pykrita/plugin/plugin.cpp

https://invent.kde.org/graphics/krita/commit/86a38621fbbf96edf489a0efd2b9c24c123e2051

Revision history for this message
Ivnitskii Andrei (ivnitsky-a) wrote :

What about version 4.2.9 for Ubuntu 20.04 ? Needs to recompile with a patch

Revision history for this message
Matt Milano (mattmilano) wrote :

Issue is still present on KDE Neon 5.26.3, Frameworks 5.100.0, Qt Version 5.15.7

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.