← Back to team overview

kernel-packages team mailing list archive

[Bug 1235649] Re: uevent spam causes libdbus client code in session upstart to consume massive amounts of memory on Ubuntu Touch

 

FWICS D-Bus is behaving as designed: since the client has not called
dbus_connection_set_wakeup_main_function(), and since D-Bus messaging is
reliable, all libdbus is able to do when a signal is sent to a
connection is cache any messages the client has not yet processed in the
hope that at some future point it might consume them.

The key part of the D-Bus code that explains this is
dbus_connection_send_preallocated_unlocked_no_update():

------------------------------

  /* Now we need to run an iteration to hopefully just write the messages
   * out immediately, and otherwise get them queued up
   */  
  _dbus_connection_do_iteration_unlocked (connection,
                                          NULL,                          
                                          DBUS_ITERATION_DO_WRITING,     
                                          -1);                           

  /* If stuff is still queued up, be sure we wake up the main loop */
  if (connection->n_outgoing > 0)
    _dbus_connection_wakeup_mainloop (connection);

------------------------------

As shown, the messages (signals in the case of Upstart) are added to the client connection queue, but since the client called
dbus_connection_open() rather than nih_dbus_connect(), no mainloop handler is registered to allow the client to deal with the signals sent to it.

>From the upstart perspective, a fix is to call dbus_connection_has_messages_to_send() and ignore that connection if the
client still has unprocessed messages (patch attached).

>From the D-Bus perspective, it would be useful to introduce a new public
API:

dbus_bool_t
dbus_connection_has_wakeup_main_function (DBusConnection *connection);

This would allow Upstart and other D-Bus server applications to detect
erroneous client connections.


** Patch added: "bug-1235649.diff"
   https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1235649/+attachment/3879222/+files/bug-1235649.diff

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1235649

Title:
  uevent spam causes libdbus client code in session upstart to consume
  massive amounts of memory on Ubuntu Touch

Status in Upstart:
  New
Status in “linux” package in Ubuntu:
  Invalid
Status in “systemd” package in Ubuntu:
  Invalid
Status in “unity” package in Ubuntu:
  New
Status in “upstart” package in Ubuntu:
  Fix Released
Status in “linux” source package in Saucy:
  Invalid
Status in “systemd” source package in Saucy:
  Invalid
Status in “unity” source package in Saucy:
  New
Status in “upstart” source package in Saucy:
  Fix Released

Bug description:
  using ubuntu touch image 82 i see the session init consume about 10MB per minute as long as the screen is on  with Mir.
  running the same session with surfaceflinger only consumes 1MB per minute.

  in both cases the system starts to swap heavily at some point, making
  the UI unresponsive.

  http://paste.ubuntu.com/6196223/ has the top output of a Mir session
  after 30min, the UI just got completely unresponsive when this
  snapshot was taken.

  http://paste.ubuntu.com/6196332/ is the top output of a surfaceflinger
  session where the screen was off for about 10min

  apparently the leak only occurs while the screen is on, it seems to be
  permanently there but in the case of surfaceflinger it hits less hard.

To manage notifications about this bug go to:
https://bugs.launchpad.net/upstart/+bug/1235649/+subscriptions