Is there maximum number of arguments

Jukka Mähönen jukka.mahonen at gmail.com
Mon Aug 25 05:42:22 PDT 2008


Hi,

I am writing a program where I need to send as much arguments as
possible in one D-Bus message. When the count of arguments exceeds 255
my program crashes. It only says "Memory overflow". After that I have
sent only 255 arguments in one message, but even now I get the same
error sometimes when I send messages in a loop.

I have this example (written in Perl) which hopefully demonstrates the issue:

#!/usr/bin/perl -w
use Net::DBus;
use strict;

# Get the session bus
my $bus = Net::DBus->session;

# Get connection
my $con = $bus->get_connection;

# Request new name
$con->request_name("perl.test.program");

# Create method call (object, interface or method_name has no
# effect here because it does not matter where the message will be sent)
print "Creating method call...\r\n";
my $methodcall = Net::DBus::Binding::Message::MethodCall->new(
                service_name => "org.freedesktop.DBus",
                object_path => "/org/freedesktop/DBus",
                interface => "org.freedesktop.DBus",
                method_name => "AddMatch");

# Get message iterator
my $iter = $methodcall->iterator($methodcall);

print "Appending args...\r\n";

# Add arguments
for (my $i = 0; $i < 256; $i++) {
    $iter->append_string("test");
}

# Send method call and get pending call
print "Sending...\r\n";
my $pendingCall = $con->send_with_reply($methodcall, 0);

# Wait until we get the reply or timeout exceeds
$pendingCall->block;


I also get the same error when using libdbus library in C so the
problem is not in Perl bindings. If you change the number of loops to
255, it should work fine but when the count is more than 255 it
crashes (at least in my computers).

So is there a limit of arguments or is it bug in my code or somewhere else?

-- 
Jukka


More information about the dbus mailing list