Bug 461056 - Crash in external tools if JS is used
Summary: Crash in external tools if JS is used
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: application (other bugs)
Version First Reported In: Git
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-27 09:05 UTC by Pozsgay Máté
Modified: 2022-10-28 18:37 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pozsgay Máté 2022-10-27 09:05:56 UTC
SUMMARY
I try to add an external tool call using the external tools plugin which requests an additional input parameter. My approach is to call a JavaScript window.prompt() function with the %{JS:} token, and I realized calling a JS function crashes Kate

STEPS TO REPRODUCE
1. Enable External tools
2. Create a new tool, for example:
   Executable: bash
   Arguments: -c echo "Input: '%{JS:editor.clipboardText()}"'
3. Run the new tool you created in step 2

OBSERVED RESULT
Crash

EXPECTED RESULT
Execute the tool as requested

SOFTWARE/OS VERSIONS
Kate version: 22.11.70
Linux/KDE Plasma: Ubuntu 22.04.1 LTS
KDE Plasma Version: 
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.3

ADDITIONAL INFORMATION
Backtrace:
Core was generated by `/home/pozsgai/projects/kde/build/kde/applications/kate/bin/kate'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fd9f541d687 in KateExternalToolsPlugin::runnerForTool (this=0x560c47290340, tool=..., view=0x0, executingSaveTrigger=false)
    at /home/matthew/projects/kde/src/kde/applications/kate/addons/externaltools/externaltoolsplugin.cpp:250
--Type <RET> for more, q to quit, c to continue without paging--
250         auto mw = view->mainWindow();
[Current thread is 1 (Thread 0x7fda1b8e29c0 (LWP 17908))]
(gdb) bt
#0  0x00007fd9f541d687 in KateExternalToolsPlugin::runnerForTool (this=0x560c47290340, tool=..., view=0x0, executingSaveTrigger=false)
    at /home/matthew/projects/kde/src/kde/applications/kate/addons/externaltools/externaltoolsplugin.cpp:250
#1  0x00007fd9f541dc8c in KateExternalToolsPlugin::runTool (this=0x560c47290340, tool=..., view=0x0, executingSaveTrigger=false)
    at /home/matthew/projects/kde/src/kde/applications/kate/addons/externaltools/externaltoolsplugin.cpp:297
#2  0x00007fd9f54286ef in operator() (__closure=0x560c479334d0) at /home/matthew/projects/kde/src/kde/applications/kate/addons/externaltools/kateexternaltoolsview.cpp:77
#3  0x00007fd9f542aa62 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KateExternalToolsMenuAction::reload()::<lambda()> >::call(struct {...} &, void **) (f=..., 
    arg=0x7ffe29a42a90) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:146
#4  0x00007fd9f542a9cb in QtPrivate::Functor<KateExternalToolsMenuAction::reload()::<lambda()>, 0>::call<QtPrivate::List<>, void>(struct {...} &, void *, void **) (f=..., arg=0x7ffe29a42a90)
    at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:256
#5  0x00007fd9f542a970 in QtPrivate::QFunctorSlotObject<KateExternalToolsMenuAction::reload()::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (
    which=1, this_=0x560c479334c0, r=0x560c47933030, a=0x7ffe29a42a90, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:443
#6  0x00007fda21320793 in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007fda21f82be6 in QAction::triggered(bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8  0x00007fda21f858fc in QAction::activate(QAction::ActionEvent) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#9  0x00007fda22110142 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x00007fda22117d39 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#11 0x00007fda21fcc4ee in QWidget::event(QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x00007fda21f89713 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#13 0x00007fda21f91364 in QApplication::notify(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#14 0x00007fda212e8e3a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007fda21f8fe47 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007fda21fe6843 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007fda21fe8fd5 in ?? () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007fda21f89713 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007fda212e8e3a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#20 0x00007fda21880307 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#21 0x00007fda21855a2c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#22 0x00007fda1af75d6e in ?? () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#23 0x00007fda1e88dd1b in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#24 0x00007fda1e8e26f8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#25 0x00007fda1e88b3c3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#26 0x00007fda213420b8 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007fda212e775b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#28 0x00007fda212efcf4 in QCoreApplication::exec() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#29 0x0000560c453bc85c in main (argc=1, argv=0x7ffe29a43bb8) at /home/matthew/projects/kde/src/kde/applications/kate/apps/kate/main.cpp:603
Comment 1 Christoph Cullmann 2022-10-28 18:37:57 UTC
Git commit 91990314e8318dacaddb9e958b643a658462d675 by Christoph Cullmann.
Committed on 28/10/2022 at 18:37.
Pushed by cullmann into branch 'master'.

better handling of no active view

M  +6    -9    addons/externaltools/kateexternaltoolsview.cpp

https://invent.kde.org/utilities/kate/commit/91990314e8318dacaddb9e958b643a658462d675