Bug 447126 - [transparency mask] Crash after importing a picture as a "new layer" and then creating a "transparency mask" over it
Summary: [transparency mask] Crash after importing a picture as a "new layer" and then...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tile manager (other bugs)
Version First Reported In: nightly build (please specify the git hash!)
Platform: Appimage Linux
: NOR crash
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords: release_blocker
Depends on:
Blocks:
 
Reported: 2021-12-17 11:24 UTC by David REVOY
Modified: 2021-12-17 13:26 UTC (History)
1 user (show)

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


Attachments
Backtrace of the bug (36.74 KB, text/plain)
2021-12-17 11:24 UTC, David REVOY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David REVOY 2021-12-17 11:24:38 UTC
Created attachment 144622 [details]
Backtrace of the bug

Hi, it's a bug I discussed on IRC and where dmitryK built a appimage with ASAN for helping me to detect.

To reproduce:
===========
1. Open Krita, create a new document
2. Drag'n'drop an external jpg (or a kra, png) picture from file browser into the canvas , and choose → insert as a new layer.
3. Then right click on the layer of the imported picture and select on the menu: Add → Add a Transparency Mask.

Result:
======
A dialog appears: SAFE ASSERT (krita): "qAbs(row) < 0x7FFF && qAbs(col) < 0x7FFF" in file /home/appimage/persistent/krita/libs/image/tiles3/kis_tile_hash_table2.h, line 151 

It looks like that: https://www.peppercarrot.com/extras/temp/2021-12-17_screenshot_114756_net.jpg  

Info:
====
A backtrace is attached to this report and it's 100% reproducable. 
The appimage is 2021-12-17_krita-5.1.0-prealpha-7793838-ASAN-x86_64.appimage , from Krita git~master. It was tested in a vanilla new environment, Kubtuntu Linux 20.04LTS.
Comment 1 Dmitry Kazakov 2021-12-17 12:59:41 UTC
Git commit eae06ae046f65537c3a11577fa586ccf873ef7d1 by Dmitry Kazakov.
Committed on 17/12/2021 at 12:59.
Pushed by dkazakov into branch 'master'.

Fix a crash after D&D of a layer into Krita and adding a mask

The problem happened because the paint device of a pasted layer
belonged to two different images at the same time. And the temporary
image reset the image link during its destruction.

M  +11   -2    libs/image/kis_image.cc
M  +5    -2    libs/ui/kis_import_catcher.cc

https://invent.kde.org/graphics/krita/commit/eae06ae046f65537c3a11577fa586ccf873ef7d1
Comment 2 Dmitry Kazakov 2021-12-17 13:00:12 UTC
Git commit 042134137f7889cb019f6271f6657de7cd834078 by Dmitry Kazakov.
Committed on 17/12/2021 at 13:00.
Pushed by dkazakov into branch 'krita/5.0'.

Fix a crash after D&D of a layer into Krita and adding a mask

The problem happened because the paint device of a pasted layer
belonged to two different images at the same time. And the temporary
image reset the image link during its destruction.
(cherry picked from commit eae06ae046f65537c3a11577fa586ccf873ef7d1)

M  +11   -2    libs/image/kis_image.cc
M  +5    -2    libs/ui/kis_import_catcher.cc

https://invent.kde.org/graphics/krita/commit/042134137f7889cb019f6271f6657de7cd834078
Comment 3 Dmitry Kazakov 2021-12-17 13:09:17 UTC
Git commit cb39296cd45c18d5c3b532266a8fe93680933d6e by Dmitry Kazakov.
Committed on 17/12/2021 at 13:09.
Pushed by dkazakov into branch 'krita/5.0'.

[not for master] Remove a sanity check from Krita 5.0

It is safer to disable the resetting of the image link in the
image's destructor for Krita 5.0, because there might be unexpected
crashes like in the bug below.

M  +6    -3    libs/image/kis_image.cc

https://invent.kde.org/graphics/krita/commit/cb39296cd45c18d5c3b532266a8fe93680933d6e
Comment 4 Dmitry Kazakov 2021-12-17 13:26:59 UTC
Git commit a9fc8fa7b270871996924e19ba7456cccab452b5 by Dmitry Kazakov.
Committed on 17/12/2021 at 13:26.
Pushed by dkazakov into branch 'master'.

Remove a sanity check from master as well

It breaks a lot of unittests on master

(It is safer to disable the resetting of the image link in the
image's destructor for Krita 5.0, because there might be unexpected
crashes like in the bug below)
(cherry picked from commit cb39296cd45c18d5c3b532266a8fe93680933d6e)

M  +6    -3    libs/image/kis_image.cc

https://invent.kde.org/graphics/krita/commit/a9fc8fa7b270871996924e19ba7456cccab452b5