Bug 417465 - krita-4.2.8.2 crash on exit
Summary: krita-4.2.8.2 crash on exit
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 4.2.8
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: drkonqi
: 418530 422974 424559 436724 438842 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-02-12 00:54 UTC by Andreas Sturmlechner
Modified: 2021-08-03 09:54 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
New crash information added by DrKonqi (13.07 KB, patch)
2020-02-12 02:56 UTC, Andreas Sturmlechner
Details
New crash information added by DrKonqi (8.63 KB, patch)
2020-05-20 11:13 UTC, Meditator
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sturmlechner 2020-02-12 00:54:25 UTC
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()::holder>) at qdbusconnection.cpp:179
#8  0x00007efeb78c836b in QThreadPrivate::start (arg=0x7efeb5629da0 <(anonymous namespace)::Q_QGS__q_manager::innerFunction()::holder>) at thread/qthread_unix.cpp:342
#9  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#10 0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 6 (Thread 0x7efea9856700 (LWP 11896)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7efe94002f58) at ../sysdeps/unix/sysv/linux/futex-internal.h:80
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7efe94002f08, cond=0x7efe94002f30) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7efe94002f30, mutex=0x7efe94002f08) at pthread_cond_wait.c:638
#3  0x00007efeb0e7d46b in cnd_wait (mtx=0x7efe94002f08, cond=0x7efe94002f30) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:155
#4  util_queue_thread_func (input=input@entry=0x7efe940032d0) at ../mesa-20.0.0-rc2/src/util/u_queue.c:275
#5  0x00007efeb0e7d087 in impl_thrd_routine (p=<optimized out>) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:87
#6  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#7  0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7efeabfff700 (LWP 11895)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7efe94002f58) at ../sysdeps/unix/sysv/linux/futex-internal.h:80
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7efe94002f08, cond=0x7efe94002f30) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7efe94002f30, mutex=0x7efe94002f08) at pthread_cond_wait.c:638
#3  0x00007efeb0e7d46b in cnd_wait (mtx=0x7efe94002f08, cond=0x7efe94002f30) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:155
#4  util_queue_thread_func (input=input@entry=0x55c9a9c89290) at ../mesa-20.0.0-rc2/src/util/u_queue.c:275
#5  0x00007efeb0e7d087 in impl_thrd_routine (p=<optimized out>) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:87
#6  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#7  0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7efeab7fe700 (LWP 11894)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7efe94002f58) at ../sysdeps/unix/sysv/linux/futex-internal.h:80
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7efe94002f08, cond=0x7efe94002f30) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7efe94002f30, mutex=0x7efe94002f08) at pthread_cond_wait.c:638
#3  0x00007efeb0e7d46b in cnd_wait (mtx=0x7efe94002f08, cond=0x7efe94002f30) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:155
#4  util_queue_thread_func (input=input@entry=0x55c9a9b0a310) at ../mesa-20.0.0-rc2/src/util/u_queue.c:275
#5  0x00007efeb0e7d087 in impl_thrd_routine (p=<optimized out>) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:87
#6  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#7  0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7efeaaffd700 (LWP 11893)):
#0  futex_wait_cancelable (private=0, expected=0, futex_word=0x7efe94002f58) at ../sysdeps/unix/sysv/linux/futex-internal.h:80
#1  __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x7efe94002f08, cond=0x7efe94002f30) at pthread_cond_wait.c:508
#2  __pthread_cond_wait (cond=0x7efe94002f30, mutex=0x7efe94002f08) at pthread_cond_wait.c:638
#3  0x00007efeb0e7d46b in cnd_wait (mtx=0x7efe94002f08, cond=0x7efe94002f30) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:155
#4  util_queue_thread_func (input=input@entry=0x7efe94003310) at ../mesa-20.0.0-rc2/src/util/u_queue.c:275
#5  0x00007efeb0e7d087 in impl_thrd_routine (p=<optimized out>) at ../mesa-20.0.0-rc2/include/c11/threads_posix.h:87
#6  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#7  0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7efeaa7fc700 (LWP 11892)):
#0  0x00007efeb7497bc3 in __GI___poll (fds=0x7efeaa7fbce8, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007efeb48dfcf2 in ?? () from /usr/lib64/libxcb.so.1
#2  0x00007efeb48e18ea in xcb_wait_for_event () from /usr/lib64/libxcb.so.1
#3  0x00007efeb22b6e50 in QXcbEventQueue::run (this=0x55c9a9a359d0) at qxcbeventqueue.cpp:228
#4  0x00007efeb78c836b in QThreadPrivate::start (arg=0x55c9a9a359d0) at thread/qthread_unix.cpp:342
#5  0x00007efeb55752d7 in start_thread (arg=<optimized out>) at pthread_create.c:479
#6  0x00007efeb74a3a5f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7efeb29487c0 (LWP 11875)):
[KCrash Handler]
#7  0x00007efeb848d98e in QGestureManager::cleanupCachedGestures (this=this@entry=0x55c9b6a2fb80, target=target@entry=0x55c9b7e00a30, type=<optimized out>) at kernel/qgesturemanager.cpp:170
#8  0x00007efeb847d6f8 in QWidget::~QWidget (this=0x55c9b7e00a30, __in_chrg=<optimized out>) at ../../include/QtCore/../../src/corelib/tools/qmap.h:534
#9  0x00007efeb847dbc9 in QWidget::~QWidget (this=0x55c9b7e00a30, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1408
#10 0x00007efeb7aa1eac in QObjectPrivate::deleteChildren (this=this@entry=0x55c9b95c6a10) at kernel/qobject.cpp:2123
#11 0x00007efeb847d9d6 in QWidget::~QWidget (this=0x55c9b95c69d0, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1530
#12 0x00007efeb8550acd in QComboBoxListView::~QComboBoxListView (this=0x55c9b95c69d0, __in_chrg=<optimized out>) at ../../include/QtWidgets/5.14.1/QtWidgets/private/../../../../../src/widgets/widgets/qcombobox_p.h:85
#13 QComboBoxListView::~QComboBoxListView (this=0x55c9b95c69d0, __in_chrg=<optimized out>) at ../../include/QtWidgets/5.14.1/QtWidgets/private/../../../../../src/widgets/widgets/qcombobox_p.h:85
#14 0x00007efeb7aa1eac in QObjectPrivate::deleteChildren (this=this@entry=0x55c9b95cac90) at kernel/qobject.cpp:2123
#15 0x00007efeb847d9d6 in QWidget::~QWidget (this=0x55c9b76db660, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1530
#16 0x00007efeb8553094 in QComboBoxPrivateContainer::~QComboBoxPrivateContainer (this=0x55c9b76db660, __in_chrg=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qbasictimer.h:67
#17 QComboBoxPrivateContainer::~QComboBoxPrivateContainer (this=0x55c9b76db660, __in_chrg=<optimized out>) at ../../include/QtWidgets/5.14.1/QtWidgets/private/../../../../../src/widgets/widgets/qcombobox_p.h:218
#18 0x00007efeb7aa1eac in QObjectPrivate::deleteChildren (this=this@entry=0x55c9b0f08bc0) at kernel/qobject.cpp:2123
#19 0x00007efeb847d9d6 in QWidget::~QWidget (this=0x55c9b86500e0, __in_chrg=<optimized out>) at kernel/qwidget.cpp:1530
#20 0x00007efe89ddf8b9 in ?? () from /usr/lib/python3.8/site-packages/PyQt5/QtWidgets.so
#21 0x00007efe8a7ff831 in ?? () from /usr/lib/python3.8/site-packages/PyQt5/QtCore.so
#22 0x00007efe8a903608 in ?? () from /usr/lib/python3.8/site-packages/PyQt5/sip.so
#23 0x00007efe8a7ff4dc in ?? () from /usr/lib/python3.8/site-packages/PyQt5/QtCore.so
#24 0x00007efe8ad0de15 in ?? () from /usr/lib64/libpython3.8.so.1.0
#25 0x00007efe8acd74df in PyVectorcall_Call () from /usr/lib64/libpython3.8.so.1.0
#26 0x00007efe8ae18d4e in ?? () from /usr/lib64/libpython3.8.so.1.0
#27 0x00007efe8adbc82e in Py_FinalizeEx () from /usr/lib64/libpython3.8.so.1.0
#28 0x00007efe8afe2811 in ?? () from /usr/lib64/kritaplugins/kritapykrita.so
#29 0x00007efe8afe299c in ?? () from /usr/lib64/kritaplugins/kritapykrita.so
#30 0x00007efe8afdfd07 in ?? () from /usr/lib64/kritaplugins/kritapykrita.so
#31 0x00007efeb7aa1eac in QObjectPrivate::deleteChildren (this=0x55c9a99fa030) at kernel/qobject.cpp:2123
#32 0x00007efeb7aa2b32 in QObject::~QObject (this=<optimized out>, __in_chrg=<optimized out>) at kernel/qobject.cpp:1107
#33 0x00007efeb7a73eea in QCoreApplication::~QCoreApplication (this=0x7fff3c3c3f40, __in_chrg=<optimized out>) at ../../include/QtCore/../../src/corelib/text/qstringlist.h:111
#34 0x00007efeb7e53a02 in QGuiApplication::~QGuiApplication (this=0x7fff3c3c3f40, __in_chrg=<optimized out>) at kernel/qguiapplication.cpp:723
#35 0x00007efeb844062f in QApplication::~QApplication (this=0x7fff3c3c3f40, __in_chrg=<optimized out>) at kernel/qapplication.cpp:835
#36 0x00007efeb9f9d97e in QtSingleApplication::~QtSingleApplication() () from /usr/lib64/libkritaui.so.18
#37 0x000055c9a802b4f6 in main ()
[Inferior 1 (process 11875) detached]

Possible duplicates by query: bug 414728, bug 413345, bug 408889, bug 406062, bug 402892.

Reported using DrKonqi
Comment 1 Andreas Sturmlechner 2020-02-12 02:56:19 UTC
Created attachment 125883 [details]
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
Comment 2 Andreas Sturmlechner 2020-02-12 13:17:03 UTC
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).
Comment 3 Halla Rempt 2020-02-12 13:54:01 UTC
I suspect that it's a build issue... It's not something I can reproduce in any case.
Comment 4 Andreas Sturmlechner 2020-02-12 21:39:05 UTC
Yes, I'll experiment with it some more and re-open this once I can be sure it is not a downstream cause.
Comment 5 Bug Janitor Service 2020-02-27 04:33:11 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 6 Halla Rempt 2020-03-06 10:17:04 UTC
*** Bug 418530 has been marked as a duplicate of this bug. ***
Comment 7 Halla Rempt 2020-03-06 10:17:45 UTC
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.
Comment 8 Halla Rempt 2020-03-08 13:38:30 UTC
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
Comment 9 Halla Rempt 2020-03-08 13:39:01 UTC
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
Comment 10 Meditator 2020-05-20 11:13:08 UTC
Created attachment 128631 [details]
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
Comment 11 Rik Mills 2020-05-25 08:21:40 UTC
Yes, with 5.12: https://bugs.launchpad.net/ubuntu/+source/krita/+bug/1874096
Comment 12 Halla Rempt 2020-05-26 10:37:33 UTC
This might be relevant: https://www.riverbankcomputing.com/static/Docs/PyQt5/gotchas.html#crashes-on-exit
Comment 14 Halla Rempt 2020-05-26 10:45:42 UTC
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.
Comment 15 Rik Mills 2020-05-26 13:22:26 UTC
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 :)
Comment 16 Halla Rempt 2020-06-14 15:49:58 UTC
*** Bug 422974 has been marked as a duplicate of this bug. ***
Comment 17 Halla Rempt 2020-07-23 08:36:46 UTC
*** Bug 424559 has been marked as a duplicate of this bug. ***
Comment 18 amyspark 2021-06-18 13:38:57 UTC
*** Bug 438842 has been marked as a duplicate of this bug. ***
Comment 19 amyspark 2021-06-18 13:40:49 UTC
Reopening this bug because, with PyQt 5.15.4, PtQt5_sip 12.9 and SIP 6.1, this arose again.
Comment 20 amyspark 2021-06-18 15:38:33 UTC
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
Comment 21 Alvin Wong 2021-06-18 15:55:53 UTC
Could there be a more proper way to fix this? Perhaps we should explicitly unload the KritaPyQtPlugin before destructing KisApplication?
Comment 22 amyspark 2021-06-19 00:32:51 UTC
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.
Comment 23 Alvin Wong 2021-06-19 06:36:10 UTC
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?
Comment 24 Alvin Wong 2021-06-19 08:35:02 UTC
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
Comment 25 Alvin Wong 2021-06-22 09:58:17 UTC
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
Comment 26 Dmitry Kazakov 2021-08-03 08:52:02 UTC
*** Bug 436724 has been marked as a duplicate of this bug. ***
Comment 27 Dmitry Kazakov 2021-08-03 09:54:00 UTC
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