Bug 475562 - krita segfaults on start after displaying the splash screen
Summary: krita segfaults on start after displaying the splash screen
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: General (other bugs)
Version First Reported In: 5.2.0
Platform: Exherbo Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-13 11:26 UTC by Timo Gurr
Modified: 2023-10-30 15:05 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
krita-20231013-132223.kcrash (1.58 KB, text/vnd.kde.kcrash-report)
2023-10-13 11:26 UTC, Timo Gurr
Details
krita-5.2.0-coredump.txt (26.91 KB, text/plain)
2023-10-13 11:26 UTC, Timo Gurr
Details
krita-20231014-004649.kcrash (1.58 KB, text/vnd.kde.kcrash-report)
2023-10-13 22:50 UTC, Timo Gurr
Details
krita-20231016-085327.kcrash (2.68 KB, text/vnd.kde.kcrash-report)
2023-10-16 06:56 UTC, Timo Gurr
Details
krita-5.2.0-installed-files.txt (112.59 KB, text/plain)
2023-10-17 14:59 UTC, Timo Gurr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Gurr 2023-10-13 11:26:18 UTC
Created attachment 162272 [details]
krita-20231013-132223.kcrash

SUMMARY
Krita crashes right on start just after displaying the splash screen. 

STEPS TO REPRODUCE
1.  Compile Krita 5.2.0
2.  Try to run it

OBSERVED RESULT
Segfault

EXPECTED RESULT
No segfault

SOFTWARE/OS VERSIONS
Operating System: Exherbo 
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.5 (64-bit)
Graphics Platform: X11
Processors: 12 × 12th Gen Intel® Core™ i5-12500
Memory: 15.3 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 770

ADDITIONAL INFORMATION
Used CMake options during build

cmake -DCMAKE_BUILD_TYPE:STRING=None -DCMAKE_C_FLAGS:STRING=-march=native -O2 -pipe -DNDEBUG -DQT_NO_DEBUG -DCMAKE_CXX_FLAGS:STRING=-march=native -O2 -pipe -DNDEBUG -DQT_NO_DEBUG -DCMAKE_AR:PATH=x86_64-pc-linux-gnu-ar -DCMAKE_RANLIB:PATH=x86_64-pc-linux-gnu-ranlib -DCMAKE_NM:PATH=x86_64-pc-linux-gnu-nm -DCMAKE_C_COMPILER:PATH=x86_64-pc-linux-gnu-cc -DCMAKE_CXX_COMPILER:PATH=x86_64-pc-linux-gnu-c++ -DCMAKE_INSTALL_PREFIX:PATH=/usr/x86_64-pc-linux-gnu -DCMAKE_FIND_ROOT_PATH:PATH=/usr/x86_64-pc-linux-gnu -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM:STRING=NEVER -DCMAKE_SYSTEM_PREFIX_PATH:PATH=/usr/x86_64-pc-linux-gnu -DCMAKE_INSTALL_LIBDIR:STRING=lib -DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share/ -DBUILD_COVERAGE:BOOL=FALSE -DBUILD_KRITA_QT_DESIGNER_PLUGINS:BOOL=FALSE -DBUILD_SHARED_LIBS:BOOL=TRUE -DCMAKE_DISABLE_FIND_PACKAGE_KSeExpr:BOOL=TRUE -DCMAKE_DISABLE_FIND_PACKAGE_LibMyPaint:BOOL=TRUE -DCRASH_ON_SAFE_ASSERTS:BOOL=FALSE -DDISABLE_PO_INSTALLATION:BOOL=FALSE -DENABLE_BSYMBOLICFUNCTIONS:BOOL=FALSE -DENABLE_CPU_THROTTLE:BOOL=FALSE -DENABLE_UPDATERS:BOOL=FALSE -DHAVE_BACKTRACE_SUPPORT:BOOL=FALSE -DHAVE_MEMORY_LEAK_TRACKER:BOOL=FALSE -DHIDE_SAFE_ASSERTS:BOOL=TRUE -DINSTALL_BENCHMARKS:BOOL=FALSE -DKRITA_ENABLE_BROKEN_TESTS:BOOL=FALSE -DKRITA_ENABLE_PCH:BOOL=TRUE -DLIMIT_LONG_TESTS:BOOL=TRUE -DUSE_EXTERNAL_RAQM:BOOL=FALSE -DUSE_LOCK_FREE_HASH_TABLE:BOOL=TRUE -DFOUNDATION_BUILD:BOOL=FALSE -DKRITA_DEVS:BOOL=FALSE -DBUILD_SHARED_LIBS:BOOL=TRUE -DKDE_INSTALL_AUTOSTARTDIR=/etc/xdg/autostart -DKDE_INSTALL_CONFDIR=/etc/xdg -DKDE_INSTALL_DATAROOTDIR:PATH=/usr/share -DKDE_INSTALL_LIBEXECDIR=libexec -DKDE_INSTALL_SYSCONFDIR=/etc -DKDE_INSTALL_USE_QT_SYS_PATHS:BOOL=TRUE -DQT_MAJOR_VERSION=5 -DCMAKE_DISABLE_FIND_PACKAGE_FFTW3:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_OpenColorIO:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_HEIF:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_OpenJPEG:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_JPEGXL:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_OpenEXR:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_Poppler:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_libjpeg-turbo:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_PythonLibrary:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_SIP:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_PyQt5:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_KF5KDcraw:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_Mlt7:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_SDL2:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_xsimd:BOOL=FALSE -DCMAKE_DISABLE_FIND_PACKAGE_WebP:BOOL=FALSE -DBUILD_TESTING:BOOL=FALSE /var/tmp/paludis/build/media-gfx-krita-5.2.0/work/krita-5.2.0
Comment 1 Timo Gurr 2023-10-13 11:26:32 UTC
Created attachment 162273 [details]
krita-5.2.0-coredump.txt
Comment 2 Halla Rempt 2023-10-13 11:34:52 UTC
Well, this is of course not a general problem, so something must have gone wrong with the way krita is built -- or maybe there is both a self-built krita and a system krita present?
Comment 3 Timo Gurr 2023-10-13 11:39:18 UTC
Only one krita present on the system. Exherbo is a source-based distribution like Gentoo.
Comment 4 Halla Rempt 2023-10-13 11:58:47 UTC
I'm afraid you'll have to investigate this yourself. It (obviously) doesn't happen for any of us developers, so it's either a build problem, a problem with dependencies or something else, even weirder.
Comment 5 Timo Gurr 2023-10-13 12:06:55 UTC
Thanks for your comments. Just for reference this pretty much happens to us with every new krita version and usually the problems in the past have not really been on our side:

https://bugs.kde.org/show_bug.cgi?id=445276
https://bugs.kde.org/show_bug.cgi?id=445285
https://bugs.kde.org/show_bug.cgi?id=445329
https://bugs.kde.org/show_bug.cgi?id=447597
Comment 6 Halla Rempt 2023-10-13 13:35:06 UTC
I know... But even so, there isn't much testing we can do, since it doesn't happen elsewhere. The only guess I can make is that this patch might help, but I cannot test it:

diff --git a/libs/widgets/KisVisualColorModel.cpp b/libs/widgets/KisVisualColorModel.cpp
index 943eb0a93a..d9d6206031 100644
--- a/libs/widgets/KisVisualColorModel.cpp
+++ b/libs/widgets/KisVisualColorModel.cpp
@@ -78,6 +78,8 @@ void KisVisualColorModel::slotSetColor(const KoColor &c)
 
 void KisVisualColorModel::slotSetColorSpace(const KoColorSpace *cs)
 {
+    if (!cs) return;
+
     if (!m_d->currentCS || *m_d->currentCS != *cs) {
         const KoColorSpace *csNew = cs;
Comment 7 Timo Gurr 2023-10-13 22:49:57 UTC
(In reply to Halla Rempt from comment #6)
> I know... But even so, there isn't much testing we can do, since it doesn't
> happen elsewhere. The only guess I can make is that this patch might help,
> but I cannot test it:
> 
> diff --git a/libs/widgets/KisVisualColorModel.cpp
> b/libs/widgets/KisVisualColorModel.cpp
> index 943eb0a93a..d9d6206031 100644
> --- a/libs/widgets/KisVisualColorModel.cpp
> +++ b/libs/widgets/KisVisualColorModel.cpp
> @@ -78,6 +78,8 @@ void KisVisualColorModel::slotSetColor(const KoColor &c)
>  
>  void KisVisualColorModel::slotSetColorSpace(const KoColorSpace *cs)
>  {
> +    if (!cs) return;
> +
>      if (!m_d->currentCS || *m_d->currentCS != *cs) {
>          const KoColorSpace *csNew = cs;

Thanks for helping to get this resolved. I'm afraid it still segfaults right away with the patch applied, the kcrash looks basically identical, attaching it anyways.
Comment 8 Timo Gurr 2023-10-13 22:50:15 UTC
Created attachment 162284 [details]
krita-20231014-004649.kcrash
Comment 9 Bug Janitor Service 2023-10-14 03:46:17 UTC
Thanks for your comment!

Automatically switching the status of this bug to REPORTED so that the KDE team
knows that the bug is ready to get confirmed.

In the future you may also do this yourself when providing needed information.
Comment 10 Halla Rempt 2023-10-14 07:42:27 UTC
it would be helpful if the backtrace would include line numbers :)
Comment 11 Timo Gurr 2023-10-14 16:40:14 UTC
(In reply to Halla Rempt from comment #10)
> it would be helpful if the backtrace would include line numbers :)

Is it possible to automatically get them included in the debug output and if so can you please advice how to do that? I'm not that familiar with debugging stuff and while the kcrash is automatically created the commands for coredump are ones that I noted quite a while ago:

# coredumpctl list
# echo "thr a a bt full" | coredumpctl gdb <PID>
Comment 12 Halla Rempt 2023-10-15 10:37:23 UTC
That's dependent on the distribution... You probably need to configure something that prevents stripping out debug info.
Comment 13 Timo Gurr 2023-10-16 06:55:51 UTC
(In reply to Halla Rempt from comment #12)
> That's dependent on the distribution... You probably need to configure
> something that prevents stripping out debug info.

Turns out that -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo instead of None did the trick, attaching a kcrash including the requested line numbers.
Comment 14 Timo Gurr 2023-10-16 06:56:19 UTC
Created attachment 162343 [details]
krita-20231016-085327.kcrash
Comment 15 Lynx3d 2023-10-17 14:50:34 UTC
hm the crashing line is:
> cs->profile()->uniqueId() == KoColorSpaceRegistry::instance()->p2020PQProfile()->uniqueId()) {

That suggests the p2020PQProfile is not available, which should be part of a correct installation.
Nevertheless, I guess there needs to be a nullptr check, I wasn't aware this function depends on the presence of a .icc file and thus can fail to return a valid profile.
Comment 16 Timo Gurr 2023-10-17 14:59:35 UTC
Created attachment 162374 [details]
krita-5.2.0-installed-files.txt

(In reply to Lynx3d from comment #15)
> hm the crashing line is:
> > cs->profile()->uniqueId() == KoColorSpaceRegistry::instance()->p2020PQProfile()->uniqueId()) {
> 
> That suggests the p2020PQProfile is not available, which should be part of a correct installation.

Can you please name the file I have to check for to verify something is actually missing or not correctly installed? Attaching a full list of installed files.
Comment 17 Lynx3d 2023-10-17 18:58:25 UTC
The file is 'ITUR_2100_PQ_FULL.ICC' and has the verbose descriptive name "High Dynamic Range UHDTV Wide Color Gamut Display (Rec. 2020) - SMPTE ST 2084 PQ EOTF"
It should be in: <INSTALL_PREFIX>/share/color/icc/krita/
I don't have a complete list of installed files for 5.2.0 at hand, it'd be quite long anyway...
Comment 18 Timo Gurr 2023-10-18 09:50:07 UTC
(In reply to Lynx3d from comment #17)
> The file is 'ITUR_2100_PQ_FULL.ICC' 
> It should be in: <INSTALL_PREFIX>/share/color/icc/krita/

Thanks for the information, as you can see from my attached full list above I do have the file in

/usr/share/color/icc/krita/ITUR_2100_PQ_FULL.ICC

however strace shows the path is missing from kritas search path locations as it does search in e.g. /usr/share/krita/color/icc but not /usr/share/color/icc/krita. As "../share" does not work for our cross setup as we have arch-independent stuff in /usr/share, but arch-depedendent stuff installed to prefix /usr/<arch>.

As I can see e.g. /usr/share/krita//color/icc in addition to ../share/krita//color/icc/ I hope the missing /usr/share/color/icc search path can be added as another alternative for ../share//color/icc as well.

statx(AT_FDCWD, "/home/domain/user/.local/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
statx(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
statx(AT_FDCWD, "/home/domain/user/.local/share/flatpak/exports/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
statx(AT_FDCWD, "/var/lib/flatpak/exports/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
statx(AT_FDCWD, "/usr/local/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
statx(AT_FDCWD, "/usr/share/krita//color/icc", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT, STATX_ALL, 0x7ffd8d398580) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
openat(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/bin/../share//color/icc/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
openat(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/bin/../share//color/icc/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
openat(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/bin/../share/krita//color/icc/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
openat(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/bin/../share/krita//color/icc/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
openat(AT_FDCWD, "/usr/x86_64-pc-linux-gnu/bin/../share/.", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 35

For testing as a workaround I created a symlink 

# mkdir -p /usr/x86_64-pc-linux-gnu/share/
# ln -s /usr/share/color /usr/x86_64-pc-linux-gnu/share/color

and krita is able to successfully launch without crashing.
Comment 19 Timo Gurr 2023-10-19 11:10:01 UTC
I was able to workaround this downstream by applying:

diff -Naur krita-5.2.0/libs/resources/KoResourcePaths.cpp krita-5.2.0.new/libs/resources/KoResourcePaths.cpp
--- krita-5.2.0/libs/resources/KoResourcePaths.cpp	2023-10-04 10:06:16.000000000 +0200
+++ krita-5.2.0.new/libs/resources/KoResourcePaths.cpp	2023-10-19 12:36:59.478727217 +0200
@@ -145,7 +145,7 @@
     // NOTE the subscript [1]. It points to the internal location.
     return QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)[1] + "/";
 #else
-    return qApp->applicationDirPath() + "/../";
+    return qApp->applicationDirPath() + "/../../";
 #endif
 }
 
Additionally we have to patch the search paths on different other iterations:

diff -Naur krita-5.0.2/libs/libqml/Theme.cpp krita-5.0.2.new/libs/libqml/Theme.cpp
--- krita-5.0.2/libs/libqml/Theme.cpp	2022-01-05 12:03:09.000000000 +0100
+++ krita-5.0.2.new/libs/libqml/Theme.cpp	2022-03-08 16:13:27.390969897 +0100
@@ -347,7 +347,7 @@
     QString qml = QStandardPaths::locate(QStandardPaths::AppDataLocation,
                                          QString("krita/qmlthemes/%1/theme.qml").arg(id));
     if (qml.isEmpty()) {
-            qml = KoResourcePaths::getApplicationRoot() + QString("/share/krita/qmlthemes/%1/theme.qml").arg(id);
+            qml = QString("/usr/share/krita/qmlthemes/%1/theme.qml").arg(id);
     }
     return qml;
 }
diff -Naur krita-5.0.2/libs/ui/KisApplication.cpp krita-5.0.2.new/libs/ui/KisApplication.cpp
--- krita-5.0.2/libs/ui/KisApplication.cpp	2022-01-05 12:03:09.000000000 +0100
+++ krita-5.0.2.new/libs/ui/KisApplication.cpp	2022-03-08 16:17:08.585457533 +0100
@@ -368,7 +368,7 @@
         QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita: Fatal error"), i18n("%1\n\nKrita will quit now.", KisResourceCacheDb::lastError()));
     }
 
-    KisResourceLocator::LocatorError r = KisResourceLocator::instance()->initialize(KoResourcePaths::getApplicationRoot() + "/share/krita");
+    KisResourceLocator::LocatorError r = KisResourceLocator::instance()->initialize("/usr/share/krita");
     connect(KisResourceLocator::instance(), SIGNAL(progressMessage(const QString&)), this, SLOT(setSplashScreenLoadingText(const QString&)));
     if (r != KisResourceLocator::LocatorError::Ok && qApp->inherits("KisApplication")) {
         QMessageBox::critical(qApp->activeWindow(), i18nc("@title:window", "Krita: Fatal error"), KisResourceLocator::instance()->errorMessages().join('\n') + i18n("\n\nKrita will quit now."));

Anyhow feel free to close this issue as the whole search path problem with our Exherbo multiarch/cross layout with arch-independent stuff in /usr/share, but arch-depedendent stuff installed to prefix /usr/<arch> and a solution for this should probably be a separate more general bugreport.
Comment 20 Lynx3d 2023-10-21 20:43:21 UTC
Git commit 01b70545968e1c0b01d738b8e32de69cacff89c1 by Mathias Wein.
Committed on 21/10/2023 at 22:41.
Pushed by mwein into branch 'master'.

Prevent a crash when a default profile is missing

KoColorSpaceRegistry::instance()->p2020PQProfile() will return null
if the file providing it cannot be found for whatever reason.

M  +3    -2    libs/widgets/KisVisualColorModel.cpp

https://invent.kde.org/graphics/krita/-/commit/01b70545968e1c0b01d738b8e32de69cacff89c1
Comment 21 Lynx3d 2023-10-21 20:51:22 UTC
Git commit 737a640d6765424870f6df7ccec9db0b08d53e88 by Mathias Wein.
Committed on 21/10/2023 at 22:51.
Pushed by mwein into branch 'krita/5.2'.

Prevent a crash when a default profile is missing

KoColorSpaceRegistry::instance()->p2020PQProfile() will return null
if the file providing it cannot be found for whatever reason.


(cherry picked from commit 01b70545968e1c0b01d738b8e32de69cacff89c1)

M  +3    -2    libs/widgets/KisVisualColorModel.cpp

https://invent.kde.org/graphics/krita/-/commit/737a640d6765424870f6df7ccec9db0b08d53e88
Comment 22 Halla Rempt 2023-10-30 15:05:59 UTC
I guess we also need to figure out why KoResourcePaths::getApplicationRoot()  doesn't work on this distribution.