Bug 469647

Summary: Crash on minimizing Krita window
Product: [Applications] krita Reporter: Freya Lupen <penguinflyer2222>
Component: GeneralAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: crash CC: halla, lynx.mw+kde
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Freya Lupen 2023-05-12 04:38:08 UTC
SUMMARY
With a document open, minimizing the window can cause Krita to crash.
Given the backtrace is in KisIdleTasksManager, it's probably related to the recent set of commits which added it.

Backtrace:

> * thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ff8ac0f8b5e: Access violation reading location 0x241a499f000
>   * frame #0: 0x00007ff8ac0f8b5e ucrtbase.dll`memcmp + 238
>     frame #1: 0x00007ff80a8dcd74 Qt5Core.dll`QListData::erase(void**) [inlined] QListData::remove(int) at qlist.cpp:282:13
>     frame #2: 0x00007ff80a8dcd59 Qt5Core.dll`QListData::erase(void**) at qlist.cpp:347:5
>     frame #3: 0x00007ff81c84e66f libkritaui.dll`KisIdleTasksManager::slotImageIsIdle() [inlined] QList<int>::takeFirst(this=0x00000241c5e45e50) at qlist.h:603:29
>     frame #4: 0x00007ff81c84e5f1 libkritaui.dll`KisIdleTasksManager::slotImageIsIdle() [inlined] QQueue<int>::dequeue(this=0x00000241c5e45e50) at qqueue.h:60:43
>     frame #5: 0x00007ff81c84e5f1 libkritaui.dll`KisIdleTasksManager::slotImageIsIdle(this=0x00000241c5e379b8) at KisIdleTasksManager.cpp:112:41
>     frame #6: 0x00007ff80aa90cbb Qt5Core.dll`void doActivate<false>(QObject*, int, void**) at qobject.cpp:3931:21
>     frame #7: 0x00007ff80aa90cbb Qt5Core.dll`void doActivate<false>(QObject*, int, void**) at qobject.cpp:3931:21
>     frame #8: 0x00007ff80aa95ee4 Qt5Core.dll`QTimer::timerEvent(QTimerEvent*) [inlined] QTimer::timeout(QTimer::QPrivateSignal) at moc_qtimer.cpp:205:5
>     frame #9: 0x00007ff80aa95eba Qt5Core.dll`QTimer::timerEvent(QTimerEvent*) at qtimer.cpp:257:14
>     frame #10: 0x00007ff80aa85a6f Qt5Core.dll`QObject::event(QEvent*) at qobject.cpp:1324:9
>     frame #11: 0x00007ff80e3ec5a3 Qt5Widgets.dll`QApplicationPrivate::notify_helper(QObject*, QEvent*) at qapplication.cpp:3637:26
>     frame #12: 0x00007ff80e3ed823 Qt5Widgets.dll`QApplication::notify(QObject*, QEvent*) at qapplication.cpp:0
>     frame #13: 0x00007ff81cadab88 libkritaui.dll`KisApplication::notify(this=0x0000006e68d4f870, receiver=0x00000241c5e46480, event=0x0000006e68d4c220) at KisApplication.cpp:0
>     frame #14: 0x00007ff80aa5dfb2 Qt5Core.dll`QCoreApplication::notifyInternal2(QObject*, QEvent*) at qcoreapplication.cpp:1064:18
>     frame #15: 0x00007ff80aab18e3 Qt5Core.dll`QEventDispatcherWin32Private::sendTimerEvent(int) at qeventdispatcher_win.cpp:430:9
>     frame #16: 0x00007ff80aab1555 Qt5Core.dll`qt_internal_proc(HWND__*, unsigned int, unsigned long long, long long) at qeventdispatcher_win.cpp:256:16
>     frame #17: 0x00007ff8adf7e858 user32.dll`CallWindowProcW + 1016
>     frame #18: 0x00007ff8adf7e299 user32.dll`DispatchMessageW + 601
>     frame #19: 0x00007ff80aab2708 Qt5Core.dll`QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at qeventdispatcher_win.cpp:595:21
>     frame #20: 0x00007ff83d998295 qwindows.dll`qt_plugin_instance + 11253
>     frame #21: 0x00007ff80aa5b236 Qt5Core.dll`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at qeventloop.cpp:139:55
>     frame #22: 0x00007ff80aa5b217 Qt5Core.dll`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) at qeventloop.cpp:232:9
>     frame #23: 0x00007ff80aa5e54d Qt5Core.dll`QCoreApplication::exec() at qcoreapplication.cpp:1375:32
>     frame #24: 0x00007ff8457f5569 krita.dll`::krita_main(argc=<unavailable>, argv=0x00000241ba3fcf80) at main.cc:717:17
>     frame #25: 0x00007ff6c2a313d6 krita.com`__tmainCRTStartup at crtexe.c:329:15
>     frame #26: 0x00007ff6c2a31426 krita.com`mainCRTStartup at crtexe.c:206:9
>     frame #27: 0x00007ff8ae177614 kernel32.dll`BaseThreadInitThunk + 20
>     frame #28: 0x00007ff8ae7226a1 ntdll.dll`RtlUserThreadStart + 33


STEPS TO REPRODUCE
1. Open a document.
2. Minimize the window. It might take a few attempts, or crash the first time.

OBSERVED RESULT
Instant crash.

EXPECTED RESULT
No crash.

SOFTWARE/OS VERSIONS
Krita 5.2.0-prealpha git f0a28f5a.

ADDITIONAL INFORMATION
Comment 1 Halla Rempt 2023-05-12 07:08:02 UTC
Dmitry, please take a look.
Comment 2 Lynx3d 2023-05-13 17:18:37 UTC
Well I didn't manage to reproduce the crash by minimizing krita, but after working a bit and switching focus to a different application window, it of course caught me just before I wanted to save my work :P

#4  __pthread_kill_implementation (no_tid=0, signo=6, threadid=139760608016512) at ./nptl/pthread_kill.c:44
#5  __pthread_kill_internal (signo=6, threadid=139760608016512) at ./nptl/pthread_kill.c:78
#6  __GI___pthread_kill (threadid=139760608016512, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#7  0x00007f1c92b0e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#8  0x00007f1c92af47f3 in __GI_abort () at ./stdlib/abort.c:79
#9  0x00007f1c92fd0bff in  () at /opt/qt515-kde/lib/libQt5Core.so.5
#10 0x00007f1c92fcfff0 in qt_assert_x(char const*, char const*, char const*, int) () at /opt/qt515-kde/lib/libQt5Core.so.5
#11 0x00007f1c94f93710 in QList<int>::first() (this=0x564487637810) at /opt/qt515-kde/include/QtCore/qlist.h:361
#12 QList<int>::takeFirst() (this=0x564487637810) at /opt/qt515-kde/include/QtCore/qlist.h:603
#13 QQueue<int>::dequeue() (this=<optimized out>) at /opt/qt515-kde/include/QtCore/qqueue.h:60
#14 KisIdleTasksManager::slotImageIsIdle() (this=0x564487748430) at /home/lynx/coding/krita/krita-git/libs/ui/KisIdleTasksManager.cpp:112
#15 0x00007f1c932323b8 in  () at /opt/qt515-kde/lib/libQt5Core.so.5
#16 0x00007f1c932323b8 in  () at /opt/qt515-kde/lib/libQt5Core.so.5
#17 0x00007f1c932363fe in QTimer::timeout(QTimer::QPrivateSignal) () at /opt/qt515-kde/lib/libQt5Core.so.5
#18 0x00007f1c93227dbf in QObject::event(QEvent*) () at /opt/qt515-kde/lib/libQt5Core.so.5
#19 0x00007f1c93d3b7a3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /opt/qt515-kde/lib/libQt5Widgets.so.5
#20 0x00007f1c95644345 in KisApplication::notify(QObject*, QEvent*) (this=0x7ffe8e757610, receiver=0x56448773aae0, event=0x7ffe8e7571a0) at /home/lynx/coding/krita/krita-git/libs/ui/KisApplication.cpp:768
#21 0x00007f1c931fa78a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /opt/qt515-kde/lib/libQt5Core.so.5
#22 0x00007f1c93252fdb in QTimerInfoList::activateTimers() () at /opt/qt515-kde/lib/libQt5Core.so.5
#23 0x00007f1c932538dc in  () at /opt/qt515-kde/lib/libQt5Core.so.5
#24 0x00007f1c9059dd3b in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007f1c905f26c8 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#26 0x00007f1c9059b3e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x00007f1c93253ca8 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /opt/qt515-kde/lib/libQt5Core.so.5
#28 0x00007f1c931f90ab in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /opt/qt515-kde/lib/libQt5Core.so.5
#29 0x00007f1c93201644 in QCoreApplication::exec() () at /opt/qt515-kde/lib/libQt5Core.so.5
#30 0x000056448354c73e in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /home/lynx/coding/krita/krita-git/krita/main.cc:717
Comment 3 Dmitry Kazakov 2023-05-16 14:38:11 UTC
Hi, Freya!

Thank you for your report! I have just fixed the bug in
https://invent.kde.org/graphics/krita/-/commit/0e564cea6ee24d57b388662d1bd4b5767d55fed2