GNOME Bugzilla – Bug 623810
Message serialization bug
Last modified: 2010-07-15 16:22:34 UTC
I found g_dbus_method_invocation_return_value (invocation, NULL) will reply a message with signature "()". I think it should be "".
Additional information: When I get a void reply message from a connection and send it to another connection, g_dbus_connection_send_message return an error. The error message is "Message body is empty but signature in the header field is `()'". Do you have any idea about this problem?
After investigation, I found the problem maybe in g_dbus_message_to_blob. If the body is NULL and signature is not NULL, it will return the error.
I'm not sure there's a bug here - the way it's supposed to work is like this 1. If body is NULL then signature must be NULL as well. Similar if signature is NULL then body must be NULL. 2. Otherwise, the signature of the message must equal the GVariant type-string of the body except for the starting and ending parenthesis. 3. Specifically g_dbus_message_set_body() updates the signature to like asked for in 2. 4. Note that the body==NULL case is similar to the case where the body is an empty GVariant tuple and signature is the empty string. The only reason we allow NULL values is performance. Please reopen if you find a bug with how this works.
Created attachment 165937 [details] Add a small program to reproduce this issue In this program, the message body is NULL, and the signature is an empty string. And the message can not be serialized.
The output of this program. dhcp-172-30-136-58:test penghuang$ ./test ** (process:17029): DEBUG: signature='', body=0x100412200 ** (process:17029): DEBUG: signature='', body=0x0 ** (process:17029): DEBUG: Message body is empty but signature in the header field is `()'
I see. So the problem is that we are failing the case where body==NULL but signature is the empty string. I've fixed that with this commit http://git.gnome.org/browse/glib/commit/?id=48b1fe948c4424cbc7e68ecca32b0ddac0f7410b and this makes the test program from comment 4 work as expected. I've also included a test case for this. Please verify that this fixes the problem you were experiencing. Thanks!