Created attachment 128144 [details] A crash to desktop seen when using magnetic selection. A total of two clicks occur after starting the selection. SUMMARY When using magnetic selection, Krita may crash to desktop when the user clicks while making a selection. It also appears to occur with dragging your magnetic selection too far. Version: 4.3.0-beta1 STEPS TO REPRODUCE 1. Open a test .kra file. The one I used was 512x512px with a layer for lineart and colour. 2. Open the magnetic selection tool at default values. 3. Click and drag the magnetic selection tool to select a feature in the file. During your selection, stop holding down the mouse button and click to restart the selection process. OBSERVED RESULT Krita freezes momentarily and then crashes to desktop. EXPECTED RESULT The selection either continues or starts a new selection depending on your value. SOFTWARE/OS VERSIONS Windows: 10 macOS: NA Linux/KDE Plasma: NA (available in About System) KDE Plasma Version: NA KDE Frameworks Version: NA Qt Version: Unknown ADDITIONAL INFORMATION Attached file shows a crash in action.
Hi, Could you please also attach the kritacrash.log file you can find in AppData\Local?
Created attachment 128195 [details] kritacrash.log
Of course, here you go. Hope this helps!
Thanks!
No matter what I try, I am not able to reproduce the crash for now with the 4.3.0-beta1 appimage
Hi Malle, I also haven't been able to reproduce this on windows or linux; can you reliable reproduce this crash?
I've just tested the steps to reproduce the crash, and have found the following: Krita seems to crash reliably at 512x512px canvas size when performing the steps. When I tested on larger canvas sizes (A5 and A4 size), I have not been able to reproduce the crash. Both of these tests were on the windows version. I hope that helps!
Hm... I still cannot reproduce.
The only other thing that I can think of is that the file I used to test has multiple raster layers. I set these to be invisible, and made sure they weren't selected before testing, but I still seem to get the crash. I tried editing the memory limit, but it appears to happen whether I set it to 5% or 95%. Beyond that, I don't know what else might be influencing the presence of crashing. I will attach the file that I first experienced the crash with, in case it might help with reproducing the bug! Hope this helps!
Created attachment 128260 [details] .kra file that I first experienced the crash with.
Yes! With that file I can reproduce the crash on Linux. ASSERT failure in QVector<T>::operator[]: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h, line 463 KCrash: crashing... crashRecursionCounter = 2 KCrash: Application Name = krita path = /home/boud/dev/i-4.3/bin pid = 14118 KCrash: Arguments: /home/boud/dev/i-4.3/bin/krita /home/boud/Downloads/workDoc_george_stickers_testFile.kra KCrash: Attempting to start /usr/lib/x86_64-linux-gnu/libexec/drkonqi from kdeinit Here's the full backtrace: Thread 1 (Thread 0x7fe30d88b800 (LWP 14118)): [KCrash Handler] #6 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #7 0x00007fe308044801 in __GI_abort () at abort.c:79 #8 0x00007fe308a6e59b in QMessageLogger::fatal(char const*, ...) const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #9 0x00007fe308a6ddeb in qt_assert_x(char const*, char const*, char const*, int) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #10 0x00007fe2cf82eb4f in QVector<double>::operator[] (i=<optimized out>, this=<optimized out>) at /home/boud/dev/4.3/libs/global/kis_shared_ptr.h:223 #11 KisMagneticLazyTiles::filter (this=0x558dbc56d8c0, radius=3, rect=...) at /home/boud/dev/4.3/plugins/tools/selectiontools/KisMagneticWorker.cc:180 #12 0x00007fe2cf8718e1 in KisMagneticWorker::computeEdge (this=this@entry=0x558dbc56d8c0, bounds=30, begin=..., end=end@entry=..., radius=3) at /home/boud/dev/4.3/plugins/tools/selectiontools/KisMagneticWorker.cc:199 #13 0x00007fe2cf87f2bb in KisToolSelectMagnetic::computeEdgeWrapper (b=..., a=..., this=0x558dbc56d7d0) at /home/boud/dev/4.3/plugins/tools/selectiontools/KisToolSelectMagnetic.cc:189 #14 KisToolSelectMagnetic::beginPrimaryAction (this=0x558dbc56d7d0, event=<optimized out>) at /home/boud/dev/4.3/plugins/tools/selectiontools/KisToolSelectMagnetic.cc:219 #15 0x00007fe30c0f38b3 in KisToolProxy::forwardToTool (this=<optimized out>, state=KisToolProxy::BEGIN, action=KisTool::Primary, event=0x7fff72394630, docPoint=...) at /home/boud/dev/4.3/libs/ui/canvas/kis_tool_proxy.cpp:183 #16 0x00007fe30c0f3a3b in KisToolProxy::forwardEvent (this=0x558dba0b1980, state=state@entry=KisToolProxy::BEGIN, action=action@entry=KisTool::Primary, event=event@entry=0x7fff72394630, originalEvent=originalEvent@entry=0x7fff72394630) at /home/boud/dev/4.3/libs/ui/canvas/kis_tool_proxy.cpp:132 #17 0x00007fe30c4b4903 in KisToolInvocationAction::begin (this=this@entry=0x558db67724b0, shortcut=<optimized out>, event=event@entry=0x7fff72394630) at /usr/include/c++/9/bits/atomic_base.h:413 #18 0x00007fe30c4c3b31 in KisShortcutMatcher::tryRunReadyShortcut (this=0x558db6e89410, button=Qt::LeftButton, event=0x7fff72394630) at /home/boud/dev/4.3/libs/ui/input/kis_shortcut_matcher.cpp:620 #19 0x00007fe30c4c3e1e in KisShortcutMatcher::buttonPressed (this=0x558db6e89410, button=Qt::LeftButton, event=event@entry=0x7fff72394630) at /home/boud/dev/4.3/libs/ui/input/kis_shortcut_matcher.cpp:271 #20 0x00007fe30c4a6af4 in KisInputManager::eventFilterImpl (this=0x558db79e2df8, event=0x7fff72394630) at /usr/include/x86_64-linux-gnu/qt5/QtGui/qevent.h:132 #21 0x00007fe308c81b3d in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #22 0x00007fe309b6b892 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #23 0x00007fe309b73908 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #24 0x00007fe30c52ba59 in KisApplication::notify (this=<optimized out>, receiver=0x558dba151370, event=0x7fff72394630) at /home/boud/dev/4.3/libs/ui/KisApplication.cpp:680 #25 0x00007fe308c81db8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #26 0x00007fe309b71f8f in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #27 0x00007fe309bc6eb1 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #28 0x00007fe309bc9d1a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #29 0x00007fe309b6b8bc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #30 0x00007fe309b72ac0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 #31 0x00007fe30c52ba59 in KisApplication::notify (this=<optimized out>, receiver=0x558db76b84c0, event=0x7fff72394b30) at /home/boud/dev/4.3/libs/ui/KisApplication.cpp:680 #32 0x00007fe308c81db8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #33 0x00007fe30927df95 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 #34 0x00007fe30927f0c5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 #35 0x00007fe30925801b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 #36 0x00007fe2f9200c8a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5 #37 0x00007fe300264417 in g_main_context_dispatch () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 #38 0x00007fe300264650 in ?? () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 #39 0x00007fe3002646dc in g_main_context_iteration () from /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 #40 0x00007fe308ce10bc in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #41 0x00007fe308c8063a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #42 0x00007fe308c89db0 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 #43 0x0000558dab416b47 in main (argc=<optimized out>, argv=0x7fff723951f8) at /home/boud/dev/4.3/krita/main.cc:593 [Inferior 1 (process 14118) detached]
hellozee, does this patch makes sense: diff --git a/plugins/tools/selectiontools/KisMagneticWorker.cc b/plugins/tools/selectiontools/KisMagneticWorker.cc index f190006eb3..631caaf749 100644 --- a/plugins/tools/selectiontools/KisMagneticWorker.cc +++ b/plugins/tools/selectiontools/KisMagneticWorker.cc @@ -177,7 +177,7 @@ void KisMagneticLazyTiles::filter(qreal radius, QRect &rect) for (int i = firstTile.y(); i <= lastTile.y(); i++) { for (int j = firstTile.x(); j <= lastTile.x(); j++) { int currentTile = i * m_tilesPerRow + j; - if (radius != m_radiusRecord[currentTile]) { + if (m_radiusRecord.size() < currentTile && radius != m_radiusRecord[currentTile]) { QRect bounds = m_tiles[currentTile]; KisGaussianKernel::applyTightLoG(m_dev, bounds, radius, -1.0, QBitArray(), nullptr); KisLazyFillTools::normalizeAlpha8Device(m_dev, bounds); lines 1-13/13 (END) ?
Okay, there's another unchecked access, so this patch is better: diff --git a/plugins/tools/selectiontools/KisMagneticWorker.cc b/plugins/tools/selectiontools/KisMagneticWorker.cc index f190006eb3..511c6831e6 100644 --- a/plugins/tools/selectiontools/KisMagneticWorker.cc +++ b/plugins/tools/selectiontools/KisMagneticWorker.cc @@ -177,7 +177,9 @@ void KisMagneticLazyTiles::filter(qreal radius, QRect &rect) for (int i = firstTile.y(); i <= lastTile.y(); i++) { for (int j = firstTile.x(); j <= lastTile.x(); j++) { int currentTile = i * m_tilesPerRow + j; - if (radius != m_radiusRecord[currentTile]) { + if (m_radiusRecord.size() < currentTile + && m_tiles.size() < currentTile + && radius != m_radiusRecord[currentTile]) { QRect bounds = m_tiles[currentTile]; KisGaussianKernel::applyTightLoG(m_dev, bounds, radius, -1.0, QBitArray(), nullptr); KisLazyFillTools::normalizeAlpha8Device(m_dev, bounds); But... It seriously breaks the selection... I cannot get a good selection with it anymore.
Git commit 4a94c3fe9974c07899ff4447b4f1495a62036b1c by Boudewijn Rempt. Committed on 14/05/2020 at 11:29. Pushed by rempt into branch 'master'. Check vectors before indexing them M +3 -1 plugins/tools/selectiontools/KisMagneticWorker.cc https://invent.kde.org/kde/krita/commit/4a94c3fe9974c07899ff4447b4f1495a62036b1c
Git commit 85bac32e34d7279764969bd72b6f0d1de639f2fe by Boudewijn Rempt. Committed on 14/05/2020 at 11:30. Pushed by rempt into branch 'krita/4.3'. Check vectors before indexing them (cherry picked from commit 4a94c3fe9974c07899ff4447b4f1495a62036b1c) M +3 -1 plugins/tools/selectiontools/KisMagneticWorker.cc https://invent.kde.org/kde/krita/commit/85bac32e34d7279764969bd72b6f0d1de639f2fe