Bug 475266

Summary: When trying to activate broken desktop files an assert in libdbus is hit
Product: [Frameworks and Libraries] frameworks-kio Reporter: Kyungjoon Lee <kjoonlee>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: aaronjwoodbridge, agurenko, atu, kde, kde, kdelibs-bugs, kevinleroy, nate, nicolas.fella, parag.lkml, postix, sajjaddns, sunny.moon2962, xlkill4r, zargulthewizard, zuurveldt
Priority: HI Keywords: drkonqi
Version: 5.110.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
See Also: https://bugzilla.redhat.com/show_bug.cgi?id=2242454
Latest Commit: Version Fixed In: 5.111
Sentry Crash Report:
Attachments: New crash information added by DrKonqi
The firefox desktop file
stderr from after crash

Description Kyungjoon Lee 2023-10-06 05:38:58 UTC
Application: plasmashell (5.27.8)

Qt Version: 5.15.10
Frameworks Version: 5.110.0
Operating System: Linux 6.5.4-403.asahi.fc39.aarch64+16k aarch64
Windowing System: Wayland
Distribution: Fedora Linux Asahi Remix 39 (Thirty Nine)
DrKonqi: 5.27.8 [KCrashBackend]

-- Information about the crash:
This started happening for me with Fedora today, after Firefox update:

    Pin Firefox 118.0.1 to Task Manager.
    Launch Firefox from Task Manager.

Expected results: Firefox should be launched.

Actual results: Plasma Shell (maybe it is plasma-workspace) dies, Firefox is not launched.

Workaround: Launch Firefox from Launcher menu instead.

When Plasma Shell (maybe it is plasma-workspace) dies, this is printed to stdout/stderr:

QString::arg: 2 argument(s) missing in firefox

I am running Asahi Linux, Fedora 39, M1 Macbook Air.

The crash can be reproduced every time.

-- Backtrace:
Application: Plasma (plasmashell), signal: Aborted

[KCrash Handler]
#4  0x0000ffff9fc42280 in __pthread_kill_implementation () at /lib64/libc.so.6
#5  0x0000ffff9fbf5800 [PAC] in raise () at /lib64/libc.so.6
#6  0x0000ffff9fbe0288 [PAC] in abort () at /lib64/libc.so.6
#7  0x0000ffff9e3cbec4 [PAC] in _dbus_abort () at ../../dbus/dbus-sysdeps.c:101
#8  0x0000ffff9e3cc404 [PAC] in _dbus_warn_check_failed (format=0xffff9e3e5ef8 "arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\nThis is normally a bug in some application using the D-Bus library.\n") at ../../dbus/dbus-internals.c:289
#9  0x0000ffff9e3ba2ac [PAC] in dbus_message_new_method_call (destination=0xaaab8a342e18 "firefox", path=0xaaab8a342f68 "/firefox", iface=0xaaab8a302fa8 "org.freedesktop.Application", method=0xaaab8a3433b8 "Activate") at ../../dbus/dbus-message.c:1375
#10 0x0000ffffa0c902fc [PAC] in q_dbus_message_new_method_call (method=<optimized out>, interface=<optimized out>, path=<optimized out>, bus_name=<optimized out>) at /usr/src/debug/qt5-qtbase-5.15.10-9.fc39.aarch64/src/dbus/qdbus_symbols_p.h:381
#11 QDBusMessagePrivate::toDBusMessage(QDBusMessage const&, QFlags<QDBusConnection::ConnectionCapability>, QDBusError*) (message=..., capabilities=..., error=error@entry=0xfffffc22ecd8) at qdbusmessage.cpp:139
#12 0x0000ffffa0c88fd0 [PAC] in QDBusConnectionPrivate::sendWithReplyAsync(QDBusMessage const&, QObject*, char const*, char const*, int) (this=0xffff84001620, message=..., receiver=receiver@entry=0x0, returnMethod=returnMethod@entry=0x0, errorMethod=errorMethod@entry=0x0, timeout=timeout@entry=-1) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#13 0x0000ffffa0c748dc [PAC] in QDBusConnection::asyncCall(QDBusMessage const&, int) const (this=this@entry=0xfffffc22ee00, message=..., timeout=timeout@entry=-1) at qdbusconnection.cpp:711
#14 0x0000ffff9f765be4 [PAC] in DBusActivationRunner::startProcess() (this=0xaaab8a33c1f0) at /usr/src/debug/kf5-kio-5.110.0-2.fc39.aarch64/src/gui/dbusactivationrunner.cpp:71
#15 0x0000ffffa02d1ea4 [PAC] in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0xfffffc22eef0, r=<optimized out>, this=0xaaab8a33c490) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#16 doActivate<false>(QObject*, int, void**) (sender=0xaaab8a33c1f0, signal_index=5, argv=0xfffffc22eef0) at kernel/qobject.cpp:3925
#17 0x0000ffffa02cc858 [PAC] in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=<optimized out>, local_signal_index=local_signal_index@entry=2, argv=argv@entry=0x0) at kernel/qobject.cpp:3985
#18 0x0000ffff9f75f448 in KProcessRunner::xdgActivationTokenArrived() (this=<optimized out>) at /usr/src/debug/kf5-kio-5.110.0-2.fc39.aarch64/redhat-linux-build/src/gui/KF5KIOGui_autogen/include/moc_kprocessrunner_p.cpp:169
#19 0x0000ffff9f75f89c in operator() (token=<optimized out>, tokenSerial=<optimized out>, __closure=0xaaab8a33ae90) at /usr/src/debug/kf5-kio-5.110.0-2.fc39.aarch64/src/gui/kprocessrunner.cpp:300
#20 QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1>, QtPrivate::List<int, const QString&>, void, KProcessRunner::init(const KService::Ptr&, const QString&, const QString&, const QString&, const QByteArray&)::<lambda(int, const QString&)> >::call (arg=<optimized out>, f=...) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:146
#21 QtPrivate::Functor<KProcessRunner::init(const KService::Ptr&, const QString&, const QString&, const QString&, const QByteArray&)::<lambda(int, const QString&)>, 2>::call<QtPrivate::List<int, QString const&>, void> (arg=<optimized out>, f=...) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:256
#22 QtPrivate::QFunctorSlotObject<KProcessRunner::init(const KService::Ptr&, const QString&, const QString&, const QString&, const QByteArray&)::<lambda(int, const QString&)>, 2, QtPrivate::List<int, const QString&>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=<optimized out>, this_=0xaaab8a33ae80, r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/qt5/QtCore/qobjectdefs_impl.h:443
#23 0x0000ffffa02d1ea4 [PAC] in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0xfffffc22f020, r=<optimized out>, this=0xaaab8a33ae80) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#24 doActivate<false>(QObject*, int, void**) (sender=0xffffa16d0490 <(anonymous namespace)::Q_QGS_g_kwmInstanceContainer::innerFunction()::holder>, signal_index=18, argv=0xfffffc22f020) at kernel/qobject.cpp:3925
#25 0x0000ffffa02cc858 [PAC] in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=m@entry=0xffffa16ceba8 <KWindowSystem::staticMetaObject>, local_signal_index=local_signal_index@entry=15, argv=argv@entry=0xfffffc22f020) at kernel/qobject.cpp:3985
#26 0x0000ffffa168cc58 in KWindowSystem::xdgActivationTokenArrived(int, QString const&) (this=<optimized out>, _t1=<optimized out>, _t2=<optimized out>) at /usr/src/debug/kf5-kwindowsystem-5.110.0-1.fc39.aarch64/redhat-linux-build/src/KF5WindowSystem_autogen/include/moc_kwindowsystem.cpp:503
#27 0x0000ffffa02d1ea4 [PAC] in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0xfffffc22f128, r=<optimized out>, this=0xaaab89d863d0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#28 doActivate<false>(QObject*, int, void**) (sender=0xaaab89dc38a0, signal_index=4, argv=0xfffffc22f128) at kernel/qobject.cpp:3925
#29 0x0000ffff744a1768 [PAC] in non-virtual thunk to WaylandXdgActivationTokenV1::xdg_activation_token_v1_done(QString const&) () at /usr/src/debug/kwayland-integration-5.27.8-1.fc39.aarch64/redhat-linux-build/src/windowsystem/KF5WindowSystemKWaylandPlugin_autogen/EWIEGA46WW/../../../../../src/windowsystem/waylandxdgactivationv1_p.h:19
#30 0x0000ffff744ac178 [PAC] in QtWayland::xdg_activation_token_v1::handle_done(void*, xdg_activation_token_v1*, char const*) (data=0xaaab89dc38b0, object=<optimized out>, token=<optimized out>) at /usr/src/debug/kwayland-integration-5.27.8-1.fc39.aarch64/redhat-linux-build/src/windowsystem/qwayland-xdg-activation-v1.cpp:183
#31 0x0000ffff9fa4c050 [PAC] in ffi_call_SYSV () at ../src/aarch64/sysv.S:127
#32 0x0000ffff9fa463ac in ffi_call_int (cif=cif@entry=0xfffffc22f2f8, fn=<optimized out>, orig_rvalue=0xffff9fa600f0 <ffi_type_pointer>, orig_rvalue@entry=0x0, avalue=avalue@entry=0xfffffc22f3c8, closure=0xffff9fa600f0 <ffi_type_pointer>, closure@entry=0x0) at ../src/aarch64/ffi.c:816
#33 0x0000ffff9fa48a6c [PAC] in ffi_call (cif=cif@entry=0xfffffc22f2f8, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0xfffffc22f3c8) at ../src/aarch64/ffi.c:825
#34 0x0000ffffa2ad1a60 in wl_closure_invoke (closure=closure@entry=0xffff7c00d870, target=<optimized out>, target@entry=0xaaab8a33b1d0, opcode=opcode@entry=0, data=<optimized out>, flags=1) at ../src/connection.c:1025
#35 0x0000ffffa2ad23fc [PAC] in dispatch_event (display=0xaaab8825fe90, queue=<optimized out>) at ../src/wayland-client.c:1631
#36 0x0000ffffa2ad2724 [PAC] in dispatch_queue (queue=0xaaab8825ff80, display=0xaaab8825fe90) at ../src/wayland-client.c:1777
#37 wl_display_dispatch_queue_pending (display=0xaaab8825fe90, queue=0xaaab8825ff80) at ../src/wayland-client.c:2019
#38 0x0000ffffa17c3a0c [PAC] in QtWaylandClient::QWaylandDisplay::flushRequests() (this=<optimized out>) at /usr/src/debug/qt5-qtwayland-5.15.10-4.fc39.aarch64/src/client/qwaylanddisplay.cpp:255
#39 0x0000ffffa02c7a9c [PAC] in QObject::event(QEvent*) (this=0xaaab8825b830, e=0xffff80001f70) at kernel/qobject.cpp:1347
#40 0x0000ffffa10b2c18 [PAC] in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0xaaab8825b830, e=0xffff80001f70) at kernel/qapplication.cpp:3640
#41 0x0000ffffa0295f10 [PAC] in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0xaaab8825b830, event=0xffff80001f70) at kernel/qcoreapplication.cpp:1064
#42 0x0000ffffa02961ec [PAC] in QCoreApplication::sendEvent(QObject*, QEvent*) (receiver=receiver@entry=0xaaab8825b830, event=event@entry=0xffff80001f70) at kernel/qcoreapplication.cpp:1462
#43 0x0000ffffa02999e0 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0xaaab88234e30) at kernel/qcoreapplication.cpp:1821
#44 0x0000ffffa0299e5c [PAC] in QCoreApplication::sendPostedEvents(QObject*, int) (receiver=<optimized out>, event_type=<optimized out>) at kernel/qcoreapplication.cpp:1680
#45 0x0000ffffa02f4740 in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0xaaab88298f10) at kernel/qeventdispatcher_glib.cpp:277
#46 0x0000ffff9e550310 [PAC] in g_main_context_dispatch_unlocked.lto_priv () at /lib64/libglib-2.0.so.0
#47 0x0000ffff9e5ae59c [PAC] in g_main_context_iterate_unlocked.isra () at /lib64/libglib-2.0.so.0
#48 0x0000ffff9e54dac8 [PAC] in g_main_context_iteration () at /lib64/libglib-2.0.so.0
#49 0x0000ffffa02f40e8 [PAC] in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0xaaab8829ce10, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#50 0x0000ffffa02941e4 [PAC] in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0xfffffc22fa20, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#51 0x0000ffffa029d880 [PAC] in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#52 0x0000ffffa06ebd6c [PAC] in QGuiApplication::exec() () at kernel/qguiapplication.cpp:1863
#53 0x0000ffffa10b2bb8 in QApplication::exec() () at kernel/qapplication.cpp:2832
#54 0x0000aaab79e169ac in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/plasma-workspace-5.27.8-2.fc39.aarch64/shell/main.cpp:235
[Inferior 1 (process 12513) detached]

Reported using DrKonqi
Comment 1 Kyungjoon Lee 2023-10-06 05:59:04 UTC
Another workaround:

sudo dnf downgrade firefox-118.0
Comment 2 David Redondo 2023-10-06 07:52:00 UTC
How is firefox installed?

Could you attach the desktop file of firefox? It looks like we are in the DbusActivatable=True path, but my firefox 118.0.1 file does not contain it.

destination=0xaaab8a342e18 "firefox", path=0xaaab8a342f68 "/firefox", iface=0xaaab8a302fa8 "org.freedesktop.Application", method=0xaaab8a3433b8 "Activate"

this looks certainly wrong as well but something goes wrong with the arguments as well
Comment 3 Tristan Busch 2023-10-06 09:19:19 UTC
Created attachment 162117 [details]
New crash information added by DrKonqi

plasmashell (5.27.8) using Qt 5.15.10

The same is happening to me with the normal x68 Fedora KDE spin, right after updating Firefox to version 118.0.1-4.fc38.
I'm experiencing the same problem as described above with the same workaround. Unpining and repinning Firefox from the Task Manager did not help.

-- Backtrace (Reduced):
#7  0x00007f17bc067cf2 in _dbus_abort.cold () from /lib64/libdbus-1.so.3
#8  0x00007f17bc090102 in _dbus_warn_check_failed () from /lib64/libdbus-1.so.3
#9  0x00007f17bc07eab1 in dbus_message_new_method_call () from /lib64/libdbus-1.so.3
#10 0x00007f17be7451fc in QDBusMessagePrivate::toDBusMessage(QDBusMessage const&, QFlags<QDBusConnection::ConnectionCapability>, QDBusError*) () from /lib64/libQt5DBus.so.5
#11 0x00007f17be73e635 in QDBusConnectionPrivate::sendWithReplyAsync(QDBusMessage const&, QObject*, char const*, char const*, int) () from /lib64/libQt5DBus.so.5
Comment 4 Tristan Busch 2023-10-06 09:25:06 UTC
I have added my desktop file to the attachments. There are, however, two other firefox desktop files in my /usr/share/applications ending in »-wayland« and »-x11« which have appeared in my program list since the update and which weren't there before.
Comment 5 Tristan Busch 2023-10-06 09:25:42 UTC
Created attachment 162118 [details]
The firefox desktop file
Comment 6 Kyungjoon Lee 2023-10-06 09:52:03 UTC
I have the same desktop file that Tristan has uploaded; and commenting out line 54 (DBusActivatable=true) from /usr/share/applications/firefox.desktop file is another workaround that lets me launch Firefox 118.0.1 from the Task Manager again.
Comment 7 Kyungjoon Lee 2023-10-06 09:58:30 UTC
Created attachment 162120 [details]
stderr from after crash

Lines 42-44 from plasmashell stderr:

QString::arg: 2 argument(s) missing in firefox
dbus[5702]: arguments to dbus_message_new_method_call() were incorrect, assertion "destination == NULL || _dbus_check_is_valid_bus_name (destination)" failed in file ../../dbus/dbus-message.c line 1375.
This is normally a bug in some application using the D-Bus library.
Comment 8 Bug Janitor Service 2023-10-06 12:29:44 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/1440
Comment 9 David Redondo 2023-10-06 12:34:53 UTC
According to the desktop file spec

The application must name its desktop file in accordance with the naming recommendations in the introduction section (e.g. the filename must be like org.example.FooViewer.desktop). The application must have a D-Bus service activatable at the well-known name that is equal to the desktop file name with the .desktop portion removed (for our example, org.example.FooViewer). The above interface must be implemented at an object path determined as follows: starting with the well-known D-Bus name of the application, change all dots to slashes and prefix a slash. If a dash ('-') is found, convert it to an underscore ('_'). For our example, this is /org/example/FooViewer. 


Firefox names it desktop file only "firefox.desktop" so we make a call to "firefox" but according to the dbus spec 

- Bus names are composed of 1 or more elements separated by a period ('.') character. All elements must contain at least one character. 
- Bus names must contain at least one '.' (period) character (and thus at least two elements). 

So the desktop file of firefox is broken but we still should guard for broken desktop files. I reported this to firefox
Comment 10 Nicolas Fella 2023-10-06 12:43:18 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=2242454
Comment 11 Nicolas Fella 2023-10-06 13:37:48 UTC
*** Bug 475276 has been marked as a duplicate of this bug. ***
Comment 12 Nicolas Fella 2023-10-06 13:42:15 UTC
Git commit 246ea181b16603c1bbbe6912c27a8bfc503e894f by Nicolas Fella, on behalf of Harald Sitter.
Committed on 06/10/2023 at 15:26.
Pushed by nicolasfella into branch 'master'.

dbusactivationrunner: only activate well-formed services

From the specification:

> The application must name its desktop file in accordance with the
> naming recommendations in the introduction section (e.g. the filename
> must be like org.example.FooViewer.desktop).

When an application is in violation of this we'll not dbus activate it
lest libdbus assert crashes in our face

M  +4    -0    src/gui/dbusactivationrunner.cpp

https://invent.kde.org/frameworks/kio/-/commit/246ea181b16603c1bbbe6912c27a8bfc503e894f
Comment 13 Nicolas Fella 2023-10-06 13:48:22 UTC
Git commit eb12ebeab5a6408c483ecbe681a353bb95cff782 by Nicolas Fella, on behalf of Harald Sitter.
Committed on 06/10/2023 at 15:45.
Pushed by nicolasfella into branch 'kf5'.

dbusactivationrunner: only activate well-formed services

From the specification:

> The application must name its desktop file in accordance with the
> naming recommendations in the introduction section (e.g. the filename
> must be like org.example.FooViewer.desktop).

When an application is in violation of this we'll not dbus activate it
lest libdbus assert crashes in our face
(cherry picked from commit 246ea181b16603c1bbbe6912c27a8bfc503e894f)

M  +4    -0    src/gui/dbusactivationrunner.cpp

https://invent.kde.org/frameworks/kio/-/commit/eb12ebeab5a6408c483ecbe681a353bb95cff782
Comment 14 Bug Janitor Service 2023-10-06 14:53:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/3374
Comment 15 Nicolas Fella 2023-10-06 19:38:09 UTC
*** Bug 475291 has been marked as a duplicate of this bug. ***
Comment 16 Nicolas Fella 2023-10-06 20:12:23 UTC
*** Bug 475295 has been marked as a duplicate of this bug. ***
Comment 17 Wilbur Jaywright 2023-10-07 01:39:18 UTC
Clicking Firefox in Kickoff search results does the same thing.
Comment 18 Nicolas Fella 2023-10-07 14:53:40 UTC
*** Bug 475323 has been marked as a duplicate of this bug. ***
Comment 19 sunny.moon2962 2023-10-07 16:13:09 UTC
For me, firefox opens via application launcher or terminal, but crashed via the task manager.

Also it happens the same for steam, but steam I am not able to launch via application launcher, only via terminal.

This started to happen after the update to Fedora 38.

Operating System: Fedora Linux 38
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.5-200.fc38.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 7900 12-Core Processor
Memory: 30.5 GiB of RAM
Graphics Processor: AMD Radeon RX 6700 XT
Manufacturer: ASUS
Comment 20 Nicolas Fella 2023-10-07 17:02:48 UTC
*** Bug 475330 has been marked as a duplicate of this bug. ***
Comment 21 Nicolas Fella 2023-10-07 20:09:16 UTC
*** Bug 475237 has been marked as a duplicate of this bug. ***
Comment 22 Nicolas Fella 2023-10-08 00:31:04 UTC
*** Bug 475305 has been marked as a duplicate of this bug. ***
Comment 23 Nicolas Fella 2023-10-08 12:04:43 UTC
*** Bug 475355 has been marked as a duplicate of this bug. ***
Comment 24 David Redondo 2023-10-09 07:06:30 UTC
>For me, firefox opens via application launcher or terminal, but crashed via the task manager.

This is because kicker/kickoff sets DeleteTemporaryFiles flag which causes us to not use Dbusactviation