Bug 413548 - Color Selector Tool 'Add to palette:' option crashes if selected palette has been deleted
Summary: Color Selector Tool 'Add to palette:' option crashes if selected palette has ...
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Resource Management (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Debian stable Linux
: NOR crash
Target Milestone: ---
Assignee: Halla Rempt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-28 11:47 UTC by Ahab Greybeard
Modified: 2020-01-08 13:56 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahab Greybeard 2019-10-28 11:47:49 UTC
SUMMARY
This happens from version 4.2.6 to the latest 4.3.0 prealpha (git a20ad8a) appimage.

STEPS TO REPRODUCE
1. Use the Colour Selector Tool with its Tool Options set to 'Add to palette:'
2. Create a new palette 'New-1' and note that New-1 does not appear in the drop down list of palettes in Tool Options until after a restart.
3. Use the Colour Selector Tool to select colours and add them to New-1.
(See Additional Information)
4. Delete the New-1 palette and note that it is not removed from the drop down list of palettes and it is still shown as the selected palette.
5. Use the Colour Selector Tool

OBSERVED RESULT
There is a crash.

EXPECTED RESULT
No crash, maybe an advisory. Ideally the list of palettes would be refreshed after creation and deletion of palettes.

SOFTWARE/OS VERSIONS

Krita

 Version: 4.3.0-prealpha (git a20ad8a)
 Languages: en_GB, en
 Hidpi: true

Qt

  Version (compiled): 5.12.5
  Version (loaded): 5.12.5

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-6-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10

ADDITIONAL INFORMATION
When you add colours to a palette in this way, there is a minor usability bug that gives a delay in a colour appearing in the palette until the next addition of a colour or a change of the displayed palette in the Palette docker.
Comment 1 Sam Dyer 2019-10-29 08:14:47 UTC
Could you please add a backtrace to help find the cause of the crash.
Comment 2 Halla Rempt 2019-10-29 08:22:25 UTC
I do see the New-1 palette in the color picker tool option's list of palettes, I do see it's not removed from the combobox, and I can also confirm the crash:

Application: Krita (krita), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fbe18b6a800 (LWP 3202))]

Thread 6 (Thread 0x7fbe04889700 (LWP 3338)):
#0  0x00007fbe1bbbd824 in g_mutex_unlock () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007fbe1bb7211c in g_main_context_prepare () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fbe1bb72b2b in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fbe1bb72d1c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fbe1e77c063 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007fbe1e7275bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fbe1e5722c6 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007fbe0f773ef5 in ?? () from /lib/x86_64-linux-gnu/libQt5Qml.so.5
#8  0x00007fbe1e573612 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007fbe1c33a182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#10 0x00007fbe1e1ecb1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 5 (Thread 0x7fbdfffff700 (LWP 3337)):
#0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1  0x00007fbe1e575c30 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007fbe1e575aa2 in QSemaphore::tryAcquire(int, int) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007fbe1f9f9733 in KisTileDataSwapper::waitForWork (this=<optimized out>) at /home/boud/dev/krita/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:86
#4  0x00007fbe1f9f996a in KisTileDataSwapper::run (this=0x7fbe1fee0e40 <(anonymous namespace)::Q_QGS_s_instance::innerFunction()::holder+64>) at /home/boud/dev/krita/libs/image/tiles3/swap/kis_tile_data_swapper.cpp:92
#5  0x00007fbe1e573612 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fbe1c33a182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#7  0x00007fbe1e1ecb1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7fbe05103700 (LWP 3333)):
#0  __GI___libc_read (nbytes=16, buf=0x7fbe05102b80, fd=28) at ../sysdeps/unix/sysv/linux/read.c:26
#1  __GI___libc_read (fd=28, buf=0x7fbe05102b80, nbytes=16) at ../sysdeps/unix/sysv/linux/read.c:24
#2  0x00007fbe1bbb9410 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fbe1bb726cf in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4  0x00007fbe1bb72ba0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5  0x00007fbe1bb72d1c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6  0x00007fbe1e77c063 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007fbe1e7275bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fbe1e5722c6 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#9  0x00007fbe1e573612 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007fbe1c33a182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#11 0x00007fbe1e1ecb1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7fbe0ebca700 (LWP 3210)):
#0  0x00007fbe1bbbd824 in g_mutex_unlock () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007fbe1bb72b1e in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fbe1bb72d1c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fbe1e77c063 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007fbe1e7275bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007fbe1e5722c6 in QThread::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#6  0x00007fbe1c36a565 in ?? () from /lib/x86_64-linux-gnu/libQt5DBus.so.5
#7  0x00007fbe1e573612 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x00007fbe1c33a182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#9  0x00007fbe1e1ecb1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7fbe178b4700 (LWP 3209)):
#0  0x00007fbe1e1e0729 in __GI___poll (fds=0x7fbe178b3ca8, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007fbe1b9e9917 in ?? () from /lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007fbe1b9eb53a in xcb_wait_for_event () from /lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007fbe184676a8 in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007fbe1e573612 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007fbe1c33a182 in start_thread (arg=<optimized out>) at pthread_create.c:486
#6  0x00007fbe1e1ecb1f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7fbe18b6a800 (LWP 3202)):
[KCrash Handler]
#6  0x00007fbe1d34e835 in QHash<QString, KisSwatchGroup>::findNode (ahp=<optimized out>, akey=..., this=<optimized out>) at /home/boud/dev/krita/libs/pigment/resources/KoColorSet.cpp:271
#7  QHash<QString, KisSwatchGroup>::contains (akey=..., this=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qhash.h:908
#8  KoColorSet::add (this=0x7fbe1000f2f0, c=..., groupName=...) at /home/boud/dev/krita/libs/pigment/resources/KoColorSet.cpp:271
#9  0x00007fbe05c5fcf9 in KisToolColorPicker::endPrimaryAction (this=<optimized out>, event=<optimized out>) at /home/boud/dev/krita/plugins/tools/basictools/kis_tool_colorpicker.cc:204
#10 0x00007fbe20ad96f8 in KisToolProxy::forwardToTool (this=<optimized out>, state=KisToolProxy::END, action=KisTool::Primary, event=0x7ffc0c054210, docPoint=...) at /home/boud/dev/krita/libs/ui/canvas/kis_tool_proxy.cpp:202
#11 0x00007fbe20ad988b in KisToolProxy::forwardEvent (this=0x55eae15dde20, state=state@entry=KisToolProxy::END, action=action@entry=KisTool::Primary, event=event@entry=0x7ffc0c054210, originalEvent=originalEvent@entry=0x7ffc0c054210) at /home/boud/dev/krita/libs/ui/canvas/kis_tool_proxy.cpp:132
#12 0x00007fbe20ec2068 in KisToolInvocationAction::end (this=0x55eadfb0a1f0, event=0x7ffc0c054210) at /usr/include/c++/8/bits/atomic_base.h:390
#13 0x00007fbe20ecfe96 in KisShortcutMatcher::tryEndRunningShortcut (this=this@entry=0x55eadfaeb190, button=<optimized out>, event=event@entry=0x7ffc0c054210) at /home/boud/dev/krita/libs/ui/input/kis_shortcut_matcher.cpp:679
#14 0x00007fbe20ed0e6c in KisShortcutMatcher::buttonReleased (this=0x55eadfaeb190, button=<optimized out>, event=event@entry=0x7ffc0c054210) at /home/boud/dev/krita/libs/ui/input/kis_shortcut_matcher.cpp:296
#15 0x00007fbe20eb1576 in KisInputManager::eventFilterImpl (this=0x55eadfb20eb8, event=0x7ffc0c054210) at /usr/include/x86_64-linux-gnu/qt5/QtGui/qevent.h:132
#16 0x00007fbe1e7285fb in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#17 0x00007fbe1f0ee541 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007fbe1f0f5b77 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007fbe20f37727 in KisApplication::notify (this=<optimized out>, receiver=0x55eae11370b0, event=0x7ffc0c054210) at /home/boud/dev/krita/libs/ui/KisApplication.cpp:653
#20 0x00007fbe1e7288e9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007fbe1f0f4ebf in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007fbe1f14857b in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007fbe1f14b53f in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007fbe1f0ee551 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007fbe1f0f5930 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#26 0x00007fbe20f37727 in KisApplication::notify (this=<optimized out>, receiver=0x55eadf5a65f0, event=0x7ffc0c054710) at /home/boud/dev/krita/libs/ui/KisApplication.cpp:653
#27 0x00007fbe1e7288e9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007fbe1eafec6c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#29 0x00007fbe1eb00075 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#30 0x00007fbe1eada05b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#31 0x00007fbe1846867a in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#32 0x00007fbe1bb729ee in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#33 0x00007fbe1bb72c88 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#34 0x00007fbe1bb72d1c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007fbe1e77c047 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#36 0x00007fbe1e7275bb in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#37 0x00007fbe1e72f5e2 in QCoreApplication::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#38 0x000055ead12584de in main (argc=<optimized out>, argv=0x7ffc0c054de8) at /home/boud/dev/krita/krita/main.cc:575
[Inferior 1 (process 3202) detached]
Comment 3 Tiar 2019-12-19 20:53:18 UTC
Git commit d25b10a4c25e5fed309ff97b532e9eaf880f9a85 by Agata Cacko, on behalf of Saurabh Kumar.
Committed on 19/12/2019 at 20:52.
Pushed by tymond into branch 'master'.

Prevent crash on addition of color to deleted palette with colorpicker

This commit makes the deletion and addition of palette
in palette docker show in colorpicker's tool options'
Add to palette comboBox. This also prevents a crash
due to a dangling pointer due to palette pointing to
deleted memory location.

M  +60   -4    plugins/tools/basictools/kis_tool_colorpicker.cc
M  +14   -3    plugins/tools/basictools/kis_tool_colorpicker.h

https://invent.kde.org/kde/krita/commit/d25b10a4c25e5fed309ff97b532e9eaf880f9a85
Comment 4 Ahab Greybeard 2019-12-20 10:12:15 UTC
I'll raise a separate bug report for the UI/Usability problem (which is what I should have done in the first place).
Comment 5 Halla Rempt 2020-01-08 13:56:22 UTC
Git commit 7d72be15bc3a6ef7a5d17bf7ac15a2770c14dcbe by Boudewijn Rempt, on behalf of Saurabh Kumar.
Committed on 08/01/2020 at 13:33.
Pushed by rempt into branch 'krita/4.2'.

Prevent crash on addition of color to deleted palette with colorpicker

This commit makes the deletion and addition of palette
in palette docker show in colorpicker's tool options'
Add to palette comboBox. This also prevents a crash
due to a dangling pointer due to palette pointing to
deleted memory location.

M  +60   -4    plugins/tools/basictools/kis_tool_colorpicker.cc
M  +14   -3    plugins/tools/basictools/kis_tool_colorpicker.h

https://invent.kde.org/kde/krita/commit/7d72be15bc3a6ef7a5d17bf7ac15a2770c14dcbe