Bug 421363 - Transform to tiny size causes Krita to crash to desktop
Summary: Transform to tiny size causes Krita to crash to desktop
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools/Transform (show other bugs)
Version: 4.3.0-beta1
Platform: Microsoft Windows Microsoft Windows
: NOR crash
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-11 19:57 UTC by lethal.logan
Modified: 2021-03-25 21:31 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Crash log (20.92 KB, text/plain)
2020-05-11 19:57 UTC, lethal.logan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lethal.logan 2020-05-11 19:57:47 UTC
Created attachment 128372 [details]
Crash log

SUMMARY
Transform drawing to tiny size causes Krita to crash to desktop. I realise this is probably quite an edge case, but it is a 100% reproducible crash which could cause an artist to lose their progress on an artwork if they ever trigger it.

STEPS TO REPRODUCE
1. Draw something (even a single line)
2. Use the transform tool to shrink it down as small as possible
3. Press Enter to apply the transformation

OBSERVED RESULT
Krita will attempt to apply transform and will crash to the desktop

EXPECTED RESULT
Transform tool should resize the drawing without Krita crashing

SOFTWARE/OS VERSIONS
Windows: Windows 10 64-bit 1909
Crash occurs in Krita 4.2.9 stable and 4.3.0 beta 1

ADDITIONAL INFORMATION
krita.exe caused an Integer division by zero at location 00007FFCB9EB7D2A in module libkritaimage.dll.
Comment 1 David REVOY 2020-05-11 20:42:09 UTC
Good one! I can reproduce this one easily on 4.3beta appimage on Kubuntu Linux. I'm switching it to confirmed.
Comment 2 Halla Rempt 2020-05-14 08:02:21 UTC
This doesn't seem to crash in GDB... And the crash handler doesn't seem to like this crash, but I can reproduce it too.
Comment 3 sh_zam 2021-03-25 19:20:13 UTC
Hello!

I looked into this and our 8 bit KisFixedPoint representation fails to map values lesser than 1 >> 8 which it gets from KisFilterWeightsBuffer. The trivial solution I came up with is below. It works fine and doesn't seem to cause problems. But I'm not sure if this is the right place for this guard. Halla or Dmitry would probably know?

diff --git a/libs/image/kis_filter_weights_buffer.h b/libs/image/kis_filter_weights_buffer.h
index 4b649ba01c..26d64d66d0 100644
--- a/libs/image/kis_filter_weights_buffer.h
+++ b/libs/image/kis_filter_weights_buffer.h
@@ -154,7 +154,7 @@ public:
         KisFixedPoint supportSrc;
         KisFixedPoint supportDst;
 
-        if (realScale < 1.0) {
+        if (realScale < 1.0 && realScale > (1 >> 8)) {
             m_weightsPositionScale = KisFixedPoint(realScale);
             supportSrc.from256Frac(filterStrategy->intSupport(m_weightsPositionScale.toFloat()) / realScale);
             supportDst.from256Frac(filterStrategy->intSupport(m_weightsPositionScale.toFloat()));
Comment 4 Halla Rempt 2021-03-25 20:18:36 UTC
Yes, please commit.
Comment 5 sh_zam 2021-03-25 21:29:01 UTC
Git commit 47fa74d0320547fd4a46be1069466f10f7e15b8b by Sharaf Zaman.
Committed on 25/03/2021 at 21:27.
Pushed by szaman into branch 'master'.

Bugfix: Transform tool crash when scaled to a few pixels

M  +1    -1    libs/image/kis_filter_weights_buffer.h

https://invent.kde.org/graphics/krita/commit/47fa74d0320547fd4a46be1069466f10f7e15b8b
Comment 6 sh_zam 2021-03-25 21:31:34 UTC
small correction to my previous statement. Less than 1.0 / (1 << 8). My brain somehow thought that the inverse of 1 << 8 is 1 >> 8 :)