copy/pasting in krita crashes the program
This has been happening to me lately very commonly, and copy/pasting is something I do sometimes, I was following this bug report on the krita side but they point to xfce as the culprit.
https://bugs.kde.org/show_bug.cgi?id=502266
But then I came here and I don't see any bug report related to it, and that one was closed "because it was xfce's issue"
My rough config:
xfce4 + x11
CPU AMD Ryzen 9 7900x
GPU nvidia rtx 4070ti super
Graphics tablet: huion kamvas pro 24 4k
RAM: 64 Gb
I can reproduce it deterministically by doing the following:
- open krita
- draw something (optional)
- select an area (I do it with the free select tool)
- copy
- paste
- paste (this crashes)
The second paste crashes for me, but I believe in other circumstances I have seen a first paste crashing it..
This is the whole backtrace of the thing, but I believe that all the 87 threads are not important other than the thread 1 here:
Thread 1 (Thread 0x7fffefd96dc0 (LWP 509744) "krita"):
#0 0x00007ffff54b06b2 in __cxxabiv1::__dynamic_cast (src_ptr=0x55555a293ef0, src_type=0x7ffff737f598 <typeinfo for KisNode>, dst_type=0x7ffff737f230 <typeinfo for KisCloneLayer>, src2dst=0) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/dyncast.cc:58
vtable = 0x55500f7c9783
prefix = 0x55500f7c9773
whole_ptr = <optimized out>
whole_type = <optimized out>
result = {dst_ptr = 0x7fffffffc010, whole2dst = 4111092942, whole2src = 32767, dst2src = __cxxabiv1::__class_type_info::__unknown, whole_details = 0}
whole_vtable = <optimized out>
whole_prefix = <optimized out>
#1 0x00007ffff7870680 in (anonymous namespace)::safeCopyNode (node=..., detachClones=true) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_mimedata.cpp:53
cloneLayer = {d = <optimized out>}
#2 0x00007ffff787b346 in KisMimeData::tryLoadInternalNodes (data=data@entry=0x555556b334f0, image=..., shapeController=0x555559e70150, copyNode=@0x7fffffffc25c: false) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_mimedata.cpp:295
node = {d = 0x55555a293ef0}
_container_294 = {c = {<QListSpecialMethods<KisSharedPtr<KisNode> >> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = std::atomic<int> = { -1 }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x555556cdcb20}, d = 0x555556cdcb20}}, i = {i = 0x555556cdcb30}, e = {i = 0x555556cdcb38}, control = 1}
lock = {<KisAdaptedLock<KisImageBarrierLockAdapterImpl<KisSharedPtr<KisImage>, true> >> = {<KisImageBarrierLockAdapterImpl<KisSharedPtr<KisImage>, true>> = {m_image = {d = 0x0}}, <std::unique_lock<KisImageBarrierLockAdapterImpl<KisSharedPtr<KisImage>, true> >> = {_M_device = 0x7fffffffc100, _M_owns = false}, <No data fields>}, <No data fields>}
clones = {<QListSpecialMethods<KisSharedPtr<KisNode> >> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = std::atomic<int> = { -1 }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x7ffff5bbb0d0 <QListData::shared_null>}, d = 0x7ffff5bbb0d0 <QListData::shared_null>}}
nodes = {<QListSpecialMethods<KisSharedPtr<KisNode> >> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = std::atomic<int> = { -1 }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x555556cdcb20}, d = 0x555556cdcb20}}
forceCopy = <optimized out>
sourceImage = {d = <optimized out>}
mimedata = <optimized out>
#3 0x00007ffff787c9a2 in KisMimeData::loadNodesFast (data=0x555556b334f0, image=..., shapeController=<optimized out>, copyNode=@0x7fffffffc25c: false) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_mimedata.cpp:428
nodes = {<QListSpecialMethods<KisSharedPtr<KisNode> >> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = std::atomic<int> = { -1 }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x555556cdcb20}, d = 0x555556cdcb20}}
#4 0x00007ffff787cd96 in KisMimeData::insertMimeLayers (data=<optimized out>, image=..., shapeController=<optimized out>, parentDummy=<optimized out>, aboveThisDummy=<optimized out>, copyNode=<optimized out>, nodeInsertionAdapter=0x555556b36180, changeOffset=false, offset=..., applicator=0x0) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_mimedata.cpp:468
nodes = {<QListSpecialMethods<KisSharedPtr<KisNode> >> = {<No data fields>}, {p = {static shared_null = {ref = {atomic = {_q_value = std::atomic<int> = { -1 }}}, alloc = 0, begin = 0, end = 0, array = {0x0}}, d = 0x555556cdcb20}, d = 0x555556cdcb20}}
result = <optimized out>
aboveThisNode = {d = <optimized out>}
hasDelayedNodes = <optimized out>
#5 0x00007ffff78897f7 in KisNodeManager::pasteLayersFromClipboard (this=0x555556b340f0, changeOffset=<optimized out>, offset=..., applicator=0x0) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_node_manager.cpp:1514
data = 0x555556b334f0
activeNode = {d = 0x555556cb3710}
shapeController = 0x555559e70150
dummiesFacade = <optimized out>
copyNode = false
image = {d = <optimized out>}
parentDummy = 0x55555a516650
aboveThisDummy = 0x0
#6 0x00007ffff7aa7c86 in KisPasteActionFactory::run (this=0x7fffffffc790, flags=..., view=0x555556b33160) at /usr/src/debug/krita/krita-5.2.13/libs/ui/actions/KisPasteActionFactories.cpp:275
offsetTopLeft = {xp = <optimized out>, yp = <optimized out>}
pasteAtCursorPosition = <optimized out>
image = {d = 0x555558b97160}
docPos = {xp = 559.64411964942815, yp = 171.13363610510257}
fittingBounds = {x1 = 0, y1 = 0, x2 = 3839, y2 = 2159}
range = {<boost::operators_impl::equality_comparable<KisTimeSpan, KisTimeSpan, boost::operators_impl::operators_detail::empty_base<KisTimeSpan>, boost::operators_impl::operators_detail::false_t>> = {<boost::operators_impl::equality_comparable1<KisTimeSpan, boost::operators_impl::operators_detail::empty_base<KisTimeSpan> >> = {<boost::operators_impl::operators_detail::empty_base<KisTimeSpan>> = {<No data fields>}, <No data fields>}, <No data fields>}, m_start = 1480289744, m_end = 21845}
clip = {d = 0x7ffff47a4dee <KXmlGuiWindow::event(QEvent*)+46>}
#7 0x00007ffff78ec2f7 in KisSelectionManager::paste (this=0x555556b33e18) at /usr/src/debug/krita/krita-5.2.13/libs/ui/kis_selection_manager.cc:359
factory = {<KisOperation> = {_vptr.KisOperation = 0x7ffff7d7b598 <vtable for KisPasteActionFactory+16>, m_id = {d = 0x55555ad2c640}}, <No data fields>}
#8 0x00007ffff5b07705 in doActivate<false> (sender=0x555558668870, signal_index=4, argv=0x7fffffffc8b0) at kernel/qobject.cpp:3940
method_relative = <optimized out>
callFunction = <optimized out>
methodIndex = 0
receiver = 0x555556b33e18
td = <optimized out>
receiverInSameThread = <optimized out>
senderData = {previous = 0x0, receiver = 0x555556b33e18, sender = 0x555558668870, signal = 4}
c = 0x555558671a50
connections = {d = 0x5555586720a0}
list = 0x55555866a0a0
inSenderThread = <optimized out>
highestConnectionId = 5
signalVector = 0x55555866a040
currentThreadId = 0x7fffefd96dc0
sp = <optimized out>
signal_spy_set = 0x0
empty_argv = {0x0}
senderDeleted = false
#9 0x00007ffff674a705 in QAction::triggered (this=this@entry=0x555558668870, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
_a = {0x0, 0x7fffffffc8ac}
#10 0x00007ffff6750640 in QAction::activate (this=0x555558668870, event=<optimized out>) at kernel/qaction.cpp:1161
guard = {wp = {d = <optimized out>, value = <optimized out>}}
d = <optimized out>
#11 0x00007ffff675073e in QAction::event (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1086
se = <optimized out>
#12 QAction::event (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1075
se = <optimized out>
#13 0x00007ffff6758626 in QApplicationPrivate::notify_helper (this=this@entry=0x7fff00000004, receiver=receiver@entry=0x555558668870, e=e@entry=0x7fffffffcb40) at kernel/qapplication.cpp:3640
consumed = false
filtered = false
#14 0x00007ffff675c9b4 in QApplication::notify (this=this@entry=0x7fffffffd1d0, receiver=receiver@entry=0x555558668870, e=e@entry=0x7fffffffcb40) at kernel/qapplication.cpp:3386
w = <optimized out>
extra = <optimized out>
isProxyWidget = <optimized out>
d = <optimized out>
res = false
#15 0x00007ffff7b01d4f in KisApplication::notify (this=0x7fffffffd1d0, receiver=0x555558668870, event=0x7fffffffcb40) at /usr/src/debug/krita/krita-5.2.13/libs/ui/KisApplication.cpp:771
guard = {m_info = 0x555555f0ce80}
result = true
info = @0x555555f0ce80: {eventRecursionCount = 1, postponedSynchronizationEvents = std::queue wrapping: std::deque with 0 elements}
#16 0x00007ffff5ad0448 in QCoreApplication::notifyInternal2 (receiver=0x555558668870, event=0x7fffffffcb40) at kernel/qcoreapplication.cpp:1064
selfRequired = true
result = false
cbdata = {0x555558668870, 0x7fffffffcb40, 0x7fffffffca8f}
d = <optimized out>
threadData = 0x555555e54260
scopeLevelCounter = {threadData = 0x555555e54260}
#17 0x00007ffff5ad04b3 in QCoreApplication::sendEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1462
#18 0x00007ffff5f6d4df in QShortcutMap::dispatchEvent (this=this@entry=0x7fffe80032b8, e=e@entry=0x7fffffffcc20) at kernel/qshortcutmap.cpp:675
d = <optimized out>
curKey = <optimized out>
current = <optimized out>
next = <optimized out>
i = <optimized out>
enabledShortcuts = 1
ambiguousShortcuts = {d = <optimized out>}
se = {<QEvent> = {_vptr.QEvent = 0x7ffff64728d0 <vtable for QShortcutEvent+16>, static staticMetaObject = {d = {superdata = {direct = 0x0}, stringdata = 0x7ffff5bae2c0 <_ZL25qt_meta_stringdata_QEvent.lto_priv.0>, data = 0x7ffff5badd00 <_ZL19qt_meta_data_QEvent.lto_priv.0>, static_metacall = 0x0, relatedMetaObjects = 0x0, extradata = 0x0}}, d = 0x0, t = 117, posted = 0, spont = 0, m_accept = 1, reserved = 7866}, sequence = {d = 0x55555768bd40}, ambig = false, sid = -45}
#19 0x00007ffff5f6da6f in QShortcutMap::tryShortcut (this=0x7fffe80032b8, e=0x7fffffffcc20) at kernel/qshortcutmap.cpp:343
identicalMatches = 1
d = <optimized out>
previousState = QKeySequence::NoMatch
#20 0x00007ffff5f20433 in QWindowSystemInterface::handleShortcutEvent (window=0x5555586bfdb0, timestamp=25450092, keyCode=86, modifiers=..., nativeScanCode=55, nativeVirtualKey=118, nativeModifiers=20, text=..., autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:477
shortcutMap = @0x7fffe80032b8: {d_ptr = {d = 0x7fffe8005880}}
keyEvent = {<QInputEvent> = {<QEvent> = {_vptr.QEvent = 0x7ffff6472c10 <vtable for QKeyEvent+16>, static staticMetaObject = {d = {superdata = {direct = 0x0}, stringdata = 0x7ffff5bae2c0 <_ZL25qt_meta_stringdata_QEvent.lto_priv.0>, data = 0x7ffff5badd00 <_ZL19qt_meta_data_QEvent.lto_priv.0>, static_metacall = 0x0, relatedMetaObjects = 0x0, extradata = 0x0}}, d = 0x0, t = 51, posted = 0, spont = 0, m_accept = 0, reserved = 8191}, modState = {i = 67108864}, ts = 0}, txt = {d = 0x55555d0fb670}, k = 86, nScanCode = 55, nVirtualKey = 118, nModifiers = 20, c = 1, autor = 0}
#21 0x00007ffff5f3bcf8 in QGuiApplicationPrivate::processKeyEvent (e=0x555557f26fa0) at kernel/qguiapplication.cpp:2398
window = 0x5555586bfdb0
ev = {<QInputEvent> = {<QEvent> = {_vptr.QEvent = 0x55555670f230, static staticMetaObject = {d = {superdata = {direct = 0x0}, stringdata = 0x7ffff5bae2c0 <_ZL25qt_meta_stringdata_QEvent.lto_priv.0>, data = 0x7ffff5badd00 <_ZL19qt_meta_data_QEvent.lto_priv.0>, static_metacall = 0x0, relatedMetaObjects = 0x0, extradata = 0x0}}, d = 0x55555670f230, t = 52496, posted = 1, spont = 1, m_accept = 1, reserved = 8191}, modState = {i = 32767}, ts = 140737313434863}, txt = {d = 0x7ffff6485d70 <QWindowSystemInterfacePrivate::windowSystemEventQueue>}, k = 1475506080, nScanCode = 21845, nVirtualKey = 4294954320, nModifiers = 32767, c = 12023, autor = 1}
#22 0x00007ffff5f1f5dd in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
event = 0x555557f26fa0
nevents = 1
#23 0x00007fffef0f4d38 in xcbSourceDispatch (source=<optimized out>) at /usr/src/debug/qt5-base/kde-qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:105
xcbEventSource = <optimized out>
flags = {i = 36}
#24 0x00007ffff3106f8d in g_main_dispatch (context=0x555555e57c70) at ../glib/glib/gmain.c:3565
user_data = 0x0
callback = 0x0
gaig_temp = <optimized out>
gaig_temp = <optimized out>
cb_data = 0x0
need_destroy = <optimized out>
dispatch = 0x7fffef0f4d10 <xcbSourceDispatch(GSource*, GSourceFunc, gpointer)>
prev_source = 0x0
was_in_call = 0
cb_funcs = 0x0
begin_time_nsec = 25450093285061
source = 0x555555ec3170
current = 0x555555fe4cb0
i = 1
#25 0x00007ffff3108657 in g_main_context_dispatch_unlocked (context=0x555555e57c70) at ../glib/glib/gmain.c:4425
#26 g_main_context_iterate_unlocked (context=context@entry=0x555555e57c70, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4490
max_priority = 2147483647
timeout_usec = 142000
some_ready = 1
nfds = 5
allocated_nfds = <optimized out>
fds = 0x55555682d4e0
begin_time_nsec = <optimized out>
#27 0x00007ffff3108865 in g_main_context_iteration (context=0x555555e57c70, may_block=1) at ../glib/glib/gmain.c:4556
retval = <optimized out>
#28 0x00007ffff5b21dc9 in QEventDispatcherGlib::processEvents (this=0x555555ec2f90, flags=...) at kernel/qeventdispatcher_glib.cpp:423
d = 0x555555e84930
canWait = <optimized out>
savedFlags = {i = 0}
result = <optimized out>
#29 0x00007ffff5ac893b in QEventLoop::exec (this=0x7fffffffcff0, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
d = 0x55555671e060
threadData = <optimized out>
locker = {val = 93825001669464}
ref = {d = <optimized out>, locker = <optimized out>, exceptionCaught = <optimized out>}
app = <optimized out>
#30 0x00007ffff5ad4c5b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1375
threadData = 0x555555e54260
eventLoop = {<QObject> = {_vptr.QObject = 0x7ffff5d3e7a0 <vtable for QEventLoop+16>, static staticMetaObject = {d = {superdata = {direct = 0x0}, stringdata = 0x7ffff5bb9b60 <_ZL26qt_meta_stringdata_QObject.lto_priv.0>, data = 0x7ffff5bb9a40 <_ZL20qt_meta_data_QObject.lto_priv.0>, static_metacall = 0x7ffff5b07c30 <QObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}, d_ptr = {d = 0x55555671e060}, static staticQtMetaObject = {d = {superdata = {direct = 0x0}, stringdata = 0x7ffff5bf7240 <_ZL21qt_meta_stringdata_Qt.lto_priv.0>, data = 0x7ffff5bf43c0 <_ZL15qt_meta_data_Qt.lto_priv.0>, static_metacall = 0x0, relatedMetaObjects = 0x0, extradata = 0x0}}}, static staticMetaObject = {d = {superdata = {direct = 0x7ffff5d374e0 <QObject::staticMetaObject>}, stringdata = 0x7ffff5bb5520 <_ZL29qt_meta_stringdata_QEventLoop.lto_priv.0>, data = 0x7ffff5bb54c0 <_ZL23qt_meta_data_QEventLoop.lto_priv.0>, static_metacall = 0x7ffff5ac6710 <QEventLoop::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)>, relatedMetaObjects = 0x0, extradata = 0x0}}}
returnCode = <optimized out>
#31 0x000055555555c034 in ??? ()
#32 0x00007ffff5027635 in __libc_start_call_main (main=main@entry=0x5555555599f0, argc=argc@entry=1, argv=argv@entry=0x7fffffffe728) at ../sysdeps/nptl/libc_start_call_main.h:58
self = <optimized out>
result = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -2335179003145522840, 140737488348968, 1, 140737354125312, 93824998684464, -2335179003122454168, -2335165977155505816}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x7fffffffe728}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
#33 0x00007ffff50276e9 in __libc_start_main_impl (main=0x5555555599f0, argc=1, argv=0x7fffffffe728, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe718) at ../csu/libc-start.c:360
#34 0x000055555555df95 in ??? ()
I'm not familiar with KDE's clipboard handling, and honestly I'm a bit confused that with anything coming from the clipboard, crashing is a viable option (I would expect clipboard contents to be treated as "external data" and thus potentially problematic, but I'm not familiar with how these things should work), but in the above bug report they seem quite convinced that this is on xfce's side.
There is a comment from a contributor that did a change that claimed that fixed the issue but I tested with a nightly build today, which I confirmed in github that had the change and it crashed in the same place:
link to the code in master now: https://github.com/KDE/krita/blob/master/libs/ui/kis_clipboard.cc#L319
Can anyone confirm if this is in fact an XFCE issue or is on Krita? Please let me know if this information is enough, I ran krita with gdb and allowing gdb to download symbols, but it is not a debug build (is the default arch krita)
I do have some experience on linux + debug but I'm not familiar with either krita or xfce (and the possibility of the issue being on the WM is a bit scary). But this to clarify that you can ask me for further details.
I opened the issue in xfce4-settings because the last comment on the KDE ticket mentioned that this is solved by downgrading xfce4-settings to a given version, and I couldn't find a better fit for clipboard events on xfce (maybe xfwm4??). I haven't tested myself if downgrading works, but it didn't crash in the past. Feel free to move this to another project if more convenient.
Many thanks for XFCE!