Bug 411365

Summary: Freeze while navigating canvas (middle mouse click) on krita/4.2 branch
Product: [Applications] krita Reporter: David REVOY <info>
Component: UsabilityAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: griffinvalley, halla
Priority: NOR    
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description David REVOY 2019-08-27 19:39:14 UTC
Hi, 
This is the second Freeze I have with Krita 4.2 branch compiled of today: https://cgit.kde.org/krita.git/commit/?h=krita/4.2&id=314e9bc3eb90e867f53b6bb70175820a3607487a ; but I couldn't backtrace the first Freeze. This one does a similar result:

- It happens while dragging/navigating the canvas with middle-mouse click
- Krita freeze and the cursor keeps frozen on the shape of the "hand closed" cursor.

Here is the backtrace:

[Thread 0x7fff151fc700 (LWP 11663) exited]
[Thread 0x7fff0ffff700 (LWP 11664) exited]
[Thread 0x7fff0cb2f700 (LWP 11665) exited]
[Thread 0x7ffefd8d3700 (LWP 11666) exited]
[New Thread 0x7ffefd8d3700 (LWP 11667)]
[Thread 0x7ffefd8d3700 (LWP 11667) exited]
[New Thread 0x7ffefd8d3700 (LWP 11668)]
[New Thread 0x7fff0cb2f700 (LWP 11777)]
""
QFileInfo::absolutePath: Constructed with empty filename
[Thread 0x7fff0cb2f700 (LWP 11777) exited]
[Thread 0x7ffefd8d3700 (LWP 11668) exited]
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::translate: Painter not active
QPainter::setWorldTransform: Painter not active
QPainter::save: Painter not active
QPainter::setCompositionMode: Painter not active
QPainter::restore: Unbalanced save/restore
QPainter::setClipPath: Painter not active
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::hasClipping: Painter not active
^C
Thread 1 "krita" received signal SIGINT, Interrupt.
syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
38      ../sysdeps/unix/sysv/linux/x86_64/syscall.S: No such file or directory.
(gdb) thread apply all bt

Thread 11 (Thread 0x7fffa4be3700 (LWP 26459)):
#0  0x00007ffff2e7abf9 in __GI___poll (fds=0x7fff98004b40, nfds=1, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffeb40a5c9 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffeb40a6dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff39db90b in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff39809ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff379f22a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007fffecb506db in start_thread (arg=0x7fffa4be3700) at pthread_create.c:463
#8  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 10 (Thread 0x7fffa6216700 (LWP 26458)):
#0  0x00007ffff2e7abf9 in __GI___poll (fds=0x7fffa0003ce0, nfds=1, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffeb40a5c9 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffeb40a6dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff39db8ef in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff39809ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff379f22a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fffd6efb6f5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
---Type <return> to continue, or q <return> to quit---
#7  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffecb506db in start_thread (arg=0x7fffa6216700) at pthread_create.c:463
#9  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 9 (Thread 0x7fffb91c5700 (LWP 26457)):
#0  0x00007fffecb569f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x555560f9dd80) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  0x00007fffecb569f3 in __pthread_cond_wait_common (abstime=0x0, mutex=0x555560f9dd30, cond=0x555560f9dd58)
    at pthread_cond_wait.c:502
#2  0x00007fffecb569f3 in __pthread_cond_wait (cond=0x555560f9dd58, mutex=0x555560f9dd30)
    at pthread_cond_wait.c:655
#3  0x00007ffff37a559b in QWaitCondition::wait(QMutex*, unsigned long) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff379de5f in QSemaphore::tryAcquire(int, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff57469d3 in KisTileDataSwapper::waitForWork() (this=<optimized out>)
    at /home/deevad/sources/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:86
#6  0x00007ffff5746c0a in KisTileDataSwapper::run() (this=0x7ffff5c44e00 <_ZZN12_GLOBAL__N_116Q_QGS_s_instance13innerFunctionEvE6holder+64>)
    at /home/deevad/sources/krita/src/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:92
#7  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffecb506db in start_thread (arg=0x7fffb91c5700) at pthread_create.c:463
#9  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 8 (Thread 0x7fffb99c6700 (LWP 26456)):
#0  0x00007fffecb569f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x555560f9dad4) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
---Type <return> to continue, or q <return> to quit---
#1  0x00007fffecb569f3 in __pthread_cond_wait_common (abstime=0x0, mutex=0x555560f9da80, cond=0x555560f9daa8)
    at pthread_cond_wait.c:502
#2  0x00007fffecb569f3 in __pthread_cond_wait (cond=0x555560f9daa8, mutex=0x555560f9da80)
    at pthread_cond_wait.c:655
#3  0x00007ffff37a559b in QWaitCondition::wait(QMutex*, unsigned long) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff379dc0b in QSemaphore::acquire(int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff57275ba in KisTileDataPooler::waitForWork() (this=0x7ffff5c44dc0 <_ZZN12_GLOBAL__N_116Q_QGS_s_instance13innerFunctionEvE6holder>)
    at /home/deevad/sources/krita/src/libs/image/tiles3/kis_tile_data_pooler.cc:164
#6  0x00007ffff5727e3a in KisTileDataPooler::run() (this=0x7ffff5c44dc0 <_ZZN12_GLOBAL__N_116Q_QGS_s_instance13innerFunctionEvE6holder>) at /home/deevad/sources/krita/src/libs/image/tiles3/kis_tile_data_pooler.cc:186
#7  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffecb506db in start_thread (arg=0x7fffb99c6700) at pthread_create.c:463
#9  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 7 (Thread 0x7fffbb076700 (LWP 26455)):
#0  0x00007ffff2e7abf9 in __GI___poll (fds=0x7fffb4003ce0, nfds=1, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffeb40a5c9 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffeb40a6dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff39db8ef in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff39809ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff379f22a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#6  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007fffecb506db in start_thread (arg=0x7fffbb076700) at pthread_create.c:463
#8  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 6 (Thread 0x7fffd37e8700 (LWP 26451)):
#0  0x00007ffff2e7abf9 in __GI___poll (fds=0x7fffcc018310, nfds=4, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffeb40a5c9 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fffeb40a6dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff39db8ef in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff39809ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff379f22a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fffecd7dd45 in  () at /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fffecb506db in start_thread (arg=0x7fffd37e8700) at pthread_create.c:463
#9  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7fffdedbd700 (LWP 26450)):
#0  0x00007ffff2e7abf9 in __GI___poll (fds=0x7fffdedbcca8, nfds=1, timeout=-1)
    at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fffea69f747 in  () at /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007fffea6a136a in xcb_wait_for_event () at /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007fffe17262a9 in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007ffff37a416d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
#5  0x00007fffecb506db in start_thread (arg=0x7fffdedbd700) at pthread_create.c:463
#6  0x00007ffff2e8788f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7ffff7f9f640 (LWP 26441)):
#0  0x00007ffff2e81839 in syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007ffff379b765 in QBasicMutex::lockInternal() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff0e2cd3f in QMutexLocker::QMutexLocker(QBasicMutex*) (m=0x555562a2e868, this=<synthetic pointer>)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qmutex.h:200
#3  0x00007ffff0e2cd3f in KoShapeManager::shapes() const (this=this@entry=0x555562781630)
    at /home/deevad/sources/krita/src/libs/flake/KoShapeManager.cpp:661
#4  0x00007ffff0e31a15 in KoShapeManager::paint(QPainter&, KoViewConverter const&, bool) (this=0x555562781630, painter=..., converter=..., forPrint=forPrint@entry=false)
    at /home/deevad/sources/krita/src/libs/flake/KoShapeManager.cpp:309
#5  0x00007ffff6d87dce in KisReferenceImagesLayer::paintReferences(QPainter&) (this=<optimized out>, painter=...) at /home/deevad/sources/krita/src/libs/ui/flake/KisReferenceImagesLayer.cpp:168
#6  0x00007ffff6d8353b in KisReferenceImagesDecoration::Private::updateBuffer(QRectF, QRectF) (this=this@entry=0x555565781460, widgetRect=..., imageRect=...)
    at /home/deevad/sources/krita/src/libs/ui/KisReferenceImagesDecoration.cpp:95
#7  0x00007ffff6d83140 in KisReferenceImagesDecoration::Private::updateBufferByWidgetCoordinates(QRectF const&) (dirtyWidgetRect=..., this=0x555565781460)
    at /home/deevad/sources/krita/src/libs/ui/KisReferenceImagesDecoration.cpp:61
#8  0x00007ffff6d83140 in KisReferenceImagesDecoration::drawDecoration(QPainter&, QRectF const&, KisCoordinatesConverter const*, KisCanvas2*) (this=0x555565780610, gc=..., converter=<optimized out>)
    at /home/deevad/sources/krita/src/libs/ui/KisReferenceImagesDecoration.cpp:140
#9  0x00007ffff698f023 in KisCanvasDecoration::paint(QPainter&, QRectF const&, KisCoordinatesConverter const*, KisCanvas2*) (this=this@entry=0x555565780610, gc=..., updateArea=..., converter=converter@entry=0x555562985800, c---Type <return> to continue, or q <return> to quit---
anvas=canvas@entry=0x5555629858a0) at /home/deevad/sources/krita/src/libs/ui/canvas/kis_canvas_decoration.cc:81
#10 0x00007ffff6977e33 in KisCanvasWidgetBase::drawDecorations(QPainter&, QRect const&) const (this=0x555562620e78, gc=..., updateWidgetRect=...)
    at /home/deevad/sources/krita/src/libs/ui/canvas/kis_canvas_widget_base.cpp:152
#11 0x00007ffff6b6d61d in KisOpenGLCanvas2::renderDecorations(QPainter*) (this=this@entry=0x555562620e40, painter=painter@entry=0x7fffffffd2f0) at /home/deevad/sources/krita/src/libs/ui/opengl/kis_opengl_canvas2.cpp:953
#12 0x00007ffff6b74136 in KisOpenGLCanvas2::paintGL() (this=0x555562620e40)
    at /home/deevad/sources/krita/src/libs/ui/opengl/kis_opengl_canvas2.cpp:410
#13 0x00007ffff475f85d in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007ffff473f038 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff470082c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff47080f4 in QApplication::notify(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff6cdbcd7 in KisApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x555562620e40, event=0x7fffffffd6b0) at /home/deevad/sources/krita/src/libs/ui/KisApplication.cpp:653
#18 0x00007ffff39829a8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff473818a in QWidgetPrivate::sendPaintEvent(QRegion const&) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff470f704 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff4710095 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007ffff472766f in QWidgetPrivate::syncBackingStore() () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007ffff473f1a8 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff4852c4b in QMainWindow::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff5353267 in KMainWindow::event(QEvent*) (this=this@entry=0x555559c49790, ev=ev@entry=0x7fffd891439---Type <return> to continue, or q <return> to quit---
0) at /home/deevad/sources/krita/src/libs/widgetutils/xmlgui/kmainwindow.cpp:765
#26 0x00007ffff5389849 in KXmlGuiWindow::event(QEvent*) (this=0x555559c49790, ev=0x7fffd8914390)
    at /home/deevad/sources/krita/src/libs/widgetutils/xmlgui/kxmlguiwindow.cpp:125
#27 0x00007ffff470082c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007ffff47080f4 in QApplication::notify(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007ffff6cdbcd7 in KisApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x555559c49790, event=0x7fffd8914390) at /home/deevad/sources/krita/src/libs/ui/KisApplication.cpp:653
#30 0x00007ffff39829a8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007ffff398511d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007ffff39dc2c3 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#33 0x00007fffeb40a417 in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00007fffeb40a650 in  () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007fffeb40a6dc in g_main_context_iteration () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007ffff39db8ef in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#37 0x00007ffff39809ea in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#38 0x00007ffff3989a84 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#39 0x0000555555e4d48e in main(int, char**) (argc=<optimized out>, argv=0x7fffffffe3f8)
    at /home/deevad/sources/krita/src/krita/main.cc:535
(gdb) 
(gdb)
Comment 1 wolthera 2019-08-27 19:43:39 UTC
david remarked that the freeze happened at a point that a reference image was just about to be visible in the viewport due panning. Still odd.
Comment 2 Halla Rempt 2019-08-27 19:46:51 UTC
Yes, looks related to reference images and the shape manager. This build includes the commit to the shape manager:

commit cb8279b40c3f0fa3064d444988be95a2b311630a
Author: Dmitry Kazakov <dimula73@gmail.com>
Date:   Mon Aug 26 16:05:08 2019 +0300

    Fix deadlock when removing reference image
    
    We shouldn't request a recursivve shape update from inside a mutex help.
    
    BUG:411212
Comment 3 Dmitry Kazakov 2019-08-27 19:52:01 UTC
Git commit 223c4f3b41558e3fd18cd9461238b76d2caa24f8 by Dmitry Kazakov.
Committed on 27/08/2019 at 19:50.
Pushed by dkazakov into branch 'kazakov/force-crashes-in-lockfree-bug-411280'.

Fix a deadlock in KoShapeManager::paint()

We shouldn't take a lock recursively...

M  +1    -1    libs/flake/KoShapeManager.cpp

https://invent.kde.org/kde/krita/commit/223c4f3b41558e3fd18cd9461238b76d2caa24f8
Comment 4 Dmitry Kazakov 2019-08-27 19:53:26 UTC
Git commit 16b5373ca1d06f1a722ce25873861646521a0b32 by Dmitry Kazakov.
Committed on 27/08/2019 at 19:53.
Pushed by dkazakov into branch 'krita/4.2'.

Fix a deadlock in KoShapeManager::paint()

We shouldn't take a lock recursively...

M  +1    -1    libs/flake/KoShapeManager.cpp

https://invent.kde.org/kde/krita/commit/16b5373ca1d06f1a722ce25873861646521a0b32
Comment 5 Dmitry Kazakov 2019-08-27 19:56:56 UTC
Git commit 4a8019730016e30d76147a4247a041f7de7c2f46 by Dmitry Kazakov.
Committed on 27/08/2019 at 19:56.
Pushed by dkazakov into branch 'master'.

Fix a deadlock in KoShapeManager::paint()

We shouldn't take a lock recursively...

M  +1    -1    libs/flake/KoShapeManager.cpp

https://invent.kde.org/kde/krita/commit/4a8019730016e30d76147a4247a041f7de7c2f46