Validating Message Parameters

Thiago Macieira thiago at kde.org
Mon Aug 21 06:03:48 UTC 2017


On Sunday, 20 August 2017 17:05:56 PDT Lawrence D'Oliveiro wrote:
> On Sun, 20 Aug 2017 16:18:52 -0700, Thiago Macieira wrote:
> > Or you get an assertion failure and your application crashes.
> 
>     python3 -ic "import dbussy as dbus"
> 
>     >>> m = dbus.Message.new_method_call(destination = "nosuch", path = "/",
>     >>> iface = "nosuch", method = "nosuch")
>     process 5697: 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 1370. This
> is normally a bug in some application using the D-Bus library. Traceback
> (most recent call last):
>       File "<stdin>", line 1, in <module>
>       File "/home/ldo/projects/dbussy/dbussy.py", line 3473, in
> new_method_call raise CallFailed("dbus_message_new_method_call")
>     dbussy.CallFailed: dbus_message_new_method_call failed
> 
> Seems like libdbus prints a message, but does not abort.

That depends on the configuration flags at the time of compilation. They can be:

 1) return failure, no message printed
 2) no test, assume arguments are correct
 3) print warning and return
 4) print warning and abort

> So at the API level, you get back a failure indication without any hint
> as to what actually was wrong.

To be honest, the only mode I wasn't aware of was #3, the one you're 
reporting. For me, it's always just crashed and produced a core dump. You can 
use post-mortem debugging (or a debugger) to find out where it happened and 
what argument was wrong.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center



More information about the dbus mailing list