Debian Bug report logs - #369083
gnome-cups-manager: gnome-cups-icon bloated ?

version graph

Package: libgnomecups1.0-1; Maintainer for libgnomecups1.0-1 is Ross Burton <ross@debian.org>; Source for libgnomecups1.0-1 is src:libgnomecups (PTS, buildd, popcon).

Reported by: Olivier Berger <oberger@ouvaton.org>

Date: Sat, 27 May 2006 11:48:02 UTC

Severity: normal

Tags: fixed-upstream, patch

Merged with 375891

Fixed in version 0.2.2-5

Done: Loïc Minier <lool@dooz.org>

Bug is archived. No further changes may be made.

Forwarded to http://bugzilla.gnome.org/show_bug.cgi?id=339365

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Ross Burton <ross@debian.org>:
Bug#369083; Package gnome-cups-manager. (full text, mbox, link).


Acknowledgement sent to Olivier Berger <oberger@ouvaton.org>:
New Bug report received and forwarded. Copy sent to Ross Burton <ross@debian.org>. (full text, mbox, link).


Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Olivier Berger <oberger@ouvaton.org>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: gnome-cups-manager: gnome-cups-icon bloated ?
Date: Sat, 27 May 2006 13:35:49 +0200
Package: gnome-cups-manager
Version: 0.31-1.1
Severity: wishlist

gmemusage reports gnome-cups-icon taking 33928 Kb on my Gnome desktop.

I find that a bit too much for an icon that basically wouldn't be much used on the desktop.
Is there a way to avoid such a low featured application taking up so much memory ?

Maybe this is a bug ?

Thanks in advance.

Best regards,


-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-k7
Locale: LANG=fr_FR@euro, LC_CTYPE=fr_FR@euro (charmap=ISO-8859-15)

Versions of packages gnome-cups-manager depends on:
ii  libart-2.0-2              2.3.17-1       Library of functions for 2D graphi
ii  libatk1.0-0               1.11.4-2       The ATK accessibility toolkit
ii  libbonobo2-0              2.14.0-1       Bonobo CORBA interfaces library
ii  libbonoboui2-0            2.14.0-2       The Bonobo UI library
ii  libc6                     2.3.6-7        GNU C Library: Shared libraries
ii  libcupsys2                1.1.23-15      Common UNIX Printing System(tm) - 
ii  libgconf2-4               2.14.0-1       GNOME configuration database syste
ii  libglade2-0               1:2.5.1-2      library to load .glade files at ru
ii  libglib2.0-0              2.10.2-1       The GLib library of C routines
ii  libgnome-keyring0         0.4.9-1        GNOME keyring services library
ii  libgnome2-0               2.14.1-2       The GNOME 2 library - runtime file
ii  libgnomecanvas2-0         2.14.0-2       A powerful object-oriented display
ii  libgnomecups1.0-1         0.2.2-1        GNOME library for CUPS interaction
ii  libgnomecupsui1.0-1c2a    0.31-1.1       UI extensions to libgnomecups
ii  libgnomeui-0              2.14.1-1       The GNOME 2 libraries (User Interf
ii  libgnomevfs2-0            2.14.1-2       GNOME virtual file-system (runtime
ii  libgtk2.0-0               2.8.16-1       The GTK+ graphical user interface 
ii  libice6                   6.9.0.dfsg.1-6 Inter-Client Exchange library
ii  liborbit2                 1:2.14.0-1     libraries for ORBit2 - a CORBA ORB
ii  libpango1.0-0             1.12.1-2       Layout and rendering of internatio
ii  libpopt0                  1.7-5          lib for parsing cmdline parameters
ii  libsm6                    6.9.0.dfsg.1-6 X Window System Session Management
ii  libx11-6                  6.9.0.dfsg.1-6 X Window System protocol client li
ii  libxml2                   2.6.24.dfsg-1  GNOME XML library
ii  xlibs                     6.9.0.dfsg.1-6 X Window System client libraries m
ii  zlib1g                    1:1.2.3-11     compression library - runtime

Versions of packages gnome-cups-manager recommends:
ii  gksu                          1.3.7-1    graphical frontend to su

-- no debconf information



Information forwarded to debian-bugs-dist@lists.debian.org, Ross Burton <ross@debian.org>:
Bug#369083; Package gnome-cups-manager. (full text, mbox, link).


Acknowledgement sent to Samuel Mimram <smimram@debian.org>:
Extra info received and forwarded to list. Copy sent to Ross Burton <ross@debian.org>. (full text, mbox, link).


Message #10 received at 369083@bugs.debian.org (full text, mbox, reply):

From: Samuel Mimram <smimram@debian.org>
To: Olivier Berger <oberger@ouvaton.org>
Cc: 369083@bugs.debian.org
Subject: Re: gnome-cups-manager: gnome-cups-icon bloated ?
Date: Wed, 21 Jun 2006 15:45:30 +0200
On Sat, May 27, 2006 at 01:35:49PM +0200, Olivier Berger wrote:
> Package: gnome-cups-manager
> Version: 0.31-1.1
> Severity: wishlist
> 
> gmemusage reports gnome-cups-icon taking 33928 Kb on my Gnome desktop.
> 
> I find that a bit too much for an icon that basically wouldn't be much used on the desktop.
> Is there a way to avoid such a low featured application taking up so much memory ?

You're lucky. Here, it was taking as much as 144 Mb. There's definitively
a memory leak in this app...

Cheers,

Samuel.



Severity set to `normal' from `wishlist' Request was from Samuel Mimram <smimram@debian.org> to control@bugs.debian.org. (full text, mbox, link).


Merged 369083 375891. Request was from David Pashley <david@davidpashley.com> to control@bugs.debian.org. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Ross Burton <ross@debian.org>:
Bug#369083; Package gnome-cups-manager. (full text, mbox, link).


Acknowledgement sent to Samuel Mimram <samuel.mimram@ens-lyon.org>:
Extra info received and forwarded to list. Copy sent to Ross Burton <ross@debian.org>. (full text, mbox, link).


Message #19 received at 369083@bugs.debian.org (full text, mbox, reply):

From: Samuel Mimram <samuel.mimram@ens-lyon.org>
To: 369083@bugs.debian.org
Cc: Jody Goldberg <jody@gnome.org>, control@bugs.debian.org
Subject: Memory leak in gnome-cups-icon comes from libgnomecups
Date: Mon, 03 Jul 2006 19:08:07 +0200
[Message part 1 (text/plain, inline)]
reassign 369083 libgnomecups1.0-1
tag 369083 + patch
thanks

Hi,

I think I found out why gnome-cups-icon was taking so much memory over
the time. After a few minutes of valgrinding, the main memory leak was
obviously this one:

900,877 bytes in 52,994 blocks are definitely lost in loss record 151 of 151
   at 0x4A1B80D: malloc (vg_replace_malloc.c:149)
   by 0x8933211: strdup (in /lib/libc-2.3.6.so)
   by 0x7A5E50A: gnome_cups_request_add_requested_attributes
(gnome-cups-request.c:482)
   by 0x7A59B51: update_attributes (gnome-cups-printer.c:321)
   by 0x7A5C7A2: update_printers (gnome-cups-printer.c:728)
   by 0x7A5C7F1: update_printers_timeout (gnome-cups-printer.c:757)
   by 0x86247DA: (within /usr/lib/libglib-2.0.so.0.1000.3)
   by 0x8624148: g_main_context_dispatch (in
/usr/lib/libglib-2.0.so.0.1000.3)
   by 0x86272B4: (within /usr/lib/libglib-2.0.so.0.1000.3)
   by 0x86275B5: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.1000.3)
   by 0x5AD2251: gtk_main (in /usr/lib/libgtk-x11-2.0.so.0.800.18)
   by 0x4049C8: main (gnome-cups-icon.c:136)

So I had a look at the source of the function
gnome_cups_request_add_requested_attributes in libgnomecups:

void
gnome_cups_request_add_requested_attributes (ipp_t *request,
					     ipp_tag_t group,
					     int n_attributes,
					     char **attributes)
{
	ipp_attribute_t *attr;
	int i;
	
	attr = ippAddStrings (request,
			      group,
			      IPP_TAG_KEYWORD,
			      "requested-attributes",
			      n_attributes, NULL, NULL);

	for (i = 0; i < n_attributes; i++) {
	attr->values[i].string.text = gnome_cups_strdup(attributes[i]);
	}
}

The problem here is that gnome_cups_strdup (which is the same as strdup)
allocates memory which is never freed by ippDelete. Namely, cups seems
to use its own memory management, by reference counting AFAICT, and the
strdupped strings are not taken in account. The fix is simple here: when
its last argument is not NULL and the tag IPP_TAG_COPY is present, the
function ippAddStrings does the copy of the strings on its own and
registers them in CUPS' memory management thing, as you can see in the
source of ippAddString:

value->string.text = ((int)type & IPP_TAG_COPY) ? (char *)values[i] :
_cupsStrAlloc(values[i]);

The attached patch seems to solve the memory leak.

Thanks!

Cheers,

Samuel.

PS: Jody, you can find the full debian bug report here:
http://bugs.debian.org/369083

PPS: maybe, some day, the world will understand that memory management
shouldn't be done by hand...
[leak_gnomecups.diff (text/plain, inline)]
--- libgnomecups-0.2.2.orig/libgnomecups/gnome-cups-request.c
+++ libgnomecups-0.2.2/libgnomecups/gnome-cups-request.c
@@ -469,18 +469,14 @@
 					     int n_attributes,
 					     char **attributes)
 {
-	ipp_attribute_t *attr;
-	int i;
 	
-	attr = ippAddStrings (request, 
-			      group,
-			      IPP_TAG_KEYWORD,
-			      "requested-attributes",
-			      n_attributes, NULL, NULL);
-
-	for (i = 0; i < n_attributes; i++) {
-		attr->values[i].string.text = gnome_cups_strdup (attributes[i]);
-	}
+	ippAddStrings (request,
+		      group,
+		      IPP_TAG_KEYWORD & IPP_TAG_COPY,
+		      "requested-attributes",
+		      n_attributes,
+		      NULL,
+		      (const char**)attributes);
 }
 
 typedef struct

Bug reassigned from package `gnome-cups-manager' to `libgnomecups1.0-1'. Request was from Samuel Mimram <samuel.mimram@ens-lyon.org> to control@bugs.debian.org. (full text, mbox, link).


Tags added: patch Request was from Samuel Mimram <samuel.mimram@ens-lyon.org> to control@bugs.debian.org. (full text, mbox, link).


Tags added: pending Request was from Loïc Minier <lool+gnome@via.ecp.fr> to control@bugs.debian.org. (full text, mbox, link).


Noted your statement that Bug has been forwarded to http://bugzilla.gnome.org/show_bug.cgi?id=339365. Request was from Loïc Minier <lool+gnome@via.ecp.fr> to control@bugs.debian.org. (full text, mbox, link).


Reply sent to Loic Minier <lool@dooz.org>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Olivier Berger <oberger@ouvaton.org>:
Bug acknowledged by developer. (full text, mbox, link).


Message #32 received at 369083-close@bugs.debian.org (full text, mbox, reply):

From: Loic Minier <lool@dooz.org>
To: 369083-close@bugs.debian.org
Subject: Bug#369083: fixed in libgnomecups 0.2.2-4
Date: Mon, 03 Jul 2006 13:02:35 -0700
Source: libgnomecups
Source-Version: 0.2.2-4

We believe that the bug you reported is fixed in the latest version of
libgnomecups, which is due to be installed in the Debian FTP archive:

libgnomecups1.0-1_0.2.2-4_i386.deb
  to pool/main/libg/libgnomecups/libgnomecups1.0-1_0.2.2-4_i386.deb
libgnomecups1.0-dev_0.2.2-4_i386.deb
  to pool/main/libg/libgnomecups/libgnomecups1.0-dev_0.2.2-4_i386.deb
libgnomecups_0.2.2-4.diff.gz
  to pool/main/libg/libgnomecups/libgnomecups_0.2.2-4.diff.gz
libgnomecups_0.2.2-4.dsc
  to pool/main/libg/libgnomecups/libgnomecups_0.2.2-4.dsc



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 369083@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Loic Minier <lool@dooz.org> (supplier of updated libgnomecups package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.7
Date: Mon,  3 Jul 2006 21:38:36 +0200
Source: libgnomecups
Binary: libgnomecups1.0-1 libgnomecups1.0-dev
Architecture: source i386
Version: 0.2.2-4
Distribution: unstable
Urgency: low
Maintainer: Ross Burton <ross@debian.org>
Changed-By: Loic Minier <lool@dooz.org>
Description: 
 libgnomecups1.0-1 - GNOME library for CUPS interaction
 libgnomecups1.0-dev - GNOME library for CUPS interaction (headers)
Closes: 369083 375891
Changes: 
 libgnomecups (0.2.2-4) unstable; urgency=low
 .
   * New patch, 24_mem-leak, by Samuel Mimram to fix memory leak in
     gnome_cups_request_add_requested_attributes(). (Closes: #369083, #375891)
Files: 
 c1f0ad411e19526ea07efc711c94aab3 1448 - optional libgnomecups_0.2.2-4.dsc
 7713b7effef9073e661a72147bdca4e8 6013 - optional libgnomecups_0.2.2-4.diff.gz
 a8293163e59e85479ccec0b07e4f22e4 66280 libs optional libgnomecups1.0-1_0.2.2-4_i386.deb
 cbd2fef615611bf3a8c85cd217c39108 43464 libdevel optional libgnomecups1.0-dev_0.2.2-4_i386.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEqXMM4VUX8isJIMARAm4BAJsHU0gWOWtvS3DDtv7Antwa+X5AYgCgoTb2
xLyOIBxx1YCIxs1uzChGUcI=
=ud5+
-----END PGP SIGNATURE-----




Reply sent to Loic Minier <lool@dooz.org>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Soeren Sonnenburg <bugreports@nn7.de>:
Bug acknowledged by developer. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Ross Burton <ross@debian.org>:
Bug#369083; Package libgnomecups1.0-1. (full text, mbox, link).


Acknowledgement sent to Samuel Mimram <samuel.mimram@ens-lyon.org>:
Extra info received and forwarded to list. Copy sent to Ross Burton <ross@debian.org>. (full text, mbox, link).


Message #42 received at 369083@bugs.debian.org (full text, mbox, reply):

From: Samuel Mimram <samuel.mimram@ens-lyon.org>
To: 369083@bugs.debian.org, control@bugs.debian.org
Subject: Error in the patch for the memory leak
Date: Tue, 04 Jul 2006 08:39:03 +0200
[Message part 1 (text/plain, inline)]
reopen 369083
thanks

Hi,

I made a mistake in the patch I sent to you: the IPP_TAGs should
obviously be or-ed and not and-ed... I've checked, the version in
incoming contains this mistake. Here is an updated version of the patch.

Cheers,

Samuel.
[leak_gnomecups.diff (text/plain, inline)]
--- libgnomecups-0.2.2.orig/libgnomecups/gnome-cups-request.c
+++ libgnomecups-0.2.2/libgnomecups/gnome-cups-request.c
@@ -469,18 +469,14 @@
 					     int n_attributes,
 					     char **attributes)
 {
-	ipp_attribute_t *attr;
-	int i;
 	
-	attr = ippAddStrings (request, 
-			      group,
-			      IPP_TAG_KEYWORD,
-			      "requested-attributes",
-			      n_attributes, NULL, NULL);
-
-	for (i = 0; i < n_attributes; i++) {
-		attr->values[i].string.text = gnome_cups_strdup (attributes[i]);
-	}
+	ippAddStrings (request,
+		      group,
+		      IPP_TAG_KEYWORD | IPP_TAG_COPY,
+		      "requested-attributes",
+		      n_attributes,
+		      NULL,
+		      (const char**)attributes);
 }
 
 typedef struct

Bug reopened, originator not changed. Request was from Samuel Mimram <samuel.mimram@ens-lyon.org> to control@bugs.debian.org. (full text, mbox, link).


Reply sent to Loïc Minier <lool@dooz.org>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Olivier Berger <oberger@ouvaton.org>:
Bug acknowledged by developer. (full text, mbox, link).


Message #49 received at 369083-done@bugs.debian.org (full text, mbox, reply):

From: Loïc Minier <lool@dooz.org>
To: Samuel Mimram <samuel.mimram@ens-lyon.org>, 369083-done@bugs.debian.org
Subject: Re: Bug#369083: Error in the patch for the memory leak
Date: Tue, 4 Jul 2006 11:55:41 +0200
Version: 0.2.2-5

        Hi,

On Tue, Jul 04, 2006, Samuel Mimram wrote:
> I made a mistake in the patch I sent to you: the IPP_TAGs should
> obviously be or-ed and not and-ed... I've checked, the version in
> incoming contains this mistake. Here is an updated version of the patch.

 I don't know how you checked incoming, but I uploaded 0.2.2-5 with a
 fixed patch after the 0.2.2-4 with your patch.

 I'm closing this bug with version 0.2.2-5 which has a fixed patch I
 grabbed upstream, I didn't compare with yours though, so if you want
 you can grab 0.2.2-5 from incoming and verify the patch matches yours.

   Bye,
-- 
Loïc Minier <lool@dooz.org>



Reply sent to Loïc Minier <lool@dooz.org>:
You have taken responsibility. (full text, mbox, link).


Notification sent to Soeren Sonnenburg <bugreports@nn7.de>:
Bug acknowledged by developer. (full text, mbox, link).


Information forwarded to debian-bugs-dist@lists.debian.org, Ross Burton <ross@debian.org>:
Bug#369083; Package libgnomecups1.0-1. (full text, mbox, link).


Acknowledgement sent to Samuel Mimram <samuel.mimram@ens-lyon.org>:
Extra info received and forwarded to list. Copy sent to Ross Burton <ross@debian.org>. (full text, mbox, link).


Message #59 received at 369083@bugs.debian.org (full text, mbox, reply):

From: Samuel Mimram <samuel.mimram@ens-lyon.org>
To: Loïc Minier <lool@dooz.org>
Cc: 369083@bugs.debian.org
Subject: Re: Bug#369083: Error in the patch for the memory leak
Date: Tue, 04 Jul 2006 12:00:54 +0200
Hi,

Loïc Minier wrote:
> On Tue, Jul 04, 2006, Samuel Mimram wrote:
>> I made a mistake in the patch I sent to you: the IPP_TAGs should
>> obviously be or-ed and not and-ed... I've checked, the version in
>> incoming contains this mistake. Here is an updated version of the patch.
> 
>  I don't know how you checked incoming, but I uploaded 0.2.2-5 with a
>  fixed patch after the 0.2.2-4 with your patch.
> 
>  I'm closing this bug with version 0.2.2-5 which has a fixed patch I
>  grabbed upstream, I didn't compare with yours though, so if you want
>  you can grab 0.2.2-5 from incoming and verify the patch matches yours.

Ah, I missed the 0.2.2-5 (I only saw 0.2.2-4). The patch in it is
essentially the same as mine (corrected). So everything is alright.

Thanks for being so responsive!

Cheers,

Samuel.



Tags added: fixed-upstream Request was from bts-link-upstream@lists.alioth.debian.org to control@bugs.debian.org. (full text, mbox, link).


Tags added: fixed-upstream Request was from bts-link-upstream@lists.alioth.debian.org to control@bugs.debian.org. (full text, mbox, link).


Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 26 Jun 2007 20:16:34 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sat Jan 13 20:03:31 2018; Machine Name: beach

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.