Bug 384587 - loop in clone layers makes it impossible to load a .kra file
Summary: loop in clone layers makes it impossible to load a .kra file
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 3.2.1
Platform: Appimage Linux
: NOR critical
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-11 08:40 UTC by Larpon
Modified: 2018-04-03 11:47 UTC (History)
2 users (show)

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


Attachments
Troublesome file - makes Krita spin up CPU and takes forever to load (1.39 MB, application/x-7z-compressed)
2017-09-11 08:40 UTC, Larpon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Larpon 2017-09-11 08:40:06 UTC
Created attachment 107795 [details]
Troublesome file - makes Krita spin up CPU and takes forever to load

Attached file makes Krita load forever. The file was saved normally - but Krita crashed between sessions.

Same symptoms on these versions:
3.2.1
3.1.4
4.0.0 pre-alpha
Comment 1 Halla Rempt 2017-09-11 08:44:55 UTC
I can confirm the issue with this file.
Comment 2 Larpon 2017-09-11 10:01:10 UTC
Your suspicion about a clonelayer creating a dead-lock seem to be correct.
I've tried unzipping the .kra and editing the maindoc.xml.
Removing the "pose export" layer block starting on line 270 - and zipping it back up - will let Krita load it again.
Comment 3 Larpon 2017-09-11 10:11:34 UTC
The following "leg r" clone layer block from the attached file seems to be the culprit:

<layer collapsed="1" y="-251" colorlabel="0" name="leg r" compositeop="normal" channelflags="" opacity="255" uuid="{8d999277-25cc-47a1-ba02-40ab6cf17e68}" locked="0" clonefrom="leg" nodetype="clonelayer" filename="layer146" clonetype="0" visible="1" clonefromuuid="{c35dcb55-c5c5-47a0-8a15-56dae3654b8b}" x="-239">
        <masks>
         <mask y="250" name="Transform Mask 1" uuid="{1026da29-b104-480c-8c6e-a4599aea992b}" locked="0" nodetype="transformmask" filename="mask147" visible="1" x="-67"/>
        </masks>
       </layer>
Comment 4 Dmitry Kazakov 2018-03-27 12:32:52 UTC
Git commit ae1d6fcdd4f8b269d5cbcd95c42d8dcebe90b247 by Dmitry Kazakov.
Committed on 27/03/2018 at 12:32.
Pushed by dkazakov into branch 'master'.

Do not try to infinitely iterate through all the pixels of the device if its extent is empty

For historical reasons we use weird format for "empty extent" mark,
the rectangle is set to QRect(-int32max, -int32max, 0, 0). Using
such mark is a bit of dangerous, because mere operating with it
causes integer overflow and, therefore, infinite loop. I'm not sure
if it is safe to change this mark into standard Qt's one...

M  +4    -0    libs/image/kis_paint_device.cc

https://commits.kde.org/krita/ae1d6fcdd4f8b269d5cbcd95c42d8dcebe90b247
Comment 5 Halla Rempt 2018-04-03 11:47:21 UTC
Git commit 4f11b96603d7d2c43600dcf62ee4c7db506443f1 by Boudewijn Rempt, on behalf of Dmitry Kazakov.
Committed on 03/04/2018 at 11:16.
Pushed by rempt into branch 'krita/4.0'.

Do not try to infinitely iterate through all the pixels of the device if its extent is empty

For historical reasons we use weird format for "empty extent" mark,
the rectangle is set to QRect(-int32max, -int32max, 0, 0). Using
such mark is a bit of dangerous, because mere operating with it
causes integer overflow and, therefore, infinite loop. I'm not sure
if it is safe to change this mark into standard Qt's one...
(cherry picked from commit ae1d6fcdd4f8b269d5cbcd95c42d8dcebe90b247)

M  +4    -0    libs/image/kis_paint_device.cc

https://commits.kde.org/krita/4f11b96603d7d2c43600dcf62ee4c7db506443f1