Bug 462006

Summary: Crash when creating new image from selected region (clipboard)
Product: [Applications] krita Reporter: sander.smid
Component: GeneralAssignee: amyspark <amy>
Status: RESOLVED WORKSFORME    
Severity: crash CC: halla
Priority: NOR Keywords: drkonqi
Version: 5.1.3   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 465128    

Description sander.smid 2022-11-18 18:48:15 UTC
Application: krita (5.1.3)

Qt Version: 5.15.7
Frameworks Version: 5.99.0
Operating System: Linux 6.0.8-zen1-1-zen x86_64
Windowing System: X11
Distribution: "Arch Linux"
DrKonqi: 5.26.3 [KCrashBackend]

-- Information about the crash:
Open aimage, use the rectangular selection to select a subset, copy into clipboard and create a new image from that clipboard. Crash.

The crash can be reproduced sometimes.

-- Backtrace:
Application: Krita (krita), signal: Aborted

[KCrash Handler]
#4  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#5  0x00007f6c73ca16b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#6  0x00007f6c73c51958 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#7  0x00007f6c73c3b53d in __GI_abort () at abort.c:79
#8  0x00007f6c7429fede in qt_message_fatal (message=<synthetic pointer>..., context=<optimized out>) at global/qlogging.cpp:1914
#9  QMessageLogger::fatal(char const*, ...) const (this=this@entry=0x7fff6af5d3e0, msg=msg@entry=0x7f6c75dee277 "%s") at global/qlogging.cpp:893
#10 0x00007f6c75ddd77c in kis_assert_common(char const*, char const*, int, bool, bool) [clone .constprop.0] (assertion=assertion@entry=0x7f6c7655e9f9 "clip", file=file@entry=0x7f6c765727b0 "/usr/src/debug/krita/krita-5.1.3/libs/ui/widgets/kis_image_from_clipboard_widget.cpp", line=line@entry=80, isIgnorable=isIgnorable@entry=false, throwException=<optimized out>) at /usr/src/debug/krita/krita-5.1.3/libs/global/kis_assert.cpp:89
#11 0x00007f6c75d9f88b in kis_assert_exception(char const*, char const*, int) (assertion=assertion@entry=0x7f6c7655e9f9 "clip", file=file@entry=0x7f6c765727b0 "/usr/src/debug/krita/krita-5.1.3/libs/ui/widgets/kis_image_from_clipboard_widget.cpp", line=line@entry=80) at /usr/src/debug/krita/krita-5.1.3/libs/global/kis_assert.cpp:112
#12 0x00007f6c7631c9c9 in KisImageFromClipboardWidget::createImage() (this=0x556afa3f9d50) at /usr/src/debug/krita/krita-5.1.3/libs/ui/widgets/kis_image_from_clipboard_widget.cpp:80
#13 0x00007f6c744bda51 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff6af5d580, r=<optimized out>, this=0x556aefddc290, this=<optimized out>, r=<optimized out>, a=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#14 doActivate<false>(QObject*, int, void**) (sender=0x556aefdc22d0, signal_index=8, argv=0x7fff6af5d580) at kernel/qobject.cpp:3919
#15 0x00007f6c7530e7d3 in QDialogButtonBoxPrivate::_q_handleButtonClicked() (this=<optimized out>) at widgets/qdialogbuttonbox.cpp:878
#16 QDialogButtonBox::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at .moc/moc_qdialogbuttonbox.cpp:159
#17 0x00007f6c744bdc00 in doActivate<false>(QObject*, int, void**) (sender=0x556aefdc2730, signal_index=9, argv=0x7fff6af5d6e0) at kernel/qobject.cpp:3931
#18 0x00007f6c7525c527 in QAbstractButton::clicked(bool) (this=this@entry=0x556aefdc2730, _t1=<optimized out>) at .moc/moc_qabstractbutton.cpp:308
#19 0x00007f6c7525ed8a in QAbstractButtonPrivate::emitClicked() (this=this@entry=0x556aefdc27c0) at widgets/qabstractbutton.cpp:416
#20 0x00007f6c7525f204 in QAbstractButton::click() (this=0x556aefdc2730) at widgets/qabstractbutton.cpp:905
#21 QAbstractButton::click() (this=0x556aefdc2730) at widgets/qabstractbutton.cpp:891
#22 0x00007f6c751af5d1 in QWidget::event(QEvent*) (this=0x556aefdc2730, event=0x7fff6af5dd60) at kernel/qwidget.cpp:8702
#23 0x00007f6c75178b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x556aeef125d0, receiver=receiver@entry=0x556aefdc2730, e=e@entry=0x7fff6af5dd60) at kernel/qapplication.cpp:3637
#24 0x00007f6c7517ddf8 in QApplication::notify(QObject*, QEvent*) (this=this@entry=0x7fff6af5eca0, receiver=receiver@entry=0x556aefdc2730, e=e@entry=0x7fff6af5dd60) at kernel/qapplication.cpp:2999
#25 0x00007f6c76419d8f in KisApplication::notify(QObject*, QEvent*) (this=0x7fff6af5eca0, receiver=0x556aefdc2730, event=0x7fff6af5dd60) at /usr/src/debug/krita/krita-5.1.3/libs/ui/KisApplication.cpp:757
#26 0x00007f6c7448cf98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x556aefdc2730, event=0x7fff6af5dd60) at kernel/qcoreapplication.cpp:1064
#27 0x00007f6c751cf18b in QWidgetWindow::handleGestureEvent(QNativeGestureEvent*) (e=<optimized out>, this=<optimized out>) at kernel/qwidgetwindow.cpp:1122
#28 QWidgetWindow::event(QEvent*) (this=0x556aefdeb940, event=0x7fff6af5dd60) at kernel/qwidgetwindow.cpp:371
#29 0x00007f6c75178b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x7fff6af5daaf, receiver=0x556aefdeb940, e=e@entry=0x7fff6af5dd60) at kernel/qapplication.cpp:3637
#30 0x00007f6c7517d1f1 in QApplication::notify(QObject*, QEvent*) (this=this@entry=0x7fff6af5eca0, receiver=receiver@entry=0x556aefdeb940, e=e@entry=0x7fff6af5dd60) at kernel/qapplication.cpp:3383
#31 0x00007f6c76419d8f in KisApplication::notify(QObject*, QEvent*) (this=0x7fff6af5eca0, receiver=0x556aefdeb940, event=0x7fff6af5dd60) at /usr/src/debug/krita/krita-5.1.3/libs/ui/KisApplication.cpp:757
#32 0x00007f6c7448cf98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x556aefdeb940, event=0x7fff6af5dd60) at kernel/qcoreapplication.cpp:1064
#33 0x00007f6c7493fb80 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) (e=0x556aefe17e90) at kernel/qguiapplication.cpp:2417
#34 0x00007f6c74928985 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#35 0x00007f6c6eaec710 in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>) at /usr/src/debug/qt5-base/qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:105
#36 0x00007f6c7206d87b in g_main_dispatch (context=0x7f6c68005010) at ../glib/glib/gmain.c:3444
#37 g_main_context_dispatch (context=0x7f6c68005010) at ../glib/glib/gmain.c:4162
#38 0x00007f6c720c4279 in g_main_context_iterate.constprop.0 (context=0x7f6c68005010, block=1, dispatch=1, self=<optimized out>) at ../glib/glib/gmain.c:4238
#39 0x00007f6c7206c132 in g_main_context_iteration (context=0x7f6c68005010, may_block=1) at ../glib/glib/gmain.c:4303
#40 0x00007f6c744d7c4c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x556aeee78ba0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#41 0x00007f6c7448573c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fff6af5e060, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#42 0x00007f6c753736cb in QDialog::exec() (this=0x556afa350cb0) at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#43 0x00007f6c7645aec4 in KisMainWindow::slotFileNew() (this=<optimized out>) at /usr/src/debug/krita/krita-5.1.3/libs/ui/KisMainWindow.cpp:1703
#44 0x00007f6c744bdc00 in doActivate<false>(QObject*, int, void**) (sender=0x556af495dc20, signal_index=4, argv=0x7fff6af5e430) at kernel/qobject.cpp:3931
#45 0x00007f6c7516bec7 in QAction::triggered(bool) (this=this@entry=0x556af495dc20, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#46 0x00007f6c751718c7 in QAction::activate(QAction::ActionEvent) (this=0x556af495dc20, event=<optimized out>) at kernel/qaction.cpp:1161
#47 0x00007f6c7517198e in QAction::event(QEvent*) (e=<optimized out>, this=<optimized out>) at kernel/qaction.cpp:1086
#48 QAction::event(QEvent*) (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1075
#49 0x00007f6c75178b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x556a00000030, receiver=0x556af495dc20, e=0x7fff6af5e660, e@entry=0x556af495b700) at kernel/qapplication.cpp:3637
#50 0x00007f6c7517d1f1 in QApplication::notify(QObject*, QEvent*) (this=this@entry=0x7fff6af5eca0, receiver=receiver@entry=0x556af495dc20, e=0x556af495b700, e@entry=0x7fff6af5e660) at kernel/qapplication.cpp:3383
#51 0x00007f6c76419d8f in KisApplication::notify(QObject*, QEvent*) (this=0x7fff6af5eca0, receiver=0x556af495dc20, event=0x7fff6af5e660) at /usr/src/debug/krita/krita-5.1.3/libs/ui/KisApplication.cpp:757
#52 0x00007f6c7448cf98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x556af495dc20, event=0x7fff6af5e660) at kernel/qcoreapplication.cpp:1064
#53 0x00007f6c749742ed in QShortcutMap::dispatchEvent(QKeyEvent*) (this=<optimized out>, e=<optimized out>) at kernel/qshortcutmap.cpp:675
#54 0x00007f6c7496ab57 in QShortcutMap::tryShortcut(QKeyEvent*) (this=0x556aeef12698, e=0x7fff6af5e720) at kernel/qshortcutmap.cpp:343
#55 0x00007f6c7492a158 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) (window=<optimized out>, timestamp=743768, keyCode=78, modifiers=..., nativeScanCode=57, nativeVirtualKey=110, nativeModifiers=20, text=..., autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:477
#56 0x00007f6c7493fb22 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) (e=0x556af8b5a4a0) at kernel/qguiapplication.cpp:2398
#57 0x00007f6c74928985 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#58 0x00007f6c6eaec710 in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>) at /usr/src/debug/qt5-base/qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:105
#59 0x00007f6c7206d87b in g_main_dispatch (context=0x7f6c68005010) at ../glib/glib/gmain.c:3444
#60 g_main_context_dispatch (context=0x7f6c68005010) at ../glib/glib/gmain.c:4162
#61 0x00007f6c720c4279 in g_main_context_iterate.constprop.0 (context=0x7f6c68005010, block=1, dispatch=1, self=<optimized out>) at ../glib/glib/gmain.c:4238
#62 0x00007f6c7206c132 in g_main_context_iteration (context=0x7f6c68005010, may_block=1) at ../glib/glib/gmain.c:4303
#63 0x00007f6c744d7c4c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x556aeee78ba0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#64 0x00007f6c7448573c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7fff6af5ead0, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#65 0x00007f6c74490269 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#66 0x00007f6c7493a112 in QGuiApplication::exec() () at kernel/qguiapplication.cpp:1870
#67 0x00007f6c75176f2a in QApplication::exec() () at kernel/qapplication.cpp:2829
#68 0x0000556aedcae89f in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/krita/krita-5.1.3/krita/main.cc:721
[Inferior 1 (process 5341) detached]

Reported using DrKonqi
Comment 1 Halla Rempt 2022-12-08 14:50:39 UTC
https://bugs.kde.org/show_bug.cgi?id=459800 seems related -- I'll ask the author of the commit that closed that issue to look into this. The appimage has the kis_asserts compiled out, which is better for production builds, btw.
Comment 2 amyspark 2022-12-09 01:01:29 UTC
Halla, this is the ever elusive "clipboard is being cleared mid document creation" bug.

The backtrace shows the reporter is in a Catch-22 position: it's claiming that they've initiated a paste from clipboard, but the clipboard is empty by the time we access it. The safe assert that I added back then should have detected and ignored the situation, but it's not, and that's why I added the hard assertion that this bug hits on.

@sander.smid: are you closing the original document between copying and pasting? Do you have any other application active when the issue occurs?
Comment 3 amyspark 2022-12-22 20:20:14 UTC
To the reporter: I need to pin down what's clearing the clipboard mid-copy. Please ping back with the information requested.
Comment 4 amyspark 2022-12-22 20:24:48 UTC
Git commit 6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304 by L. E. Segovia.
Committed on 22/12/2022 at 20:24.
Pushed by lsegovia into branch 'master'.

KisImageFromClipboardWidget: stave off a clipboard being cleared mid-access

M  +10   -6    libs/ui/widgets/kis_image_from_clipboard_widget.cpp

https://invent.kde.org/graphics/krita/commit/6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304
Comment 5 Bug Janitor Service 2023-01-06 05:22:10 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2023-01-21 05:06:15 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!
Comment 7 amyspark 2023-02-01 20:48:10 UTC
Git commit dcd6535736ba797f889b8b80f43f9f25d38abab6 by L. E. Segovia.
Committed on 01/02/2023 at 20:47.
Pushed by lsegovia into branch 'krita/5.1'.

KisImageFromClipboardWidget: stave off a clipboard being cleared mid-access
Related: bug 465128

(cherry picked from commit 6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304)

M  +10   -6    libs/ui/widgets/kis_image_from_clipboard_widget.cpp

https://invent.kde.org/graphics/krita/commit/dcd6535736ba797f889b8b80f43f9f25d38abab6
Comment 8 amyspark 2023-12-14 03:25:39 UTC
Git commit f4f069cbea3dd961aed23e3abbc67460821b2da9 by L. E. Segovia.
Committed on 21/04/2023 at 00:40.
Pushed by lsegovia into branch 'master'.

KisClipboard: remove assert on clipboard being cleared

6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304 already covers it enough, so
it's safe to bail out now.
Related: bug 468494, bug 465128

M  +5    -1    libs/ui/kis_clipboard.cc

https://invent.kde.org/graphics/krita/commit/f4f069cbea3dd961aed23e3abbc67460821b2da9
Comment 9 amyspark 2023-12-14 03:25:39 UTC
Git commit f4f069cbea3dd961aed23e3abbc67460821b2da9 by L. E. Segovia.
Committed on 21/04/2023 at 00:40.
Pushed by lsegovia into branch 'master'.

KisClipboard: remove assert on clipboard being cleared

6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304 already covers it enough, so
it's safe to bail out now.
Related: bug 468494, bug 465128

M  +5    -1    libs/ui/kis_clipboard.cc

https://invent.kde.org/graphics/krita/commit/f4f069cbea3dd961aed23e3abbc67460821b2da9
Comment 10 amyspark 2023-12-14 03:26:03 UTC
Git commit d833fcb31161fbaedd738381613960daf9ac5fb7 by L. E. Segovia.
Committed on 21/04/2023 at 00:40.
Pushed by lsegovia into branch 'krita/5.1'.

KisClipboard: remove assert on clipboard being cleared

6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304 already covers it enough, so
it's safe to bail out now.
Related: bug 468494, bug 465128
(cherry picked from commit f4f069cbea3dd961aed23e3abbc67460821b2da9)

M  +5    -1    libs/ui/kis_clipboard.cc

https://invent.kde.org/graphics/krita/commit/d833fcb31161fbaedd738381613960daf9ac5fb7
Comment 11 amyspark 2023-12-14 03:26:04 UTC
Git commit d833fcb31161fbaedd738381613960daf9ac5fb7 by L. E. Segovia.
Committed on 21/04/2023 at 00:40.
Pushed by lsegovia into branch 'krita/5.1'.

KisClipboard: remove assert on clipboard being cleared

6399b0203e7c7e8fa6fc40e4fdbe4a72cae2f304 already covers it enough, so
it's safe to bail out now.
Related: bug 468494, bug 465128
(cherry picked from commit f4f069cbea3dd961aed23e3abbc67460821b2da9)

M  +5    -1    libs/ui/kis_clipboard.cc

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