Bug 456201

Summary: Crash after a right click on a group layer
Product: [Applications] krita Reporter: David REVOY <info>
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: dimula73, halla
Priority: NOR    
Version: 5.1.0-beta1   
Target Milestone: ---   
Platform: Appimage   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: ^ gdb output of the crash, compressed as zip because it was too big

Description David REVOY 2022-07-01 09:50:00 UTC
Hi,
Here is a specific crash: it works only on a specific Krita file, after opening and right-clicking on a folded layer group named "frame". I tried to remove other layer to make a smaller file, but doing so fixed the layer stack because after that I wasn't able to reproduce.

To reproduce:
===========
1. Download and extract https://www.peppercarrot.com/extras/temp/2022-07-01_E37P04_crash-right-click-on-frame-layer.zip
2. When the Krita file open, it might prompt for a missing link to a text layer; it's not related to the bug, select no.
3. Right click on the folded group layer named "frame" on top of layer stack
(original intent was to color this group to grey in the layer stack)

Result:
======
Krita crashes. Sometime, the right-click menu of the layer stack appears briefly but Krita crashes anyway. 

Expected:
========
Access the right-click menu, no crash and being able to color the group layer with grey color slot.

LOGS:
=====
GDB:
```
GNU gdb (GDB) Fedora 12.1-1.fc36
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/deevad/sources/krita/krita-testing...
(No debugging symbols found in /home/deevad/sources/krita/krita-testing)
Starting program: /home/deevad/sources/krita/krita-testing /home/deevad/peppercarrot/webcomics/new-ep37_Phoenix-Tears/E37P04.kra
/usr/bin/AppImageLauncher: /lib64/libcurl.so.4: no version information available (required by /usr/bin/../lib/x86_64-linux-gnu/appimagelauncher/libappimageupdate.so)
[Detaching after fork from child process 7800]
process 7797 is executing new program: /usr/lib/x86_64-linux-gnu/appimagelauncher/binfmt-bypass
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Detaching after fork from child process 7806]
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
krita.general: convertAndSetBlendMode: Curve conversion is not implemented yet
QObject::startTimer: Timers cannot have negative intervals
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
/tmp/.mount_krita-OxCsZi/usr/lib/krita-python-libs/krita added to PYTHONPATH
profileForCsIdWithFallbackImpl couldn't fetch a fallback profile for  
QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout
QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout
QImage::scaled: Image is a null image
[Inferior 1 (process 7797) exited normally]
Missing separate debuginfos, use: dnf debuginfo-install appimagelauncher-2.2.0-travis995~0f91801.x86_64
(gdb) 
```

KRITA LOGS:
==========
```
SESSION: 01 Jul 2022 11:33:15 +0200. Executing /tmp/.mount_krita-ssiX3v/usr/bin/krita /home/deevad/2022-07-01_E37P04.kra

Krita Version: 5.1.0-beta1, Qt version compiled: 5.12.12, loaded: 5.12.12. Process ID: 9796
-- -- -- -- -- -- -- --
01 Jul 2022 11:33:15 +0200: Style: fusion. Available styles: Windows, Fusion
01 Jul 2022 11:33:16 +0200: Database is up to date. Version: 0.0.17, created by Krita 5.1.0-beta1, at mar. juin 28 16:30:43 2022
01 Jul 2022 11:33:20 +0200: KisAppimageUpdater: update check finished. Result: 2 Exit status: 0
path: /home/deevad/sources/krita/krita-5.1.0-beta1-x86_64.appimage
output: 
01 Jul 2022 11:33:20 +0200: Importing application/x-krita to application/x-krita. Location: /home/deevad/2022-07-01_E37P04.kra. Real location: /home/deevad/2022-07-01_E37P04.kra. Batchmode: 0
01 Jul 2022 11:33:27 +0200: Loaded image from application/x-krita. Size: 3600 * 5083 pixels, 6.45083 dpi. Color model: 8-bit integer/channel RGB/Alpha (sRGB built-in). Layers: 20

KRITA DID NOT CLOSE CORRECTLY
================================================================================
```

Krita 5.1beta1 appimage; Fedora 36 KDE Spin
Comment 1 Halla Rempt 2022-07-01 09:52:56 UTC
I cannot open the file because of the missing file layer:

krita(100321)/(default) unknown: ASSERT: "channelFlags.isEmpty() ||((quint32)channelFlags.count() == colorSpace()->channelCount())" in file /home/halla/dev/krita/libs/image/kis_layer.cc, line 342

Thread 1 "krita" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff52ef859 in __GI_abort () at abort.c:79
#2  0x00007ffff579c455 in QMessageLogger::fatal(char const*, ...) const ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#3  0x00007ffff579b827 in qt_assert(char const*, char const*, int) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#4  0x00007ffff6c9d2f8 in KisLayer::setChannelFlags (this=<optimized out>, channelFlags=...)
    at /home/halla/dev/krita/libs/image/kis_layer.cc:342
#5  0x00007fffc85efdd1 in KisKraLoader::loadNode (this=0x555557e72080, element=..., image=...)
    at /home/halla/dev/krita/plugins/impex/libkra/kis_kra_loader.cpp:921
#6  0x00007fffc85f14e3 in KisKraLoader::loadNodes (this=0x555557e72080, element=..., image=..., parent=...)
    at /home/halla/dev/krita/plugins/impex/libkra/kis_kra_loader.cpp:756
#7  0x00007fffc85f2663 in KisKraLoader::loadXML (this=0x555557e72080, imageElement=...)
    at /home/halla/dev/krita/plugins/impex/libkra/kis_kra_loader.cpp:297
#8  0x00007fffc862b83a in KraConverter::loadXML (this=0x7fffffffc050, doc=..., store=<optimized out>)
    at /home/halla/dev/krita/plugins/impex/libkra/kra_converter.cpp:374
#9  0x00007fffc862db31 in KraConverter::buildImage (this=this@entry=0x7fffffffc050, io=0x7fffffffbf50, 
    io@entry=0x7fffffffc110) at /home/halla/dev/krita/plugins/impex/libkra/kra_converter.cpp:87
#10 0x00007fffc864e3ce in KraImport::convert (this=<optimized out>, document=0x555559406b20, io=0x7fffffffc110)
    at /home/halla/dev/krita/plugins/impex/kra/kra_import.cpp:30
#11 0x00007ffff7c4ef9c in KisImportExportManager::doImport (this=0x555559bc2940, location=..., filter=...)
    at /home/halla/dev/krita/libs/ui/KisImportExportManager.cpp:665
#12 0x00007ffff7c507ba in KisImportExportManager::convert (this=0x555559bc2940, direction=<optimized out>, 
    location=..., realLocation=..., mimeType=..., showWarnings=<optimized out>, exportConfiguration=..., 
    isAsync=<optimized out>, isAdvancedExporting=<optimized out>)
    at /home/halla/dev/krita/libs/ui/KisImportExportManager.cpp:376
#13 0x00007ffff7c5158b in KisImportExportManager::importDocument (this=this@entry=0x555559bc2940, location=..., 
    mimeType=...) at /home/halla/dev/krita/libs/global/kis_shared_ptr.h:206
#14 0x00007ffff7c36065 in KisDocument::openFile (this=0x555559406b20)
    at /home/halla/dev/krita/libs/ui/KisDocument.cpp:1860
#15 0x00007ffff7c36ad9 in KisDocument::openPathInternal (this=0x555559406b20, path=...)
    at /home/halla/dev/krita/libs/ui/KisDocument.cpp:2416
#16 0x00007ffff7c3c2d9 in KisDocument::openPath (this=this@entry=0x555559406b20, _path=..., flags=..., 
    flags@entry=...) at /home/halla/dev/krita/libs/ui/KisDocument.cpp:1796
#17 0x00007ffff7c60045 in KisMainWindow::openDocumentInternal (this=<optimized out>, path=..., flags=...)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:1024
#18 0x00007ffff7c6063d in KisMainWindow::openDocument (this=0x555557945270, path=..., flags=...)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:998
#19 0x00007ffff7c60a75 in KisMainWindow::slotFileOpen (this=0x555557945270, isImporting=false)
    at /home/halla/dev/krita/libs/ui/KisMainWindow.cpp:1637
#20 0x00007ffff59cb0f0 in QMetaObject::activate(QObject*, int, int, void**) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#21 0x00007ffff63cfa36 in QAction::triggered(bool) () from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#22 0x00007ffff63d20f2 in QAction::activate(QAction::ActionEvent) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#23 0x00007ffff63d29bf in QAction::event(QEvent*) () from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#24 0x00007ffff63d60d6 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#25 0x00007ffff63df5d0 in QApplication::notify(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Widgets.so.5
#26 0x00007ffff7c1c7c5 in KisApplication::notify (this=0x7fffffffd570, receiver=0x555559d4d320, 
    event=0x7fffffffce40) at /home/halla/dev/krita/libs/ui/KisApplication.cpp:761
#27 0x00007ffff599f6ea in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#28 0x00007ffff5dbb93e in QShortcutMap::dispatchEvent(QKeyEvent*) ()
--Type <RET> for more, q to quit, c to continue without paging-- 
   from /home/halla/dev/deps/lib/libQt5Gui.so.5
#29 0x00007ffff5dbba23 in QShortcutMap::tryShortcut(QKeyEvent*) () from /home/halla/dev/deps/lib/libQt5Gui.so.5
#30 0x00007ffff5d6fcf3 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) ()
   from /home/halla/dev/deps/lib/libQt5Gui.so.5
#31 0x00007ffff5d8d231 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) ()
   from /home/halla/dev/deps/lib/libQt5Gui.so.5
#32 0x00007ffff5d928d1 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /home/halla/dev/deps/lib/libQt5Gui.so.5
#33 0x00007ffff5d6c97c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>)
    () from /home/halla/dev/deps/lib/libQt5Gui.so.5
#34 0x00007fffefeaa54e in ?? () from /home/halla/dev/deps/lib/libQt5XcbQpa.so.5
#35 0x00007ffff2ce217d in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007ffff2ce2400 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007ffff2ce24a3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#38 0x00007ffff59f7635 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#39 0x00007ffff599e29b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /home/halla/dev/deps/lib/libQt5Core.so.5
#40 0x00007ffff59a5ff6 in QCoreApplication::exec() () from /home/halla/dev/deps/lib/libQt5Core.so.5
#41 0x000055555555dd5b in main (argc=<optimized ou
Comment 2 Halla Rempt 2022-07-01 09:55:52 UTC
After unzipping and removing the file layer, I can load the file, but right-clicking on the frame group layer doesn't lead to a crash anymore.
Comment 3 David REVOY 2022-07-01 12:49:36 UTC
Thank you. 

> [...] removing the file layer, I can load the file [...]

Here I can still open the file with 5.1(beta1)appimage even after moving it to another directory (I'm prompted for the missing 'txt' layer too but I can skip it). So, if you couldn't open this one, it might be another issue about reading missing file layer.

> but right-clicking on the frame group layer doesn't lead to a crash anymore.

Good, maybe this right-click menu crash issue is fixed then in Git~master. I'll try to test it with a recent build too.
Comment 4 Dmitry Kazakov 2022-07-11 08:37:21 UTC
I can reproduce the crash, but only on Linux, because it requires KRITA_DEVS build to active Q_ASSERT checks.
Comment 5 Dmitry Kazakov 2022-07-11 08:58:02 UTC
Git commit ccfda933bbceba8dd1b9bf992c7433561fb382ba by Dmitry Kazakov.
Committed on 11/07/2022 at 08:57.
Pushed by dkazakov into branch 'master'.

Fix an assert when a graya file layer fails to load its image

The fallback color space for a file layer used to be the image's
color space, which caused an qssert when trying to load graya
channel flags.

M  +2    -2    libs/ui/kis_file_layer.cpp
M  +1    -1    libs/ui/kis_file_layer.h
M  +3    -3    plugins/impex/libkra/kis_kra_loader.cpp
M  +1    -1    plugins/impex/libkra/kis_kra_loader.h

https://invent.kde.org/graphics/krita/commit/ccfda933bbceba8dd1b9bf992c7433561fb382ba
Comment 6 Dmitry Kazakov 2022-07-11 08:59:15 UTC
Git commit fd924d7c03ce5409e5e0df9ae15b8991dd3cae8c by Dmitry Kazakov.
Committed on 11/07/2022 at 08:59.
Pushed by dkazakov into branch 'krita/5.1'.

Fix an assert when a graya file layer fails to load its image

The fallback color space for a file layer used to be the image's
color space, which caused an qssert when trying to load graya
channel flags.

M  +2    -2    libs/ui/kis_file_layer.cpp
M  +1    -1    libs/ui/kis_file_layer.h
M  +3    -3    plugins/impex/libkra/kis_kra_loader.cpp
M  +1    -1    plugins/impex/libkra/kis_kra_loader.h

https://invent.kde.org/graphics/krita/commit/fd924d7c03ce5409e5e0df9ae15b8991dd3cae8c
Comment 7 Dmitry Kazakov 2022-07-11 08:59:53 UTC
Hi, David!

Please check if you can still reproduce the click-crash in the current master. I have fixed the assert that Halla experienced, but I couldn't reproduce the original click-crash.
Comment 8 David REVOY 2022-07-12 10:21:53 UTC
Hi Dmitry,
I updated the last appimage nightly stable an hour ago, and I can still reproduce.  But it is worst now: right clicking on "Frame" layer freeze my whole Plasma desktop. The only escape I have is to Ctrl+Alt+F3 and login and type 'sudo reboot now'. I tried twice and get twice the same behavior. I'll try again now with vanilla default settings.
Comment 9 David REVOY 2022-07-12 10:26:43 UTC
Same system freeze with vanilla default. I tried to put the terminal with gdb on the second screen, but nothing unusual appears in it before the freeze.
Comment 10 David REVOY 2022-07-12 12:53:13 UTC
Created attachment 150554 [details]
^ gdb output of the crash, compressed as zip because it was too big

@Dmitry: Thanks to your instruction on IRC, I could catch a hu~~~uge 6.4MB output of gdb. Very verbose.

I attached it to this bug report, but I decided to compress it on a zip (it shrank to 170KB, better disk space usage for bugs.kde.admin). I hope you'll find good quality information in it.
Comment 11 Dmitry Kazakov 2022-07-12 13:35:46 UTC
Git commit d20876ddb9dc872e0d82e0096c409e96e8d0d705 by Dmitry Kazakov.
Committed on 12/07/2022 at 13:35.
Pushed by dkazakov into branch 'krita/5.1'.

Fix an infinite recursion in the color label selector

The size of the spacer should be changed not in resizeEvent()
(which causes an infinite recursion), but in showEvent(), right
before the widget is displayed to the user

M  +3    -16   libs/ui/widgets/kis_color_label_selector_widget.cpp
M  +1    -2    libs/ui/widgets/kis_color_label_selector_widget.h

https://invent.kde.org/graphics/krita/commit/d20876ddb9dc872e0d82e0096c409e96e8d0d705
Comment 12 Dmitry Kazakov 2022-07-12 13:38:50 UTC
Git commit c94c87e9c11c59ae15fc0e69198c0fcf49aff743 by Dmitry Kazakov.
Committed on 12/07/2022 at 13:38.
Pushed by dkazakov into branch 'master'.

Fix an infinite recursion in the color label selector

The size of the spacer should be changed not in resizeEvent()
(which causes an infinite recursion), but in showEvent(), right
before the widget is displayed to the user

M  +3    -16   libs/ui/widgets/kis_color_label_selector_widget.cpp
M  +1    -2    libs/ui/widgets/kis_color_label_selector_widget.h

https://invent.kde.org/graphics/krita/commit/c94c87e9c11c59ae15fc0e69198c0fcf49aff743
Comment 13 David REVOY 2022-07-12 14:16:49 UTC
Thank you @Dmitry, I tested the appimage from the nightly stable and I confirm: **the bug is fixed** 🎉
(I'll keep the gdb receipe somewhere to report future crashes with details).