Bug 419021 - Crash on closing a document
Summary: Crash on closing a document
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Color models (show other bugs)
Version: git master (please specify the git hash!)
Platform: Mint (Ubuntu based) Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-19 14:37 UTC by Tiar
Modified: 2021-06-01 13:15 UTC (History)
3 users (show)

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


Attachments
gdb backtrace - thread apply all bt (52.42 KB, text/plain)
2020-03-19 14:37 UTC, Tiar
Details
gdb backtrace - thread apply all bt full (83.68 KB, text/plain)
2020-03-19 14:46 UTC, Tiar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tiar 2020-03-19 14:37:58 UTC
Created attachment 126890 [details]
gdb backtrace - thread apply all bt

SUMMARY
I was just closing documents that I was making a mockup (https://phabricator.kde.org/M168) in. Some of them were with vector shapes, some only pixel, some of them 32bit with linear profiles, some of them 8bit integer sRGB, some of them converted from 32bit to 8bit. The one that Krita crashed on seems to be still 32bit.



STEPS TO REPRODUCE
???

OBSERVED RESULT
Crash

EXPECTED RESULT
No crash! :)

SOFTWARE/OS VERSIONS
Linux Mint 19.3
Krita master a481571


ADDITIONAL INFORMATION
Backtrace in the attachment.

Parts of the backtrace below:

#0  0x0000000000000064 in  ()
#1  0x00007ffff6c33fec in KisCanvasUpdatesCompressor::putUpdateInfo(KisSharedPtr<KisUpdateInfo>) (this=0x55556f4d9a10, info=...) at /home/tymon/kritadev/krita/libs/global/kis_shared_ptr.h:179
#2  0x00007ffff6c2b174 in KisCanvas2::startUpdateCanvasProjection(QRect const&) (this=0x555576fb64a8, rc=...) at /usr/include/c++/8/bits/atomic_base.h:295
#3  0x00007ffff48e86db in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff5eee4c2 in KisImage::sigImageUpdated(QRect const&) (this=this@entry=0x555582de9ff0, _t1=...) at /home/tymon/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/moc_kis_image.cpp:702
#5  0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (rc=..., this=0x555582de9ff0) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2013
#6  0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (this=0x555582de9ff0, rc=...) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2003
#7  0x00007ffff5cc271e in KisUpdateScheduler::continueUpdate(QRect const&) (this=<optimized out>, rect=...) at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:457
#8  0x00007ffff5ef5b1b in non-virtual thunk to KisUpdateJobItem::run() () at /usr/include/c++/8/bits/atomic_base.h:295
#9  0x00007ffff470ef71 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff4716c87 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff1992164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#12 0x00007ffff3fe3def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95


Thread 2739 (Thread 0x7fff80b34700 (LWP 5865)):
#0  0x00007fffd4e79101 in cmsEvalToneCurveFloat () at /usr/lib/x86_64-linux-gnu/liblcms2.so.2
#1  0x00007fffd4e8259d in  () at /usr/lib/x86_64-linux-gnu/liblcms2.so.2
#2  0x00007fffd4e81e52 in  () at /usr/lib/x86_64-linux-gnu/liblcms2.so.2
#3  0x00007fffd4e8f480 in  () at /usr/lib/x86_64-linux-gnu/liblcms2.so.2
#4  0x00007fffd4e8ffc6 in cmsDoTransform () at /usr/lib/x86_64-linux-gnu/liblcms2.so.2
#5  0x00007ffff2b9bee2 in KoColorSpace::convertPixelsTo(unsigned char const*, unsigned char*, KoColorSpace const*, unsigned int, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) const (this=<optimized out>, src=0x7fff13eff010 "իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?"..., dst=0x7fff130ff010 "\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?"..., dstColorSpace=0x55556e378a00, numPixels=65536, renderingIntent=KoColorConversionTransformation::IntentPerceptual, conversionFlags=...)
    at /home/tymon/kritadev/krita/libs/pigment/KoColorSpace.cpp:430
#6  0x00007fffd598ce31 in KoColorSpaceAbstract<KoRgbF32Traits>::convertPixelsTo(unsigned char const*, unsigned char*, KoColorSpace const*, unsigned int, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) const (this=0x5555599ec4e0, src=0x7fff13eff010 "իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?իT?\315\314\314>իT?իT?"..., dst=0x7fff130ff010 "\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?\357Ek?\315\314\314>\334Hk?\006Ok?"..., dstColorSpace=0x55556e378a00, numPixels=65536, renderingIntent=KoColorConversionTransformation::IntentPerceptual, conversionFlags=...) at /home/tymon/kritadev/krita/interfaces/KoID.h:35
#7  0x00007ffff6eaacea in KisTextureTileUpdateInfo::convertTo(KoColorSpace const*, KoColorConversionTransformation::Intent, QFlags<KoColorConversionTransformation::ConversionFlag>) (conversionFlags=..., renderingIntent=<optimized out>, dstCS=<optimized out>, this=<optimized out>) at /home/tymon/kritadev/krita/libs/ui/opengl/kis_texture_tile_update_info.h:94
#8  0x00007ffff6eaacea in KisOpenGLUpdateInfoBuilder::buildUpdateInfo(QRect const&, KisSharedPtr<KisPaintDevice>, QRect const&, int, bool) (this=0x5555833216d8, rect=..., projection=..., bounds=..., levelOfDetail=0, convertColorSpace=<optimized out>) at /home/tymon/kritadev/krita/libs/ui/opengl/KisOpenGLUpdateInfoBuilder.cpp:160
#9  0x00007ffff6eab57f in KisOpenGLUpdateInfoBuilder::buildUpdateInfo(QRect const&, KisSharedPtr<KisImage>, bool) (this=0x5555833216d8, rect=..., srcImage=..., convertColorSpace=<optimized out>)
    at /home/tymon/kritadev/krita/libs/global/kis_shared_ptr.h:179
#10 0x00007ffff6e9c279 in KisOpenGLImageTextures::updateCacheImpl(QRect const&, KisSharedPtr<KisImage>, bool) (this=<optimized out>, rect=..., srcImage=..., convertColorSpace=true) at /usr/include/c++/8/bits/atomic_base.h:295
#11 0x00007ffff6e9c33a in KisOpenGLImageTextures::updateCache(QRect const&, KisSharedPtr<KisImage>) (this=<optimized out>, rect=..., srcImage=...) at /usr/include/c++/8/bits/atomic_base.h:295
#12 0x00007ffff6e91e62 in KisOpenGLCanvas2::startUpdateCanvasProjection(QRect const&, QBitArray const&) (this=0x55556b5b5970, rc=..., channelFlags=...) at /home/tymon/kritadev/krita/libs/global/kis_shared_ptr.h:179
#13 0x00007ffff6c2b14b in KisCanvas2::startUpdateCanvasProjection(QRect const&) (this=0x555576fb64a8, rc=...) at /home/tymon/kritadev/krita/libs/ui/canvas/kis_canvas2.cpp:775
---Type <return> to continue, or q <return> to quit---
#14 0x00007ffff48e86db in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007ffff5eee4c2 in KisImage::sigImageUpdated(QRect const&) (this=this@entry=0x555582de9ff0, _t1=...) at /home/tymon/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/moc_kis_image.cpp:702
#16 0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (rc=..., this=0x555582de9ff0) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2013
#17 0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (this=0x555582de9ff0, rc=...) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2003
#18 0x00007ffff5cc271e in KisUpdateScheduler::continueUpdate(QRect const&) (this=<optimized out>, rect=...) at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:457
#19 0x00007ffff5ef5b1b in non-virtual thunk to KisUpdateJobItem::run() () at /usr/include/c++/8/bits/atomic_base.h:295
#20 0x00007ffff470ef71 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007ffff4716c87 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#22 0x00007ffff1992164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#23 0x00007ffff3fe3def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95


Thread 2740 (Thread 0x7fff72c61700 (LWP 5866)):
#0  0x00007ffff19982eb in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7fffa80025e0) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  0x00007ffff19982eb in __pthread_cond_wait_common (abstime=0x0, mutex=0x7fffa8002590, cond=0x7fffa80025b8) at pthread_cond_wait.c:502
#2  0x00007ffff19982eb in __pthread_cond_wait (cond=0x7fffa80025b8, mutex=0x7fffa8002590) at pthread_cond_wait.c:655
#3  0x00007ffff471743b in QWaitCondition::wait(QMutex*, unsigned long) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff470a462 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007ffff470b033 in QReadWriteLock::tryLockForWrite(int) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007ffff6ea8874 in QWriteLocker::relock() (this=<synthetic pointer>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qreadwritelock.h:157
#7  0x00007ffff6ea8874 in QWriteLocker::QWriteLocker(QReadWriteLock*) (areadWriteLock=<optimized out>, this=<synthetic pointer>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qreadwritelock.h:170
#8  0x00007ffff6ea8874 in KisOpenGLUpdateInfoBuilder::setChannelFlags(QBitArray const&, bool, int) (this=0x5555833216d8, channelFrags=..., onlyOneChannelSelected=<optimized out>, selectedChannelIndex=-1)
    at /home/tymon/kritadev/krita/libs/ui/opengl/KisOpenGLUpdateInfoBuilder.cpp:225
#9  0x00007ffff6e9cce1 in KisOpenGLImageTextures::setChannelFlags(QBitArray const&) (this=0x555583321640, channelFlags=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qarraydata.h:255
#10 0x00007ffff6e91da6 in KisOpenGLCanvas2::startUpdateCanvasProjection(QRect const&, QBitArray const&) (this=0x55556b5b5970, rc=..., channelFlags=...) at /home/tymon/kritadev/krita/libs/global/kis_shared_ptr.h:179
#11 0x00007ffff6c2b14b in KisCanvas2::startUpdateCanvasProjection(QRect const&) (this=0x555576fb64a8, rc=...) at /home/tymon/kritadev/krita/libs/ui/canvas/kis_canvas2.cpp:775
#12 0x00007ffff48e86db in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#13 0x00007ffff5eee4c2 in KisImage::sigImageUpdated(QRect const&) (this=this@entry=0x555582de9ff0, _t1=...) at /home/tymon/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/moc_kis_image.cpp:702
#14 0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (rc=..., this=0x555582de9ff0) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2013
#15 0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (this=0x555582de9ff0, rc=...) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2003
#16 0x00007ffff5cc271e in KisUpdateScheduler::continueUpdate(QRect const&) (this=<optimized out>, rect=...) at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:457
#17 0x00007ffff5ef5b1b in non-virtual thunk to KisUpdateJobItem::run() () at /usr/include/c++/8/bits/atomic_base.h:295
#18 0x00007ffff470ef71 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff4716c87 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007ffff1992164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#21 0x00007ffff3fe3def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Comment 1 Halla Rempt 2020-03-19 14:39:52 UTC
This is the only relevant bit of the backtrace

Thread 2738 (Thread 0x7fff8bb05700 (LWP 5864)):
#0  0x0000000000000064 in  ()
#1  0x00007ffff6c33fec in KisCanvasUpdatesCompressor::putUpdateInfo(KisSharedPtr<KisUpdateInfo>) (this=0x55556f4d9a10, info=...) at /home/tymon/kritadev/krita/libs/global/kis_shared_ptr.h:179
#2  0x00007ffff6c2b174 in KisCanvas2::startUpdateCanvasProjection(QRect const&) (this=0x555576fb64a8, rc=...) at /usr/include/c++/8/bits/atomic_base.h:295
#3  0x00007ffff48e86db in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007ffff5eee4c2 in KisImage::sigImageUpdated(QRect const&) (this=this@entry=0x555582de9ff0, _t1=...) at /home/tymon/kritadev/build/libs/image/kritaimage_autogen/EWIEGA46WW/moc_kis_image.cpp:702
#5  0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (rc=..., this=0x555582de9ff0) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2013
#6  0x00007ffff5ce1005 in KisImage::notifyProjectionUpdated(QRect const&) (this=0x555582de9ff0, rc=...) at /home/tymon/kritadev/krita/libs/image/kis_image.cc:2003
#7  0x00007ffff5cc271e in KisUpdateScheduler::continueUpdate(QRect const&) (this=<optimized out>, rect=...) at /home/tymon/kritadev/krita/libs/image/kis_update_scheduler.cpp:457
#8  0x00007ffff5ef5b1b in non-virtual thunk to KisUpdateJobItem::run() () at /usr/include/c++/8/bits/atomic_base.h:295
#9  0x00007ffff470ef71 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff4716c87 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#11 0x00007ffff1992164 in start_thread (arg=<optimized out>) at pthread_create.c:486
#12 0x00007ffff3fe3def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Comment 2 Tiar 2020-03-19 14:46:06 UTC
Created attachment 126891 [details]
gdb backtrace - thread apply all bt full
Comment 3 wolthera 2020-04-24 12:35:27 UTC
Since we have a backtrace, I'll set to confirmed.
Comment 4 Dmitry Kazakov 2021-05-21 05:03:14 UTC
Okay, the crash happens because KisOpenGLCanvas2 object is being destroyed while KisImage is still sending updates to it. I need to do the inventory of the object ownership in the canvas code.
Comment 5 Dmitry Kazakov 2021-05-21 08:28:06 UTC
Git commit 87175ca767bf6ed2c8738f81a9b957faaf84e7db by Dmitry Kazakov.
Committed on 21/05/2021 at 08:27.
Pushed by dkazakov into branch 'master'.

Fix crash when closing Krita too quickly while some stroke is still rendering

KisCanvas2 is directly connected to the image, therefore, it should not
be destroyed before the the connection is removed and all the callers
has completed their requests.

M  +6    -1    libs/ui/KisView.cpp
M  +16   -0    libs/ui/canvas/kis_canvas2.cpp
M  +1    -0    libs/ui/canvas/kis_canvas2.h

https://invent.kde.org/graphics/krita/commit/87175ca767bf6ed2c8738f81a9b957faaf84e7db
Comment 6 Dmitry Kazakov 2021-06-01 13:15:04 UTC
Git commit fd21c4a8ce2cdc9e2594c4e0899aa509fe82ce6d by Dmitry Kazakov.
Committed on 01/06/2021 at 12:06.
Pushed by dkazakov into branch 'krita/4.3'.

Fix crash when closing Krita too quickly while some stroke is still rendering

KisCanvas2 is directly connected to the image, therefore, it should not
be destroyed before the the connection is removed and all the callers
has completed their requests.

# Conflicts:
#	libs/ui/KisView.cppgit

M  +6    -0    libs/ui/KisView.cpp
M  +16   -0    libs/ui/canvas/kis_canvas2.cpp
M  +1    -0    libs/ui/canvas/kis_canvas2.h

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