Bug 423752

Summary: Crash can be induced with 4.3.0 onwards after copying a vector layer to another open image
Product: [Applications] krita Reporter: Ahab Greybeard <ahab.greybeard>
Component: Layers/VectorAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: anna.medonosova, dimula73
Priority: NOR Keywords: regression, triaged
Version: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 456450    
Attachments: backtrace of the crash

Description Ahab Greybeard 2020-07-01 16:52:59 UTC
SUMMARY
This is observed with the 4.3.0 and the Jun 30 4.3.1 alpha (git eccf4e1) and the Jun 30 5.0.0 prealpha (git 8dccf4f) appimages.

STEPS TO REPRODUCE
1. Create a new image and add a vector layer then make a vector shape in it.
2. Create a second new image.
3. In the first image, select the vector layer and do Copy Layer
4. In the second image, do Paste Layer. (This works ok)
5. Close each of the images without saving.
6. Create a New image
[NOTE: it instantly crashes and vanishes]

OBSERVED RESULT
See Steps To Reproduce.
This only happens with vector layers or a group layer that contains a vector layer.
It does not happen if you copy a vector object from one image to another (that also has a vector layer).

The log has an ASSERT of the following nature:
=================================================
01 Jul 2020 17:26:41 +0100: ASSERT (krita): "this->image()" in file /home/appimage/workspace/Krita_Nightly_Appimage_Build/krita/libs/ui/flake/kis_shape_layer.cc, line 260

KRITA DID NOT CLOSE CORRECTLY
================================================

Versions 4.2.8 onwards crash as noted above

Versions 4.2.0 to 4.2.7.1 show on screen Asserts of the following nature when closing the open images without saving:
================================================
01 Jul 2020 17:43:11 +0100: SAFE ASSERT (krita): "!sanityCheckPointer.isValid()" in file /home/appimage/workspace/Krita_Release_Appimage_Build/krita/libs/ui/KisDocument.cpp, line 515
=================================================
These Asserts can be ignored and there is no crash.

EXPECTED RESULT
It doesn't crash

SOFTWARE/OS VERSIONS
Krita

 Version: 5.0.0-prealpha (git 8dccf4f)
 Languages: en_GB, en, en, en_GB, en
 Hidpi: true

Qt

  Version (compiled): 5.12.9
  Version (loaded): 5.12.9

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-9-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10
  Desktop: MATE

OpenGL Info
 
  Vendor:  "NVIDIA Corporation" 
  Renderer:  "GeForce GTX 750 Ti/PCIe/SSE2" 
  Version:  "4.6.0 NVIDIA 440.82" 
  Shading language:  "4.60 NVIDIA" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 4.6, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
     Version: 4.6
     Supports deprecated functions true 
     is OpenGL ES: false 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: false
Comment 1 Anna Medonosova 2020-07-12 21:28:21 UTC
I can reproduce this issue in krita-5.0.0-prealpha-dd8d748-x86_64.appimage
Comment 2 Anna Medonosova 2020-07-12 21:37:38 UTC
Created attachment 130072 [details]
backtrace of the crash
Comment 3 Dmitry Kazakov 2020-09-10 19:03:54 UTC
Git commit 590e9dd98476d5b4146f5371cfec2bd487b67d33 by Dmitry Kazakov.
Committed on 10/09/2020 at 19:03.
Pushed by dkazakov into branch 'krita/4.3'.

Fix crash after pasting a shape layer into a different document

We shouldn't expect layer->image() being always set when creating
a shape layer. Image may not exist for layers stored in KisMimeData.

M  +47   -21   libs/ui/flake/kis_shape_layer.cc
M  +3    -1    libs/ui/flake/kis_shape_layer.h

https://invent.kde.org/graphics/krita/commit/590e9dd98476d5b4146f5371cfec2bd487b67d33
Comment 4 Dmitry Kazakov 2020-09-10 19:04:03 UTC
Git commit d60b315d4c51895eec12288e96790b6a4a602b01 by Dmitry Kazakov.
Committed on 10/09/2020 at 19:03.
Pushed by dkazakov into branch 'krita/4.3'.

Fix sanity assert when destroying image right after pasting a layer into it

Basically, KisNodeJugglerCompressed should stop storing **any** pointers
to KisImage after slotEndStrokeRequested() has arrived.

The pointers are stored in Private and BatchMoveUpdateData.

M  +3    -1    libs/image/kis_idle_watcher.cpp
M  +1    -0    libs/ui/KisDocument.cpp
M  +7    -4    libs/ui/kis_node_juggler_compressed.cpp

https://invent.kde.org/graphics/krita/commit/d60b315d4c51895eec12288e96790b6a4a602b01
Comment 5 Dmitry Kazakov 2020-09-10 19:04:11 UTC
Git commit 292835d05ec8650dcfa4648f961351489a4a5430 by Dmitry Kazakov.
Committed on 10/09/2020 at 19:03.
Pushed by dkazakov into branch 'krita/4.3'.

Fix memory leak in KisMimeData

M  +2    -2    libs/ui/kis_mimedata.cpp

https://invent.kde.org/graphics/krita/commit/292835d05ec8650dcfa4648f961351489a4a5430
Comment 6 Dmitry Kazakov 2020-09-10 19:04:44 UTC
Git commit 9475fe1d7301100ef9245da67f39e646bc1b394f by Dmitry Kazakov.
Committed on 10/09/2020 at 19:04.
Pushed by dkazakov into branch 'master'.

Fix crash after pasting a shape layer into a different document

We shouldn't expect layer->image() being always set when creating
a shape layer. Image may not exist for layers stored in KisMimeData.

M  +47   -21   libs/ui/flake/kis_shape_layer.cc
M  +3    -1    libs/ui/flake/kis_shape_layer.h

https://invent.kde.org/graphics/krita/commit/9475fe1d7301100ef9245da67f39e646bc1b394f
Comment 7 Dmitry Kazakov 2020-09-10 19:04:45 UTC
Git commit 04c9bf185a05eb02e9151c670e3ba46bed11971b by Dmitry Kazakov.
Committed on 10/09/2020 at 19:04.
Pushed by dkazakov into branch 'master'.

Fix sanity assert when destroying image right after pasting a layer into it

Basically, KisNodeJugglerCompressed should stop storing **any** pointers
to KisImage after slotEndStrokeRequested() has arrived.

The pointers are stored in Private and BatchMoveUpdateData.

M  +3    -1    libs/image/kis_idle_watcher.cpp
M  +1    -0    libs/ui/KisDocument.cpp
M  +7    -4    libs/ui/kis_node_juggler_compressed.cpp

https://invent.kde.org/graphics/krita/commit/04c9bf185a05eb02e9151c670e3ba46bed11971b
Comment 8 Dmitry Kazakov 2020-09-10 19:04:53 UTC
Git commit ba95fd959843b8c034e334855f008f84daad328f by Dmitry Kazakov.
Committed on 10/09/2020 at 19:04.
Pushed by dkazakov into branch 'master'.

Fix memory leak in KisMimeData

M  +2    -2    libs/ui/kis_mimedata.cpp

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