Summary: | Krita crash sometime when opening brush settings | ||
---|---|---|---|
Product: | [Applications] krita | Reporter: | Defresne Thierry <defresne.thierry> |
Component: | General | Assignee: | Krita Bugs <krita-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | 4.3.0 | ||
Target Milestone: | --- | ||
Platform: | Appimage | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/graphics/krita/commit/f717b0385683562bba951130343aff2fd4639c38 | Version Fixed In: | |
Sentry Crash Report: | |||
Attachments: |
patch
masking brush overflow fix |
Description
Defresne Thierry
2020-06-27 08:22:31 UTC
A more helpful backtrace: Thread 1 "krita" received signal SIGSEGV, Segmentation fault. 0x00007ffff2da8911 in __memset_avx2_erms () from /usr/lib/libc.so.6 (gdb) thread apply 1 bt Thread 1 (Thread 0x7fffef50e880 (LWP 127540)): #0 0x00007ffff2da8911 in __memset_avx2_erms () from /usr/lib/libc.so.6 #1 0x00007ffff6061966 in KisFixedPaintDevice::initialize (this=0x5555621d1840, defaultValue=defaultValue@entry=0 '\000') at /usr/include/qt/QtCore/qrect.h:269 #2 0x00007ffff622e847 in KisAutoBrush::createBrushPreview (this=0x55556060dcf0) at /home/vxdcxw/kritadev/krita/libs/global/kis_shared_ptr.h:179 #3 0x00007ffff622f387 in KisAutoBrush::KisAutoBrush (this=0x55556060dcf0, as=0x7fffffffcb10, angle=0, randomness=0, density=1) at /home/vxdcxw/kritadev/krita/libs/brush/kis_auto_brush.cpp:93 #4 0x00007ffff624802e in KisAutoBrushFactory::createBrush (this=<optimized out>, brushDefinition=..., resourcesInterface=...) at /home/vxdcxw/kritadev/krita/libs/brush/kis_auto_brush_factory.cpp:41 #5 0x00007ffff6233890 in KisBrushRegistry::createBrush (this=0x7ffff625a220 <(anonymous namespace)::Q_QGS_s_instance::innerFunction()::holder>, element=..., resourcesInterface=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #6 0x00007ffff6231af6 in KisBrush::fromXML (element=..., resourcesInterface=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #7 0x00007fffdff87042 in KisBrushOptionProperties::readOptionSettingResourceImpl (this=0x7fffffffcdd0, setting=<optimized out>, resourcesInterface=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #8 0x00007ffff6f1b1f5 in KisPaintopPropertiesResourcesBase::readOptionSetting (this=<optimized out>, settings=..., resourcesInterface=...) at /usr/include/qt/QtCore/qsharedpointer_impl.h:158 #9 0x00007fffdffc1478 in KisMaskingBrushOptionProperties::read (this=this@entry=0x7fffffffce40, setting=0x5555664a9b50, masterBrushSize=583, resourcesInterface=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #10 0x00007fffdffc021f in KisMaskingBrushOption::readOptionSetting (this=0x555564364630, setting=...) at /home/vxdcxw/kritadev/krita/libs/global/kis_shared_ptr.h:155 #11 0x00007ffff6fa23f4 in KisPaintOpOption::startReadOptionSetting (this=this@entry=0x555564364630, setting=...) at /home/vxdcxw/kritadev/krita/libs/ui/kis_paintop_option.cpp:75 #12 0x00007ffff6fa51ae in KisPaintOpSettingsWidget::setConfiguration (this=0x555564247b30, config=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #13 0x00007ffff5f288a0 in KisPaintOpConfigWidget::setConfigurationSafe (this=this@entry=0x555564247b30, config=...) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #14 0x00007ffff6f94884 in KisPaintopBox::slotUpdateOptionsWidgetPopup (this=0x55555983acc0) at /usr/include/c++/10.1.0/bits/atomic_base.h:325 #15 0x00007ffff342f940 in ?? () from /usr/lib/libQt5Core.so.5 #16 0x00007ffff3f10c7e in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5 #17 0x00007ffff3ecf702 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #18 0x00007ffff7123c29 in KisApplication::notify (this=<optimized out>, receiver=0x55555a62f990, event=0x7fffffffd2e0) at /home/vxdcxw/kritadev/krita/libs/ui/KisApplication.cpp:736 #19 0x00007ffff33f869a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5 #20 0x00007ffff3f0d4c8 in QWidgetPrivate::show_helper() () from /usr/lib/libQt5Widgets.so.5 #21 0x00007ffff3f0d41a in QWidgetPrivate::showChildren(bool) () from /usr/lib/libQt5Widgets.so.5 #22 0x00007ffff3f0d4a2 in QWidgetPrivate::show_helper() () from /usr/lib/libQt5Widgets.so.5 #23 0x00007ffff3f107d5 in QWidgetPrivate::setVisible(bool) () from /usr/lib/libQt5Widgets.so.5 #24 0x00007ffff559a5f9 in KisPopupButton::showPopupWidget (this=0x5555589b6390) at /usr/include/qt/QtCore/qscopedpointer.h:116 #25 0x00007ffff342f940 in ?? () from /usr/lib/libQt5Core.so.5 #26 0x00007ffff3fc196f in ?? () from /usr/lib/libQt5Widgets.so.5 #27 0x00007ffff3fc2e93 in ?? () from /usr/lib/libQt5Widgets.so.5 #28 0x00007ffff3fc3093 in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/libQt5Widgets.so.5 #29 0x00007ffff3f10c7e in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5 #30 0x00007ffff3ecf702 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #31 0x00007ffff3ed6977 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #32 0x00007ffff7123c29 in KisApplication::notify (this=<optimized out>, receiver=0x5555589b6390, event=0x7fffffffdba0) at /home/vxdcxw/kritadev/krita/libs/ui/KisApplication.cpp:736 #33 0x00007ffff33f869a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5 #34 0x00007ffff3ed585e in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /usr/lib/libQt5Widgets.so.5 #35 0x00007ffff3f293b2 in ?? () from /usr/lib/libQt5Widgets.so.5 #36 0x00007ffff3f2c78f in ?? () from /usr/lib/libQt5Widgets.so.5 #37 0x00007ffff3ecf702 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #38 0x00007ffff7123c29 in KisApplication::notify (this=<optimized out>, receiver=0x555558b79bd0, event=0x7fffffffdee0) at /home/vxdcxw/kritadev/krita/libs/ui/KisApplication.cpp:736 #39 0x00007ffff33f869a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5 #40 0x00007ffff37d4f1c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/libQt5Gui.so.5 #41 0x00007ffff37d5dfc in QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent*) () from /usr/lib/libQt5Gui.so.5 #42 0x00007ffff37aa6ec in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Gui.so.5 #43 0x00007fffef0e3c8c in ?? () from /usr/lib/libQt5XcbQpa.so.5 #44 0x00007ffff180f43c in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #45 0x00007ffff185cfa9 in ?? () from /usr/lib/libglib-2.0.so.0 #46 0x00007ffff180e221 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #47 0x00007ffff3451211 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5 #48 0x00007ffff33f701c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5 #49 0x00007ffff33ff4a4 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5 #50 0x0000555555e28780 in main (argc=<optimized out>, argv=0x7fffffffe6b8) at /home/vxdcxw/kritadev/krita/krita/main.cc:591 Created attachment 129721 [details]
patch
I have found a way to fix the bug however I lack the expertise to debug it further. I hope this will help.
Created attachment 129739 [details]
masking brush overflow fix
I achieved to find the root cause of the problem and a way to solve it. This fix may also improve performances for peoples experiencing custom brush/slow brush window issues.
I attached a diff file with the fix. However this is my first patch and I'm not very comfortable with Krita dev right now. So the solution is using a hardcoded value for the max size instead of fetching it from user settings.
I hope this will help to solve the bug.
Origin of the crash: an overflow happens in the brush preview device because it tries to allocate an invalid QRect with huge height/width.
The problem: masked brush tip size is soft-locked but it can overflow UI limitation because it is bound to base brush tip size (related to `KisMaskingBrushOption::MasterBrushSizeAdapter`). This will happen even if the masked brush option is disabled.
The root cause: The masked brush size value is not clamped into the range [O, Settings.maxBrushSize], this result in huge allocations when the brush window tries to create the device for the brush preview.
A better way to Reproduce the bug:
1. Open a file
2. Create a new brush from Pixel Engine
3. Set its size to 1
4. Set masked brush tip size to 1000
5. Close the brush settings window
6. Change the brush size to something big (100 is enough on my computer)
7. Open the brush settings window
8. Crash
Git commit 3d8ebb27f9d3e9fad9ff4d9c32e5045ac111c116 by Dmitry Kazakov. Committed on 02/07/2020 at 13:35. Pushed by dkazakov into branch 'master'. Add a workaround for too big brushes generated by Masking Brush option The masking brush is scaled by the "master" brush size value. That is, it may become much larger than the user-defined limit. This patch is a workaround that limits the size of the masking brush by 3*brughLimit size. The patch doesn't notify the user about the cropping, neither adjusts it the sliders limits, hence "workaround". TODO: 1) Implement a warning notifying the user that his masking brush has been cropped 2) Make sure that the sliders in KisMaskingBrushOption have correct limits (right now they are limited by usual maximumBrushSize) Thanks Defresne Thierry for tracking down the bug and providing a draft patch! :) M +21 -1 libs/image/brushengine/kis_paintop_settings.cpp M +21 -0 libs/image/kis_image_config.h https://invent.kde.org/graphics/krita/commit/3d8ebb27f9d3e9fad9ff4d9c32e5045ac111c116 Git commit f717b0385683562bba951130343aff2fd4639c38 by Dmitry Kazakov. Committed on 02/07/2020 at 13:36. Pushed by dkazakov into branch 'krita/4.3'. Add a workaround for too big brushes generated by Masking Brush option The masking brush is scaled by the "master" brush size value. That is, it may become much larger than the user-defined limit. This patch is a workaround that limits the size of the masking brush by 3*brughLimit size. The patch doesn't notify the user about the cropping, neither adjusts it the sliders limits, hence "workaround". TODO: 1) Implement a warning notifying the user that his masking brush has been cropped 2) Make sure that the sliders in KisMaskingBrushOption have correct limits (right now they are limited by usual maximumBrushSize) Thanks Defresne Thierry for tracking down the bug and providing a draft patch! :) M +21 -1 libs/image/brushengine/kis_paintop_settings.cpp M +21 -0 libs/image/kis_image_config.h https://invent.kde.org/graphics/krita/commit/f717b0385683562bba951130343aff2fd4639c38 |