Bug 443610 - Pressing ctrl-x twice crashes Krita
Summary: Pressing ctrl-x twice crashes Krita
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 5.0.0-beta1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-10-11 21:02 UTC by Bleke
Modified: 2021-10-21 09:09 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
All text from the terminal (41.69 KB, text/plain)
2021-10-11 21:02 UTC, Bleke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bleke 2021-10-11 21:02:44 UTC
Created attachment 142343 [details]
All text from the terminal

SUMMARY


STEPS TO REPRODUCE
1. Start Krita
2. Create a new image
3. hold ctrl and press x twice

OBSERVED RESULT

ASSERT (krita): "root->parent() || inputNodes.isEmpty()" in file /home/appimage/workspace/Krita_Release_Appimage_Build/krita/libs/image/kis_layer_utils.cpp, line 1536
Aborted (core dumped)

EXPECTED RESULT

Cut a layer or two? Nothing?
Not crashing at least. :)


SOFTWARE/OS VERSIONS
 
(available in About System)
KDE Plasma Version: Gnome 3.38.5
KDE Frameworks Version: 5
Qt Version: Not sure

ADDITIONAL INFORMATION
Pop!_OS 21.04
AMD® Ryzen 7 1700 eight-core processor × 16
15,6 GiB
NVIDIA Corporation TU104 [GeForce RTX 2070 SUPER]
Comment 1 tomtomtomreportingin 2021-10-11 21:48:13 UTC
Can confirm in beta 2 and master. A crash also occurs in older versions (such as 4.4.0) if the user unlocks the background layer and holds ctrl + x. In beta 2 and master, the second cut must quickly follow the first behavior, but the holding ctrl + x crash also occurs. The newer crash behavior might be related to https://bugs.kde.org/show_bug.cgi?id=442972 .
Comment 2 Ahab Greybeard 2021-10-12 13:01:14 UTC
With the Oct 11 5.1.0-prealpha (git 5316345) and previous appimages on Debian 10,
if you have an empty layer or a layer with paint on it, if you make a selection then two presses of Ctrl+X does not cause a crash.
Comment 3 wolthera 2021-10-12 14:26:51 UTC
Ah, this is confusing, because we had a gsoc dealing with layer operations that got merged to 5.1-pre-alpha but isn't in 5.0. The bug tomtom is linking to is one caused by the gsoc, and should only happen in 5.1-pre-alpha and above.

So, I can reproduce this issue in 5.0.0-beta2 (git 6d23534), of note is that this is the 'layer cut' operation, and not the 'pixel buffer cut' operation, we use 'layer cut' whenever there's no selection to simplify access to that function.

What I suspect is going on is that the layer docker is taking some time to update itself and can in between cuts report that the user is cutting the same layer (even when it doesn't exist there anymore, because it got cut), and the action that is handling the cutting of the layer gets confused.

BACKTRACE
----------


Thread 1 (Thread 0x7ff0d8668f80 (LWP 2329881)):
[KCrash Handler]
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x00007ff0dd944859 in __GI_abort () at abort.c:79
#6  0x00007ff0ddda0bd7 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007ff0df04fdaa in kis_assert_common(char const*, char const*, int, bool, bool) (assertion=<optimized out>, file=<optimized out>, line=<optimized out>, throwException=<optimized out>, isIgnorable=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qarraydata.h:61
#8  0x00007ff0df64d7bb in KisLayerUtils::sortMergableNodes(KisSharedPtr<KisNode>, QList<KisSharedPtr<KisNode> >&, QList<KisSharedPtr<KisNode> >&) (root=..., inputNodes=..., outputNodes=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h:116
#9  0x00007ff0dfecac69 in KisMimeData::mimeForLayersDeepCopy(QList<KisSharedPtr<KisNode> > const&, KisSharedPtr<KisImage>, bool) (nodes=..., image=..., forceCopy=<optimized out>) at /home/wolthera/krita/src/libs/global/kis_shared_ptr.h:167
#10 0x00007ff0dfe60fa0 in KisClipboard::setLayers(QList<KisSharedPtr<KisNode> >, KisSharedPtr<KisImage>, bool) (this=<optimized out>, nodes=..., image=..., forceCopy=<optimized out>) at /usr/include/c++/9/bits/atomic_base.h:318
#11 0x00007ff0dfedef43 in KisNodeManager::cutLayersToClipboard() (this=0x564257338b90) at /home/wolthera/krita/src/libs/ui/kis_node_manager.cpp:1446
#12 0x00007ff0e01ae903 in KisCutCopyActionFactory::run(bool, bool, KisViewManager*) (this=this@entry=0x7ffec8a97760, willCut=willCut@entry=true, makeSharpClip=makeSharpClip@entry=false, view=0x564257337f10) at /home/wolthera/krita/src/libs/ui/actions/kis_selection_action_factories.cpp:366
#13 0x00007ff0dff50aab in KisSelectionManager::cut() (this=0x5642573388b0) at /home/wolthera/krita/src/libs/ui/kis_selection_manager.cc:337
#14 0x00007ff0dfcff973 in KisSelectionManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /home/wolthera/krita/build/libs/ui/kritaui_autogen/EWIEGA46WW/moc_kis_selection_manager.cpp:244
#15 0x00007ff0ddff9dd0 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ff0dea968e6 in QAction::triggered(bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ff0dea98fb8 in QAction::activate(QAction::ActionEvent) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ff0dea998cf in QAction::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ff0dea9cdc3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ff0deaa5bb8 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ff0e023a65d in KisApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x564259c08800, event=0x7ffec8a97cd0) at /home/wolthera/krita/src/libs/ui/KisApplication.cpp:698
#22 0x00007ff0ddfc2d7a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#23 0x00007ff0de3d4e53 in QShortcutMap::dispatchEvent(QKeyEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#24 0x00007ff0de3d57f3 in QShortcutMap::tryShortcut(QKeyEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x00007ff0de382c72 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
Comment 4 Bug Janitor Service 2021-10-20 18:46:41 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1111
Comment 5 Halla Rempt 2021-10-21 09:08:59 UTC
Git commit c4f2585ae3051af5844c994850258f905ff98f54 by Halla Rempt, on behalf of Sharaf Zaman.
Committed on 21/10/2021 at 09:08.
Pushed by rempt into branch 'master'.

Bugfix: Crash when cutting the layers rapidly

Update operation of LayerBox seems to be slower, so the selected nodes
don't get updated in time. And because KisClipboard::setLayers takes a
node which is part of the node graph, we remove the ones which are.

M  +9    -0    libs/ui/kis_node_manager.cpp

https://invent.kde.org/graphics/krita/commit/c4f2585ae3051af5844c994850258f905ff98f54
Comment 6 Halla Rempt 2021-10-21 09:09:14 UTC
Git commit 7effb5039fb159dde24fc3ff7c4277e6b0da0798 by Halla Rempt, on behalf of Sharaf Zaman.
Committed on 21/10/2021 at 09:09.
Pushed by rempt into branch 'cherry-pick-c4f2585a'.

Bugfix: Crash when cutting the layers rapidly

Update operation of LayerBox seems to be slower, so the selected nodes
don't get updated in time. And because KisClipboard::setLayers takes a
node which is part of the node graph, we remove the ones which are.


(cherry picked from commit c4f2585ae3051af5844c994850258f905ff98f54)

M  +9    -0    libs/ui/kis_node_manager.cpp

https://invent.kde.org/graphics/krita/commit/7effb5039fb159dde24fc3ff7c4277e6b0da0798
Comment 7 Halla Rempt 2021-10-21 09:09:45 UTC
Git commit f6e7041841c212b58dc13d66f919387b25df8434 by Halla Rempt, on behalf of Sharaf Zaman.
Committed on 21/10/2021 at 09:09.
Pushed by rempt into branch 'krita/5.0'.

Bugfix: Crash when cutting the layers rapidly

Update operation of LayerBox seems to be slower, so the selected nodes
don't get updated in time. And because KisClipboard::setLayers takes a
node which is part of the node graph, we remove the ones which are.


(cherry picked from commit c4f2585ae3051af5844c994850258f905ff98f54)

M  +9    -0    libs/ui/kis_node_manager.cpp

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