Note #2025-04-11-001
> Reply to Issues · jeanparpaillon/erlang-dbus · GitHub
Crash when introspecting remote service object with overloaded methods
From what I understand, the dbus spec does not explicitly allow or disallow overloading methods. But, there are instances of overloaded methods in different applications (specially KDE based), and erlang-dbus does not handle it gracefully - it crashes.
Example
org.kde.plasmashell
's /org/kde/osdService
path exposes two methods with the same name but different number of arguments.
Output from qdbus
$ qdbus org.kde.plasmashell /org/kde/osdService
...
method void org.kde.osdService.volumeChanged(int percent)
method void org.kde.osdService.volumeChanged(int percent, int maximumPercent)
...
erlang-dbus
> {ok, Bus} = dbus_bus_reg:get_bus(session).
{ok,<0.110.0>}
> {ok, Service} = dbus_bus:get_service(Bus, 'org.kde.plasmashell').
{ok,<0.112.0>}
> {ok, RemoteObject} = dbus_remote_service:get_object(Service, '/org/kde/osdService').
=ERROR REPORT==== 10-Apr-2025::06:22:35.537460 ===
Error parsing introspection infos: {case_clause,
{fatal_error,
{key_exists,<<"volumeChanged">>}}}
=ERROR REPORT==== 10-Apr-2025::06:22:35.537539 ===
Error introspecting object '/org/kde/osdService': parse_error
erlang-dbus crashes on this because it tries to insert an element into a gb_trees
structure with a key that already exists.
I checked the behavior in pydbus, and it looks like it does not handle this fully either. It only shows the last method in the list (in this case, the one with two arguments). But, it does not crash.
This can be fixed by replacing gb_trees:insert/3
with gb_trees:enter/3
- which makes it match the behavior of pydbus.
While trying to write a test case for this issue by writing an example service using QT dbus library (which allows overloading methods), I found another issue in handling root node element without a name attribute in introspection results.
I will raise a pull request to fix both of these issues including test cases.
Interactions