Bug 462069

Summary: Crash when pasting composited layer into active layer
Product: [Applications] krita Reporter: Freya Lupen <penguinflyer2222>
Component: Layer StackAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: federicobarroso9417
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:

Description Freya Lupen 2022-11-20 16:38:04 UTC
SUMMARY
Krita crashes after copying a layer with a blending mode and using Paste into Active Layer.

STEPS TO REPRODUCE
1. Open a new document.
2. Draw something (so that the layer isn't empty).
3. Set the layer blending mode to something other than Normal (I used Multiply).
4. Copy the layer.
5. Use Paste into Active Layer.
6. Krita crashes.

SOFTWARE/OS VERSIONS
Occurs on 5.1.3 and 5.2.x git hash 8b427aea.

ADDITIONAL INFORMATION
Backtraces; for some reason the first one happens with the default crash logging and the second two when using lldb.
#1---
>Qt5Core.dll!QReadWriteLock::lockForRead+0x7  [C:/MingW-LLVM/include/c++/v1/atomic @ 981]
>libkritaimage.dll!KisTiledDataManager::KisTiledDataManager+0x74  [C:/kd/i/include/QtCore/qreadwritelock.h @ 106]
>   104:         if (q_val) {
>   105:             if ((q_val & quintptr(1u)) == quintptr(0u)) {
>>  106:                 readWriteLock()->lockForRead();
>   107:                 q_val |= quintptr(1u);
>   108:             }
>libkritaimage.dll!KisPaintDeviceData::prepareClone+0x55  [C:/kd/src/libs/image/kis_datamanager.h @ 46]
>    44:      */
>    45: KisDataManager(quint32 pixelSize, const quint8 *defPixel) : ACTUAL_DATAMGR(pixelSize, defPixel) {}
>>   46:     KisDataManager(const KisDataManager& dm) : ACTUAL_DATAMGR(dm) { }
>    47: 
>    48:     ~KisDataManager() override {
>libkritaimage.dll!KisPaintDevice::Private::cloneAllDataObjects+0x104  [C:/kd/src/libs/image/kis_paint_device.cc @ 170]
>   168:         if (!copyFrames) {
>   169:             if (m_data) {
>>  170:                 m_data->prepareClone(rhs->currentNonLodData(), true);
>   171:             } else {
>   172:                 m_data = toQShared(new KisPaintDeviceData(q, rhs->currentNonLodData(), true));
>libkritaimage.dll!KisPaintDevice::makeFullCopyFrom+0x97  [C:/kd/src/libs/image/kis_paint_device.cc @ 1114]
>  1112: 
>  1113:     // copy data objects with or without frames
>> 1114:     m_d->cloneAllDataObjects(rhs.m_d, copyMode == KritaUtils::CopyAllFrames);
>  1115: 
>  1116:     if (copyMode == KritaUtils::CopyAllFrames && rhs.m_d->framesInterface) {
>libkritaimage.dll!KisPaintDevice::KisPaintDevice+0x6d  [C:/kd/src/libs/image/kis_paint_device.cc @ 1104]
>  1102: {
>  1103:     if (this != &rhs) {
>> 1104:         makeFullCopyFrom(rhs, copyMode, newParentNode);
>  1105:     }
>  1106: }
>libkritaui.dll!KisPasteIntoActionFactory::run+0x106  [C:/kd/src/libs/ui/actions/KisPasteActionFactories.cpp @ 315]
>   313:     const KisPaintDevice *clipdev = KisClipboard::instance()->clipFromKritaLayers(image->bounds(),
>   314:                                                                             image->colorSpace()).data();
>>  315:     KisPaintDeviceSP clip = new KisPaintDevice(*clipdev);
>   316: 
>   317:     if (clip) {
>libkritaui.dll!KisSelectionManager::pasteInto+0x84  [C:/kd/src/libs/ui/kis_selection_manager.cc @ 371]
>   369: {
>   370:     KisPasteIntoActionFactory factory;
>>  371:     factory.run(m_view);
>   372: }
>   373: 
#2---
>  * frame #0: 0x00007fff0892137c libkritaimage.dll`KisPaintDevice::Private::currentNonLodData() const [inlined] QScopedPointer<KisRasterKeyframeChannel, QScopedPointerDeleter<KisRasterKeyframeChannel>>::isNull(this=0xfeeefeeefeeeff06) const at qscopedpointer.h:150:17
>    frame #1: 0x00007fff0892137c libkritaimage.dll`KisPaintDevice::Private::currentNonLodData() const [inlined] QScopedPointer<KisRasterKeyframeChannel, QScopedPointerDeleter<KisRasterKeyframeChannel>>::operator KisRasterKeyframeChannel* QScopedPointer<KisRasterKeyframeChannel, QScopedPointerDeleter<KisRasterKeyframeChannel>>::*(this=0xfeeefeeefeeeff06) const at qscopedpointer.h:134:16
>    frame #2: 0x00007fff0892137c libkritaimage.dll`KisPaintDevice::Private::currentNonLodData(this=0xfeeefeeefeeefeee) const at kis_paint_device.cc:497:13
>    frame #3: 0x00007fff08922f96 libkritaimage.dll`KisPaintDevice::Private::cloneAllDataObjects(this=0x000002236ae4ed60, rhs=0xfeeefeeefeeefeee, copyFrames=false) at kis_paint_device.cc:170:43
>    frame #4: 0x00007fff08919e37 libkritaimage.dll`KisPaintDevice::makeFullCopyFrom(this=0x0000022365352b80, rhs=0x000002230e8396d0, copyMode=CopySnapshot, newParentNode=0x0000000000000000) at kis_paint_device.cc:1114:10
>    frame #5: 0x00007fff08919d5d libkritaimage.dll`KisPaintDevice::KisPaintDevice(this=0x0000022365352b80, rhs=0x000002230e8396d0, copyMode=CopySnapshot, newParentNode=0x0000000000000000) at kis_paint_device.cc:1104:9
>    frame #6: 0x00007fff113c6656 libkritaui.dll`KisPasteIntoActionFactory::run(this=<unavailable>, viewManager=0x00000223411b15e0) at KisPasteActionFactories.cpp:315:33
>    frame #7: 0x00007fff111ae594 libkritaui.dll`KisSelectionManager::pasteInto(this=0x00000223411b2838) at kis_selection_manager.cc:371:13
#3---
>    * frame #0: 0x00007fff0891af52 libkritaimage.dll`KisPaintDevice::exactBounds() const [inlined] KisPaintDevice::Private::currentData(this=0x000001ff42ed3090) const at kis_paint_device.cc:528:28
>      frame #1: 0x00007fff0891af4e libkritaimage.dll`KisPaintDevice::exactBounds() const [inlined] KisPaintDevice::Private::cache(this=0x000001ff42ed3090) at kis_paint_device.cc:143:16
>      frame #2: 0x00007fff0891af4e libkritaimage.dll`KisPaintDevice::exactBounds(this=0x000001ff1eb0d770) const at kis_paint_device.cc:1295:17
>      frame #3: 0x00007fff113c666b libkritaui.dll`KisPasteIntoActionFactory::run(this=<unavailable>, viewManager=0x000001ff1dd9e1c0) at KisPasteActionFactories.cpp:318:34
>      frame #4: 0x00007fff111ae594 libkritaui.dll`KisSelectionManager::pasteInto(this=0x000001ff1dd9f418) at kis_selection_manager.cc:371:13
Comment 1 amyspark 2022-11-20 18:29:28 UTC
The exactBounds() crash tilts it towards Dmitry's purview. Can you take a look?
Comment 2 Freya Lupen 2022-11-29 17:36:42 UTC
I've confirmed this issue is fixed by commit 0ea213fb "PasteIntoAction: Preserve shared pointer as a variable" on 5.2.x (https://invent.kde.org/graphics/krita/-/commit/0ea213fbeb8260509cf0232776a4d41d620ff8f2).
Comment 3 Halla Rempt 2023-01-04 10:49:06 UTC
*** Bug 463592 has been marked as a duplicate of this bug. ***