memleak in plugins/orientation/gsd-orientation-manager.c

Bug #1123930 reported by Jean-Baptiste Lallement
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-nexus7
New
Undecided
Unassigned
gnome-settings-daemon (Ubuntu)
Fix Released
High
Jani Monoses
Raring
Fix Released
High
Jani Monoses

Bug Description

in plugins/orientation/gsd-orientation-manager.c mpu_timer(), the code is leaking g_build_filename() calls. The implication of this leak is severe since it's called very often. The graph attached show evolution of memory usage of g-s-d over a period of 10h or so and g-s-d leaked 9MB during that time.

a proposed patch:
--- gsd-orientation-manager.c.orig 2013-02-12 12:31:34.000000000 +0100
+++ gsd-orientation-manager.c 2013-02-13 10:35:19.496823747 +0100
@@ -438,13 +438,19 @@
 static gboolean mpu_timer(GsdOrientationManager *manager) {
  int x, y;
  static gboolean first = TRUE;
+ gchar *filename_x = NULL;
+ gchar *filename_y = NULL;
  OrientationUp orientation = manager->priv->prev_orientation;

         if (manager->priv->xrandr_proxy == NULL)
                 return TRUE;

- x = read_sysfs_attr_as_int(g_build_filename(manager->priv->sysfs_path, "in_accel_x_raw", NULL));
- y = read_sysfs_attr_as_int(g_build_filename(manager->priv->sysfs_path, "in_accel_y_raw", NULL));
+ filename_x = g_build_filename(manager->priv->sysfs_path, "in_accel_x_raw", NULL);
+ filename_y = g_build_filename(manager->priv->sysfs_path, "in_accel_y_raw", NULL);
+ x = read_sysfs_attr_as_int(filename_x);
+ y = read_sysfs_attr_as_int(filename_y);
+ g_free(filename_x);
+ g_free(filename_y);

  if (x > MPU_THRESHOLD)
   orientation = ORIENTATION_NORMAL;

ProblemType: Bug
DistroRelease: Ubuntu 13.04
Package: gnome-settings-daemon 3.6.4-0ubuntu5
ProcVersionSignature: Ubuntu 3.8.0-5.10-generic 3.8.0-rc6
Uname: Linux 3.8.0-5-generic x86_64
ApportVersion: 2.8-0ubuntu4
Architecture: amd64
Date: Wed Feb 13 10:36:35 2013
MarkForUpload: True
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: gnome-settings-daemon
UpgradeStatus: Upgraded to raring on 2012-01-31 (378 days ago)

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Added a nexus7 task since it's caused by the distro patch to make orientation sensor work on the Nexus.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks jibel!

We need to stop adding patches without review... Jani, it's your patch, can you have a look to the fix?

Changed in gnome-settings-daemon (Ubuntu):
assignee: nobody → Jani Monoses (jani)
importance: Undecided → High
Revision history for this message
Jani Monoses (jani) wrote :

Thanks for the catch, I need to remember why I did not calculate the paths only once, as there should be no need to build the same paths in each timer invocation.

Revision history for this message
Jani Monoses (jani) wrote :
tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-settings-daemon - 3.6.4-0ubuntu6

---------------
gnome-settings-daemon (3.6.4-0ubuntu6) raring; urgency=low

  * debian/patches/nexus_orientation.patch: Fix memory leak when building
    pathnames, thanks Jean-Baptiste Lallement! (LP: #1123930)
 -- Jani Monoses <email address hidden> Wed, 13 Feb 2013 13:25:19 +0200

Changed in gnome-settings-daemon (Ubuntu Raring):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.