Bug 434648 - Assert in lod counter
Summary: Assert in lod counter
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: git master (please specify the git hash!)
Platform: Mint (Ubuntu based) Linux
: NOR crash
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-20 02:03 UTC by Tiar
Modified: 2021-06-01 13:15 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Crash log for all threads (28.95 KB, text/plain)
2021-03-20 02:03 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2021-03-20 02:03:43 UTC
Created attachment 136869 [details]
Crash log for all threads

SUMMARY
I was using a Move Tool.

STEPS TO REPRODUCE
No known steps to reproduce.
I did however suspect some weird stuff regarding LOD. bounds and reference images (see bug 430988?), and the file I was working on did have reference images. It might be a red herring though.

OBSERVED RESULT
Assert

EXPECTED RESULT
No assert

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
There were two non-trivial threads this time.
---

SAFE ASSERT (krita): "m_newOpacity == other->m_oldOpacity" in file /home/tymon/kritadev/krita/libs/image/commands/kis_node_opacity_command.cpp, line 43
SAFE ASSERT (krita): "m_newOpacity == other->m_oldOpacity" in file /home/tymon/kritadev/krita/libs/image/commands/kis_node_opacity_command.cpp, line 43
SAFE ASSERT (krita): "m_newOpacity == other->m_oldOpacity" in file /home/tymon/kritadev/krita/libs/image/commands/kis_node_opacity_command.cpp, line 43
ASSERT: "lod == newLod" in file /home/tymon/kritadev/krita/libs/image/kis_lock_free_lod_counter.h, line 30

----

Thread 854 "Thread (pooled)" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffa7762700 (LWP 16313)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	../sysdeps/unix/sysv/linux/raise.c: Nie ma takiego pliku ani katalogu.
(gdb) bt
#0  0x00007ffff3d64ed7 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff3d46535 in __GI_abort () at abort.c:79
#2  0x00007ffff452e8d7 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007ffff452dd59 in qt_assert_x(char const*, char const*, char const*, int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff58e5d28 in KisLockFreeLodCounter::addLod(int) (newLod=<optimized out>, this=<optimized out>)
    at /home/tymon/kritadev/krita/libs/image/kis_lock_free_lod_counter.h:30
#5  0x00007ffff58e5d28 in KisUpdaterContext::addSpontaneousJob(KisSpontaneousJob*) (this=<optimized out>, spontaneousJob=0x555576594fe0)
    at /home/tymon/kritadev/krita/libs/image/kis_updater_context.cpp:160
#6  0x00007ffff5bb6f6b in KisSimpleUpdateQueue::processOneJob(KisUpdaterContext&) (this=0x55555d82da98, updaterContext=...)
    at /home/tymon/kritadev/krita/libs/image/kis_simple_update_queue.cpp:138
#7  0x00007ffff5bb722b in KisSimpleUpdateQueue::processQueue(KisUpdaterContext&) (this=0x55555d82da98, updaterContext=...)
    at /home/tymon/kritadev/krita/libs/image/kis_simple_update_queue.cpp:80
#8  0x00007ffff5bba03b in KisUpdateScheduler::tryProcessUpdatesQueue() (this=this@entry=0x555566c47de0)
    at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:441
#9  0x00007ffff5bba4b3 in KisUpdateScheduler::processQueues() (this=0x555566c47de0) at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:398
---Type <return> to continue, or q <return> to quit---
#10 0x00007ffff5bbad75 in KisUpdateScheduler::spareThreadAppeared() (this=<optimized out>)
    at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:467
#11 0x00007ffff5ba4e46 in KisUpdaterContext::jobFinished() (this=<optimized out>) at /home/tymon/kritadev/krita/libs/image/kis_updater_context.cpp:243
#12 0x00007ffff5e098c8 in KisUpdateJobItem::run() (this=0x55555e44ed70)
    at /home/tymon/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/../../../../../krita/libs/image/kis_update_job_item.h:99
#13 0x00007ffff4567f71 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#14 0x00007ffff456fc87 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007ffff18bd182 in start_thread (arg=<optimized out>)
    at pthread_create.c:486
#16 0x00007ffff3e3eb1f in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

-----

Thread 1 (Thread 0x7fffeb051800 (LWP 6040)):

#0  0x00007ffff3e382e9 in syscall ()
    at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007ffff4562c25 in QBasicMutex::lockInternal() ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007ffff5bb502f in QMutexLocker::QMutexLocker(QBasicMutex*) (m=0x55555d82daa0, this=<synthetic pointer>)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qmutex.h:206
#3  0x00007ffff5bb502f in KisSimpleUpdateQueue::sizeMetric() const (this=0x55555d82da98)
    at /home/tymon/kritadev/krita/libs/image/kis_simple_update_queue.cpp:242
#4  0x00007ffff5bba473 in KisUpdateScheduler::processQueues() (this=this@entry=0x555566c47de0)
    at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:61

#5  0x00007ffff5bbadc1 in KisUpdateScheduler::startStroke(KisStrokeStrategy*) (this=0x555566c47de0, strokeStrategy=<optimized out>)
    at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:210
#6  0x00007ffff5be6442 in KisImage::startStroke(KisStrokeStrategy*) (this=0x55555c8f9d20, strokeStrategy=0x7fffcc008820)
    at /home/tymon/kritadev/krita/libs/image/kis_image.cc:1779
#7  0x00007fffdc50587c in KisToolMove::startStrokeImpl(KisToolMove::MoveToolMode, QPoint const*) (this=0x555571a92310, mode=KisToolMove::MoveSelectedLayer, pos=0x7fffffffc788)
---Type <return> to continue, or q <return> to quit---
    at /home/tymon/kritadev/krita/plugins/tools/basictools/kis_tool_move.cc:238

#8  0x00007fffdc506335 in KisToolMove::startAction(KoPointerEvent*, KisToolMove::MoveToolMode) (this=0x555571a92310, event=0x7fffffffc7f0, mode=KisToolMove::MoveSelectedLayer)
    at /home/tymon/kritadev/krita/plugins/tools/basictools/kis_tool_move.cc:527
#9  0x00007ffff6ba6483 in KisToolProxy::forwardToTool(KisToolProxy::ActionState, KisTool::ToolAction, QEvent*, QPointF const&) (this=0x55556b886c70, state=KisToolProxy::BEGIN, action=KisTool::Primary, event=0x7fffffffd410, docPoint=...)
    at /home/tymon/kritadev/krita/libs/ui/canvas/kis_tool_proxy.cpp:172
#10 0x00007ffff6ba65eb in KisToolProxy::forwardEvent(KisToolProxy::ActionState, KisTool::ToolAction, QEvent*, QEvent*) (this=0x55556b886c70, state=KisToolProxy::BEGIN, action=KisTool::Primary, event=<optimized out>, originalEvent=0x7fffffffd410) at /home/tymon/kritadev/krita/libs/ui/canvas/kis_tool_proxy.cpp:121
#11 0x00007ffff6f7d331 in KisToolInvocationAction::begin(int, QEvent*) (this=<optimized out>, shortcut=<optimized out>, event=0x7fffffffd410)
    at /usr/include/c++/8/bits/atomic_base.h:390
#12 0x00007ffff6f8dafa in KisShortcutMatcher::tryRunReadyShortcut(Qt::MouseButton, QEvent*) (this=0x55555a2d9a40, button=Qt::LeftButton, event=0x7fffffffd410)
    at /home/tymon/kritadev/krita/libs/ui/input/kis_shortcut_matcher.cpp:636
#13 0x00007ffff6f8dd34 in KisShortcutMatcher::buttonPressed(Qt::MouseButton, QEvent*) (this=0x55555a2d9a40, button=Qt::LeftButton, event=0x7fffffffd410)
    at /home/tymon/kritadev/krita/libs/ui/input/kis_shortcut_matcher.cpp:259
#14 0x00007ffff6f6d0ff in KisInputManager::eventFilterImpl(QEvent*) [clone .loca---Type <return> to continue, or q <return> to quit---
lalias.272] (this=0x55555a2e1208, event=0x7fffffffd410)
    at /usr/include/x86_64-linux-gnu/qt5/QtGui/qevent.h:132
#15 0x00007ffff47181ab in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x00007ffff50d7491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff50ded28 in QApplication::notify(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff6ff7f17 in KisApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0x55556bf19f30, event=0x7fffffffd410)
    at /home/tymon/kritadev/krita/libs/ui/KisApplication.cpp:711
#19 0x00007ffff4718499 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007ffff50de029 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff5130304 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007ffff5132e8e in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007ffff50d74a1 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff50deae0 in QApplication::notify(QObject*, QEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff6ff7f17 in KisApplication::notify(QObject*, QEvent*) (this=<optim---Type <return> to continue, or q <return> to quit---
ized out>, receiver=0x55555fc97dd0, event=0x7fffffffd890)
    at /home/tymon/kritadev/krita/libs/ui/KisApplication.cpp:711
#26 0x00007ffff4718499 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007ffff4b1d53b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#28 0x00007ffff4b1f435 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
    at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#29 0x00007ffff4af9b6b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#30 0x00007fffea761e5b in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#31 0x00007ffff471716b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007ffff471f2e2 in QCoreApplication::exec() ()
    at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#33 0x0000555555e2a21b in main (argc=<optimized out>, argv=0x7fffffffde48)
    at /home/tymon/kritadev/krita/krita/main.cc:663
#34 0x00007ffff3d47b6b in __libc_start_main (main=
    0x555555e28890 <main>, argc=1, argv=0x7fffffffde48, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde38)
    at ../csu/libc-start.c:308
#35 0x0000555555e2b2da in _start ()
---Type <return> to continue, or q <return> to quit---
    at /home/tymon/kritadev/krita/krita/main.cc:468
Comment 1 Dmitry Kazakov 2021-05-21 10:53:27 UTC
Git commit 96d2a09d7eb20543051489d0d21651a4c49bf636 by Dmitry Kazakov.
Committed on 21/05/2021 at 10:52.
Pushed by dkazakov into branch 'master'.

Fix a race condition when starting spontaneous jobs

When starting any job we should always explicitly compare the
status of the current level of detail. Just the fact that there
is no merge/stroke jobs in the updater context is not enough.

It happens because an update job transitions into an empty state in
three stages. Firstly, it is marked as WAITING, then its lod ticket
is removed from the updater context, and, finally, if it is not
assigned with any nice task again, it switches into EMPTY state.

Between the first and the second states there is a short fragile
period when getJobsSnapshot() will return nothing, but
currentLevelOfDetail() will still return LoD of the latest job.
This state is "okay", we just need to restart queue processing in
this case.

M  +5    -2    libs/image/kis_simple_update_queue.cpp

https://invent.kde.org/graphics/krita/commit/96d2a09d7eb20543051489d0d21651a4c49bf636
Comment 2 Dmitry Kazakov 2021-06-01 13:15:12 UTC
Git commit 4af3922863f461bfc3852a1d2c538fbb65050a49 by Dmitry Kazakov.
Committed on 01/06/2021 at 12:07.
Pushed by dkazakov into branch 'krita/4.3'.

Fix a race condition when starting spontaneous jobs

When starting any job we should always explicitly compare the
status of the current level of detail. Just the fact that there
is no merge/stroke jobs in the updater context is not enough.

It happens because an update job transitions into an empty state in
three stages. Firstly, it is marked as WAITING, then its lod ticket
is removed from the updater context, and, finally, if it is not
assigned with any nice task again, it switches into EMPTY state.

Between the first and the second states there is a short fragile
period when getJobsSnapshot() will return nothing, but
currentLevelOfDetail() will still return LoD of the latest job.
This state is "okay", we just need to restart queue processing in
this case.

M  +5    -2    libs/image/kis_simple_update_queue.cpp

https://invent.kde.org/graphics/krita/commit/4af3922863f461bfc3852a1d2c538fbb65050a49