Reproducible: Always Krita receives a segfault when trying to flatten a layer which contains a local selection. Steps to Reproduce: 1. Create a new document 2. Add a local selection to a layer 3. Flatten layer GDB Ouput: Thread 22 "Thread (pooled)" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffacdd0700 (LWP 944)] KisNode::lastChild (this=0x0) at src/krita/libs/image/kis_node.cpp:347 347 QReadLocker l(&m_d->nodeSubgraphLock); (gdb) bt #0 KisNode::lastChild (this=0x0) at src/krita/libs/image/kis_node.cpp:347 #1 0x00007ffff3896c21 in KisLayerUtils::CleanUpNodes::reparentSelectionMasks (this=this@entry=0xcf83f00, image=..., newLayer=..., selectionMasks=...) at src/krita/libs/image/kis_layer_utils.cpp:697 #2 0x00007ffff3899c21 in KisLayerUtils::CleanUpNodes::populateChildCommands (this=0xcf83f00) at src/krita/libs/image/kis_layer_utils.cpp:679 #3 0x00007ffff24cfed7 in KisCommandUtils::AggregateCommand::redo (this=0xcf83f08) at src/krita/libs/command/kis_command_utils.cpp:36 #4 0x00007ffff384f93a in KisStrokeStrategyUndoCommandBased::doStrokeCallback (this=0x7f34310, data=<optimized out>) at src/krita/libs/image/kis_stroke_strategy_undo_command_based.cpp:118 #5 0x00007ffff39a7421 in KisStrokeJob::run (this=<optimized out>) at builds/krita_standard/libs/image/../../../../src/krita/libs/image/kis_stroke_job.h:44 #6 KisUpdateJobItem::run (this=0x7feab30) at builds/krita_standard/libs/image/../../../../src/krita/libs/image/kis_update_job_item.h:66 #7 0x00007ffff5d61be3 in ?? () from /opt/Qt-5.6/lib/libQt5Core.so.5 #8 0x00007ffff5d657e8 in ?? () from /opt/Qt-5.6/lib/libQt5Core.so.5 #9 0x00007fffeffb06ba in start_thread (arg=0x7fffacdd0700) at pthread_create.c:333 #10 0x00007ffff545d82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
I can confirm. It is specifically the 'flatten layer' and not the merge down command causing this.
Git commit 2d95fac41ce138ddea67215ce4c419cbf3df6f4a by Boudewijn Rempt. Committed on 05/06/2017 at 09:26. Pushed by rempt into branch 'master'. Check the shared pointer before dereferencing M +12 -10 libs/image/kis_layer_utils.cpp https://commits.kde.org/krita/2d95fac41ce138ddea67215ce4c419cbf3df6f4a
Git commit de70dcf0209ae83b8b4daefa52f8ed64cb2add87 by Boudewijn Rempt. Committed on 05/06/2017 at 09:26. Pushed by rempt into branch 'krita/3.2'. Check the shared pointer before dereferencing M +12 -10 libs/image/kis_layer_utils.cpp https://commits.kde.org/krita/de70dcf0209ae83b8b4daefa52f8ed64cb2add87
Git commit 3ab77958d9d38b77d672c9879aa27a4cd14dd891 by Dmitry Kazakov. Committed on 09/06/2017 at 17:05. Pushed by dkazakov into branch 'master'. Really fix a crash when doing Flatten Layer on a layer with a selection mask M +16 -12 libs/image/kis_layer_utils.cpp https://commits.kde.org/krita/3ab77958d9d38b77d672c9879aa27a4cd14dd891
Git commit f25539e118737a4c22dd9781cec1f4429836e911 by Boudewijn Rempt, on behalf of Dmitry Kazakov. Committed on 11/07/2017 at 11:26. Pushed by rempt into branch 'krita/3.2'. Really fix a crash when doing Flatten Layer on a layer with a selection mask M +17 -9 libs/image/kis_layer_utils.cpp https://commits.kde.org/krita/f25539e118737a4c22dd9781cec1f4429836e911
Git commit 84c73cbea47012de650e08acbdd78eac083ee8d8 by Boudewijn Rempt. Committed on 11/07/2017 at 11:26. Pushed by rempt into branch 'krita/3.2'. Check the shared pointer before dereferencing M +4 -2 libs/image/kis_layer_utils.cpp https://commits.kde.org/krita/84c73cbea47012de650e08acbdd78eac083ee8d8