Bug 439145

Summary: opening an svg file fills the memory up
Product: [Applications] krita Reporter: to.213692
Component: File formatsAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: ahab.greybeard, halla, shzam
Priority: NOR Keywords: triaged
Version: 4.4.3   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: The svg file that causes the memory problem

Description to.213692 2021-06-25 08:46:05 UTC
Created attachment 139654 [details]
The svg file that causes the memory problem

SUMMARY

I wanted to open an svg file today but it required 15GB of memory, which then froze my computer forever.

This doesn't happen for all svgs.


STEPS TO REPRODUCE
1. open the attached svg
2. wait
3. freezes

OBSERVED RESULT

RAM fills up until earlyoom stops krita


EXPECTED RESULT

svg opens. It works in gimp


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Xubuntu 21.04
Qt Version: 5.15.2

ADDITIONAL INFORMATION

svg attached
Comment 1 sh_zam 2021-08-04 12:11:33 UTC
Hello. I can't reproduce the OOM. But it seems the rendering isn't correct. 

I tested this in multiple programs, browsers, GIMP are able to render it correctly. But Krita and Inkscape seem to fail even after tweaking the SVG file.
Comment 2 to.213692 2021-08-05 09:03:32 UTC
I can still reproduce it. Is there any log I could generate?

The original file (that also caused the memory problem) used to contain stuff that should not be shown to the public, so I opened it in a text editor and removed a bunch of numbers and found that it still opens in my browser and still causes the same memory leak.
Comment 3 Ahab Greybeard 2021-08-07 21:29:07 UTC
I don't have a problem opening this test.svg file in Inkscape and GIMP and in Krita with the Aug 04 5.0.0-prealpha (git 3dc6b64) and the 4.4.5 appimages on Debian 10.

GIMP clearly shows naked paths extending far outside the view box.
Inkscape does not show any indication of those 'strange' paths.
Krita does show colouring in of those paths.

Maybe the .svg file was malformed from the start ?

This was reported for version 4.4.3 from Ubuntu packages.

@to.213692  Can you try it with the version 4.4.5 appimage?
Comment 4 to.213692 2021-08-08 00:10:01 UTC
I can reproduce the OOM on a different computer with Manjaro running Krita 4.4.5-3
Comment 5 Bug Janitor Service 2021-08-08 04:36:09 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 6 Ahab Greybeard 2021-08-08 06:56:26 UTC
@to.213692 Is "4.4.5-3" from Manjaro packages?
Can you try it with the 4.4.5 appimage?
Comment 7 to.213692 2021-08-08 10:46:13 UTC
yes, it's from the manjaro repo.

the appimage with the same version does not cause the OOM

Maybe there is a dependency that is working in the appimage but sometimes broken in installations from repositories?
Comment 8 Halla Rempt 2021-08-10 07:44:07 UTC
Yeah, using a distro version of Krita is generally speaking a bad idea. We have over eighty patches to Qt, and the appimage still uses Qt 5.12, because newer versions of Qt are barely usable.
Comment 9 Bug Janitor Service 2022-07-26 06:37:54 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1532
Comment 10 sh_zam 2022-07-26 07:42:08 UTC
Git commit ac4afecd320ff029e3dddfab7e1b0a941ef141e9 by Sharaf Zaman.
Committed on 26/07/2022 at 07:41.
Pushed by szaman into branch 'master'.

Fix Elliptic Arc to Bezier curve function in SVG

To get rid of undefined behavior.
Related: bug 456922

M  +106  -98   libs/flake/KoPathShapeLoader.cpp

https://invent.kde.org/graphics/krita/commit/ac4afecd320ff029e3dddfab7e1b0a941ef141e9
Comment 11 sh_zam 2022-07-28 15:58:41 UTC
Git commit 07108aaa0d1e473b0b8c78347c2934d57dc8f497 by Sharaf Zaman.
Committed on 28/07/2022 at 15:55.
Pushed by szaman into branch 'krita/5.1'.

Fix Elliptic Arc to Bezier curve function in SVG

To get rid of undefined behavior.
Related: bug 456922
(cherry picked from commit ac4afecd320ff029e3dddfab7e1b0a941ef141e9)

M  +106  -98   libs/flake/KoPathShapeLoader.cpp

https://invent.kde.org/graphics/krita/commit/07108aaa0d1e473b0b8c78347c2934d57dc8f497