Bug 506291 - Krita crashes if you use the "Index Colors" filter and uncheck Bright, Light, and Base, but keep Shadow checked
Summary: Krita crashes if you use the "Index Colors" filter and uncheck Bright, Light,...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Filters (other bugs)
Version First Reported In: nightly build (please specify the git hash!)
Platform: Appimage Linux
: NOR crash
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2025-06-27 19:52 UTC by Noel Santos
Modified: 2025-07-16 08:25 UTC (History)
1 user (show)

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


Attachments
Krita crashing video (2.41 MB, video/quicktime)
2025-06-30 12:04 UTC, Noel Santos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noel Santos 2025-06-27 19:52:08 UTC
SUMMARY
Krita crashes if you use the Index Colors filter and uncheck Bright, Light, and Base, while Shadow remains checked.

STEPS TO REPRODUCE
1. Create a new document.
2. Filter -> Artistic -> Index colors.
3. Uncheck "Bright."
4. Uncheck "Light."
5. Uncheck "Base."

OBSERVED RESULT
Krita crashes.

EXPECTED RESULT
Krita not crashing.

SOFTWARE/OS VERSIONS
I'm on Linux Mint.

ADDITIONAL INFORMATION
If you uncheck Shadow first you can uncheck the rest without crashing.
Comment 1 Halla Rempt 2025-06-30 07:49:08 UTC
I'm sorry, but with 5.2.9 on Windows, I cannot reproduce the issue.
Comment 2 Noel Santos 2025-06-30 12:04:23 UTC
Created attachment 182798 [details]
Krita crashing video

I have attached a video of Krita crashing from this bug.
Comment 3 Noel Santos 2025-07-03 14:53:53 UTC
I managed to reproduce the bug on nightly, so I changed the version.

I have created a thread for this bug https://krita-artists.org/t/linux-mint-users-lets-try-crashing-krita-with-the-index-colors-filter/128334

A different Linux Mint user was unable to reproduce it, so I figured it was a problem in my machine.

I tried switching to a different user on Linux and in a different user I can't reproduce the bug anymore, which suggest this isn't a hardware-level issue but a user-level configuration or the state of the application that leads to the bug happening.

The same thing occurred in https://bugs.kde.org/show_bug.cgi?id=505986 in which I assume gradient overlay only crashes for me because I managed to make the gradient in the toolbar undefined somehow. I don't know if this is the condition to make index colors crash, and I don't know how I managed to make the gradient in the toolbar become empty, so I have no way to check if this is the reason why it crashes. If I ever figure out what made the gradient become empty in first place I'll try it.
Comment 4 Halla Rempt 2025-07-08 08:51:10 UTC
On a system where you can reproduce the crash, could you temporarily reset Krita's settings by moving .config/kritarc to .config/kritarc.bak and check whether it still happens? If it doesn't then we'd have to take a look at the broken kritarc file.
Comment 5 Noel Santos 2025-07-08 17:50:34 UTC
(In reply to Halla Rempt from comment #4)
> On a system where you can reproduce the crash, could you temporarily reset
> Krita's settings by moving .config/kritarc to .config/kritarc.bak and check
> whether it still happens? If it doesn't then we'd have to take a look at the
> broken kritarc file.

I did some testing and narrowed down the steps to reproduce the bug.

1. It happens even with the default kritarc
2. It happens even when the gradient is button is working normally
3. It doesn't happen if you apply the filter to a transparent layer
4. It happens when you apply the filter to the white background layer that is locked by default--you have to unlock it first, of course.
5. It doesn't happen if the background layer is black or red. I didn't test every color but it seems it only crashes with white background.
6. It doesn't need to be the background layer Krita creates for you, you can make a new paint layer, shift+backspace to fill it with white, and then it will crash.

Now I can reproduce it with any user on my machine. The reason I wasn't able to before was because by default Krita creates a white background layer and a transparent layer and the transparent layer was selected by default. Applying the filter to the white background layer crashes Krita.

Considering it only crashes with white background and not other colors, there's probably a bug in the index colors algorithm rather than on the UI.
Comment 6 Bug Janitor Service 2025-07-09 03:48:41 UTC
๐Ÿ›๐Ÿงน Thanks for your comment!

Automatically switching the status to REPORTED so the team can perform further triage.

In the future you may also do this yourself when providing needed information.
Comment 7 Halla Rempt 2025-07-10 08:37:12 UTC
Got it! There's an assert:

SAFE ASSERT (krita): "primaryColor >= 0" in file /home/appimage/persistent/krita/plugins/filters/indexcolors/indexcolorpalette.cpp, line 55


Thread 58 "Thread (pooled)" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff1effd700 (LWP 40654)]
tcache_get (tc_idx=<optimized out>) at malloc.c:2937
2937    malloc.c: No such file or directory.
(gdb) bt
#0  tcache_get (tc_idx=<optimized out>) at malloc.c:2937
#1  __GI___libc_malloc (bytes=59) at malloc.c:3051
#2  0x00007ffff546bac1 in QArrayData::allocate(unsigned long, unsigned long, unsigned long, QFlags<QArrayData::AllocationOption>) () from /home/appimage/appimage-workspace/deps/usr/lib/libQt5Core.so.5
#3  0x00007ffff54c55e6 in QByteArray::QByteArray(char const*, int) ()
   from /home/appimage/appimage-workspace/deps/usr/lib/libQt5Core.so.5
#4  0x00007ffff55d0d6e in QProcessEnvironment::systemEnvironment() ()
   from /home/appimage/appimage-workspace/deps/usr/lib/libQt5Core.so.5
#5  0x00007ffff6725d4f in kis_assert_common (assertion=<optimized out>, file=<optimized out>, 
    line=<optimized out>, abort=<optimized out>, isIgnorable=<optimized out>)
    at /home/appimage/persistent/krita/libs/global/kis_assert.cpp:54
#6  0x00007fffe002cf48 in IndexColorPalette::getNearestIndex (this=this@entry=0x7fff0c017288, clr=...)
    at /home/appimage/persistent/krita/plugins/filters/indexcolors/indexcolorpalette.cpp:55
#7  0x00007fffe0029964 in KisIndexColorTransformation::transform (this=0x7fff0c017270, 
    src=0x7ffefed8f080 '\377' <repeats 200 times>..., dst=0x7ffeff43f080 '\377' <repeats 200 times>..., 
    nPixels=35) at /home/appimage/persistent/krita/plugins/filters/indexcolors/indexcolors.cpp:122
#8  0x00007ffff6c146a6 in KisColorTransformationFilter::processImpl (this=<optimized out>, device=..., 
    applyRect=..., config=..., progressUpdater=<optimized out>)
    at /home/appimage/persistent/krita/libs/image/filter/kis_color_transformation_filter.cc:56
#9  0x00007ffff79205ae in operator() (__closure=0x7fff1801e5f0)
    at /home/appimage/persistent/krita/libs/ui/tool/strokes/kis_filter_stroke_strategy.cpp:257
#10 std::__invoke_impl<void, KisFilterStrokeStrategy::doStrokeCallback(KisStrokeJobData*)::<lambda()>::<lambda()>&> (__f=...) at /usr/include/c++/11/bits/invoke.h:61
#11 std::__invoke_r<void, KisFilterStrokeStrategy::doStrokeCallback(KisStrokeJobData*)::<lambda()>::<lambda()>&>
    (__fn=...) at /usr/include/c++/11/bits/invoke.h:111
#12 std::_Function_handler<void(), KisFilterStrokeStrategy::doStrokeCallback(KisStrokeJobData*)::<lambda()>::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/11/bits/std_function.h:290
#13 0x00007ffff6b1c920 in KisStrokeJob::run (this=<optimized out>)
    at /home/appimage/appimage-workspace/krita-build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../../persistent/krita/libs/image/kis_stroke_job.h:32
#14 KisUpdateJobItem::runImpl (this=0x555557e01340)
    at /home/appimage/appimage-workspace/krita-build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../../persistent/krita/libs/image/kis_update_job_item.h:100
#15 KisUpdateJobItem::run (this=0x555557e01340)
    at /home/appimage/appimage-workspace/krita-build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../../persistent/krita/libs/image/kis_update_job_item.h:49
#16 0x00007ffff5463562 in ?? () from /home/appimage/appimage-workspace/deps/usr/lib/libQt5Core.so.5
#17 0x00007ffff54602b3 in ?? () from /home/appimage/appimage-workspace/deps/usr/lib/libQt5Core.so.5
#18 0x00007ffff3f33609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#19 0x00007ffff5013353 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Comment 8 Halla Rempt 2025-07-10 10:25:18 UTC
I started https://invent.kde.org/graphics/krita/-/merge_requests/2425
Comment 9 Halla Rempt 2025-07-16 08:25:12 UTC
And it's merged.