Bug 494464 - Kate crashes when running a macro
Summary: Kate crashes when running a macro
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 24.08.3
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2024-10-10 16:15 UTC by Pep
Modified: 2024-11-17 08:13 UTC (History)
1 user (show)

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


Attachments
Video of the bug as requested (2.33 MB, video/mp4)
2024-11-16 22:48 UTC, Pep
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pep 2024-10-10 16:15:50 UTC
Application: kate (23.08.5)

Qt Version: 5.15.13
Frameworks Version: 5.115.0
Operating System: Linux 6.8.0-45-generic x86_64
Windowing System: X11
Distribution: Ubuntu 24.04.1 LTS
DrKonqi: 5.27.11 [KCrashBackend]

-- Information about the crash:
This happens every time I use the macro system.

Firstly, I start recording a macro with the hotkeys then when I save the macro with the hotkeys it inserts a K into my document.
Then when I use the hotkey to play the macro Kate immediately asks me to save the macro and then promptly crashes when I press save.

The crash can be reproduced every time.

-- Backtrace:
Application: Kate (kate), signal: Segmentation fault

[KCrash Handler]
#4  0x0000708d666d8088 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x0000708d5480c3f4 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/ktexteditor/keyboardmacrosplugin.so
#6  0x0000708d5480c8d0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/ktexteditor/keyboardmacrosplugin.so
#7  0x0000708d66712e16 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#8  0x0000708d67564f94 in QAction::triggered(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x0000708d67567eab in QAction::activate(QAction::ActionEvent) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x0000708d676fc512 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x0000708d67704702 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x0000708d675b0df8 in QWidget::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x0000708d6756bd45 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x0000708d675746b0 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x0000708d666d8118 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#16 0x0000708d67572874 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x0000708d675cb5d2 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x0000708d675cdfbf in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x0000708d6756bd45 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x0000708d666d8118 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x0000708d66b45a3b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#22 0x0000708d66b17bfc in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#23 0x0000708d608fcd06 in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#24 0x0000708d645145b5 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x0000708d64573717 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#26 0x0000708d64513a53 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#27 0x0000708d66735279 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x0000708d666d6a7b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x0000708d666df3e8 in QCoreApplication::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x000060662192d3d7 in ?? ()
#31 0x0000708d65c2a1ca in __libc_start_call_main (main=main@entry=0x60662192be50, argc=argc@entry=3, argv=argv@entry=0x7fffbce1bf08) at ../sysdeps/nptl/libc_start_call_main.h:58
#32 0x0000708d65c2a28b in __libc_start_main_impl (main=0x60662192be50, argc=3, argv=0x7fffbce1bf08, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffbce1bef8) at ../csu/libc-start.c:360
#33 0x000060662192f7c5 in ?? ()
[Inferior 1 (process 2838) detached]

Reported using DrKonqi
Comment 1 Waqar Ahmed 2024-10-10 17:05:53 UTC
can you give exact steps to reproduce?
Comment 2 Waqar Ahmed 2024-10-11 06:58:09 UTC
Can not reproduce with a couple of macros I tried. Please share the macro that results in crash.
Comment 3 Pep 2024-10-21 10:40:49 UTC
I cannot provide the macro because kate crashed and did not record the macro.

As for the steps that I was doing I put that in my bug report.

1) start macro recording using the start macro hot key
2) move cursor down the document by three lines
3) save macro using the hot key

At step (3) kate places a "K" in my document.

I just noticed that after step 3 the stop recording macro option is still highlighted in the macro menu, so I clicked that which then set the option to un-highlighted state.

4) play the macro by either the hot key or menu option

At step (4) kate immediately asks me to save the macro, so I saved the macro as kate_bug_macro and kate crashed.

When I restart kate there are no macros in the macro menu so I cannot send you the macro.
I'm not aware of any intermediary storage for the macros so I can't even look for the macro between step (3) and step (4).
Comment 4 Waqar Ahmed 2024-10-21 10:47:35 UTC
A macro is a set of steps that you record which can be repeated quickly. 

I need those exact steps, so I can record the same macro locally and reproduce the issue.

We don't have macro sharing afaik. So you just have to tell me what actions were part of the macro.
Comment 5 Waqar Ahmed 2024-10-21 10:49:03 UTC
ok, sorry. You already shared the steps in the latest comment. didn't read carefully enough
Comment 6 Pep 2024-10-21 10:51:35 UTC
I just told you, all I did between starting recording the macro and saving the macro was press the down arrow 3 times.

Honestly it doesn't matter what I do, I could just advance the cursor one character using the right arrow key. It crashes no matter what I do.
Comment 7 Waqar Ahmed 2024-10-22 04:04:09 UTC
I tried with these steps but was not able to reproduce:

-> Ctrl+Shift+K // start record
-> move cursor down
-> Ctrl+Shift+K // end record
-> Play macro by click the action in menu

Play is not supposed to show a save dialog so things are for some reason broken for you.

Since you are on an unsupported/old version of Kate, can you try using the latest version? https://kate-editor.org/get-it/
Comment 8 Pep 2024-10-22 08:14:00 UTC
(In reply to Waqar Ahmed from comment #7)
> I tried with these steps but was not able to reproduce:
> 
> -> Ctrl+Shift+K // start record
> -> move cursor down
> -> Ctrl+Shift+K // end record
> -> Play macro by click the action in menu
> 
> Play is not supposed to show a save dialog so things are for some reason
> broken for you.
> 
> Since you are on an unsupported/old version of Kate, can you try using the
> latest version? https://kate-editor.org/get-it/

erm, that's odd.

My system is up to date and version 23.08 is the version in ubuntu/kubuntu repo.

I plan to update to the next kubuntu rolling release soon but in the meantime I  guess I'll have to find the latest version for Plasma 5.27 in kde repo as kubuntu 24.04 is their LTS so I can't see them changing kate now.

Thanks for looking in to the bug.
Comment 9 Pep 2024-10-22 08:58:15 UTC
Okay I just installed version 24.08.2 from flatpak and the exact same thing is happening.

So something else must be affecting kate then but I have no idea what could possibly doing it. I can at least rule out anything related to the keyboard because it happens using the kate menu commands for the macros too, not just the keyboard shortcuts.

So it's somewhere else inside the kde installation but I have no idea what.
Comment 10 Waqar Ahmed 2024-10-22 09:03:40 UTC
the latest version is 24.08. You can try it via snap/appimage/flatpak if you want. Check the link I gave earlier.
Comment 11 Pep 2024-10-22 14:38:31 UTC
(In reply to Waqar Ahmed from comment #10)
> the latest version is 24.08. You can try it via snap/appimage/flatpak if you
> want. Check the link I gave earlier.

Yeah I tried 24.08 as I sad in my last comment but it does the same thing, so there must be something else impacting kate macros but I have no idea where to look for anything that could do that as I'm running a bog standard kubuntu installation.
Comment 12 Waqar Ahmed 2024-10-23 04:59:17 UTC
Okay then, would it be possible for you to record a video? There might be something that I am not doing and hence not seeing the bug.

Also, run kate from the terminal and set this (before launching kate) to enable logging from the macros plugin (I am not sure if it will work with snaps, but it will work for the 23.08 kate installed in your system):

export QT_LOGGING_RULES="kate.plugin.keyboardmacros.*=true"
Comment 13 Pep 2024-11-16 22:48:07 UTC
Created attachment 175872 [details]
Video of the bug as requested
Comment 14 Pep 2024-11-16 22:56:16 UTC
I uploaded a video of the bug as requested.

I also ran kate from konsole with the export you suggested but nothing was output to konsole and I have no idea where kate or kde stores any logs, so let me know and I'll upload a log file too.

Also I think this is very relevant to whatever is going on.

I have just upgraded Kubuntu from 22.04 to 22.10 and am using the Ubuntu packaged kate rather than the flatpak version but the bug, whatever it is, still persists which I find very odd because it has crossed from Ubuntu 22.04 packaged kate to flatpack packaged kate to Ubuntu 22.10 packaged kate.

So I am leaning toward this now being not a kate bug but something very wrong on my system which has managed to cross a system upgrade but I have no idea where to start looking for anything that could affect kate like this without showing up somewhere else as well but everything else on my system is stable.

My current system specs are

Operating System: Kubuntu 24.10
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.6.2
Kernel Version: 6.11.0-9-generic (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 2700X Eight-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1080 Ti/PCIe/SSE2

And the version of kate now being used is 24.08.1
Comment 15 Waqar Ahmed 2024-11-17 07:57:26 UTC
Git commit 11a1e88ff158af88f082f3bccb7ee281712db5f0 by Waqar Ahmed.
Committed on 17/11/2024 at 07:56.
Pushed by waqar into branch 'master'.

Skip "Save macro recording" action when recording is going on

It is not supported, the user must end the recording by either playing
the macro or explicitly ending the recording before trying to save it.

With this commit, we warn the user about this and avoid recording the
shortcut.

M  +15   -2    addons/keyboardmacros/keyboardmacrosplugin.cpp
M  +2    -1    addons/keyboardmacros/keyboardmacrosplugin.h
M  +5    -0    addons/keyboardmacros/keyboardmacrospluginview.cpp
M  +1    -0    addons/keyboardmacros/keyboardmacrospluginview.h

https://invent.kde.org/utilities/kate/-/commit/11a1e88ff158af88f082f3bccb7ee281712db5f0
Comment 16 Waqar Ahmed 2024-11-17 07:57:34 UTC
Git commit 2368257248a368c94fb56dc91c3d232981dab376 by Waqar Ahmed.
Committed on 17/11/2024 at 07:53.
Pushed by waqar into branch 'master'.

Ensure key press/release are sent to the same widget

It might still happen that after key press event is sent, the widget
gets deleted but that would just be a bad widget

M  +9    -2    addons/keyboardmacros/keyboardmacrosplugin.cpp

https://invent.kde.org/utilities/kate/-/commit/2368257248a368c94fb56dc91c3d232981dab376
Comment 17 Waqar Ahmed 2024-11-17 08:13:44 UTC
Git commit e8e8e9b31ce45fa59ba7b095b884fa2dc80ffcae by Waqar Ahmed.
Committed on 17/11/2024 at 08:02.
Pushed by waqar into branch 'release/24.12'.

Ensure key press/release are sent to the same widget

It might still happen that after key press event is sent, the widget
gets deleted but that would just be a bad widget
(cherry picked from commit 2368257248a368c94fb56dc91c3d232981dab376)

M  +9    -2    addons/keyboardmacros/keyboardmacrosplugin.cpp

https://invent.kde.org/utilities/kate/-/commit/e8e8e9b31ce45fa59ba7b095b884fa2dc80ffcae
Comment 18 Waqar Ahmed 2024-11-17 08:13:50 UTC
Git commit 5291f2e995b87184d5d8c6dc48f0e60792668c0f by Waqar Ahmed.
Committed on 17/11/2024 at 08:03.
Pushed by waqar into branch 'release/24.12'.

Skip "Save macro recording" action when recording is going on

It is not supported, the user must end the recording by either playing
the macro or explicitly ending the recording before trying to save it.

With this commit, we warn the user about this and avoid recording the
shortcut.
(cherry picked from commit 11a1e88ff158af88f082f3bccb7ee281712db5f0)

M  +15   -2    addons/keyboardmacros/keyboardmacrosplugin.cpp
M  +2    -1    addons/keyboardmacros/keyboardmacrosplugin.h
M  +5    -0    addons/keyboardmacros/keyboardmacrospluginview.cpp
M  +1    -0    addons/keyboardmacros/keyboardmacrospluginview.h

https://invent.kde.org/utilities/kate/-/commit/5291f2e995b87184d5d8c6dc48f0e60792668c0f