[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#493382: marked as done (apt-pkg: memory leak in ReadConfigFile)



Your message dated Sat, 8 Aug 2009 14:08:05 +0200
with message-id <c64043e60908080508i37edb280ka6af289b1d76c72f@mail.gmail.com>
and subject line Fixed: apt-pkg: memory leak in ReadConfigFile
has caused the Debian Bug report #493382,
regarding apt-pkg: memory leak in ReadConfigFile
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
493382: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=493382
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: apt
Version: 0.7.14
Severity: normal
Tags: patch

Hi,

there is a rather unfortunate leak in ReadConfigFile (in Adept, it managed to
leak out a megabyte of memory in no time, gods only know why -- there might be
another problem lurking calling ReadConfigFile too many times, although it does
leak a kilobyte per config line parsed...). I guess a patch is worth a thousand
words:

diff -ruN apt-0.7.14/apt-pkg/contrib/configuration.cc apt-0.7.14+morn/apt-pkg/contrib/configuration.cc
--- apt-0.7.14/apt-pkg/contrib/configuration.cc	2008-05-28 15:22:14.000000000 +0200
+++ apt-0.7.14+morn/apt-pkg/contrib/configuration.cc	2008-08-02 17:08:26.000000000 +0200
@@ -25,6 +25,7 @@
 #include <algorithm>
 #include <fstream>
 #include <iostream>
+#include <string>
     
 #include <stdio.h>
 #include <dirent.h>
@@ -513,16 +514,11 @@
       std::string Fragment;
 
       // Grab the next line of F and place it in Input.
-      do
-	{
-	  char *Buffer = new char[1024];
-
-	  F.clear();
-	  F.getline(Buffer,sizeof(Buffer) / 2);
-
-	  Input += Buffer;
-	}
-      while (F.fail() && !F.eof());
+      std::string Buffer;
+
+      F.clear();
+      std::getline(F, Buffer);
+      Input += Buffer;
 
       // Expand tabs in the input line and remove leading and trailing
       // whitespace.

Yours,
    Petr.

-- Package-specific info:

-- apt-config dump --

APT "";
APT::Architecture "i386";
APT::Build-Essential "";
APT::Build-Essential:: "build-essential";
APT::Install-Recommends "1";
APT::Install-Suggests "0";
APT::Acquire "";
APT::Acquire::Translation "environment";
APT::NeverAutoRemove "";
APT::NeverAutoRemove:: "^linux-image.*";
APT::NeverAutoRemove:: "^linux-restricted-modules.*";
APT::Periodic "";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::Unattended-Upgrade "0";
APT::Authentication "";
APT::Authentication::TrustCDROM "true";
Dir "/";
Dir::State "var/lib/apt/";
Dir::State::lists "lists/";
Dir::State::cdroms "cdroms.list";
Dir::State::userstatus "status.user";
Dir::State::status "/var/lib/dpkg/status";
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "srcpkgcache.bin";
Dir::Cache::pkgcache "pkgcache.bin";
Dir::Etc "etc/apt/";
Dir::Etc::sourcelist "sources.list";
Dir::Etc::sourceparts "sources.list.d";
Dir::Etc::vendorlist "vendors.list";
Dir::Etc::vendorparts "vendors.list.d";
Dir::Etc::main "apt.conf";
Dir::Etc::parts "apt.conf.d";
Dir::Etc::preferences "preferences";
Dir::Bin "";
Dir::Bin::methods "/usr/lib/apt/methods";
Dir::Bin::dpkg "/usr/bin/dpkg";
Dir::Log "var/log/apt";
Dir::Log::Terminal "term.log";
Unattended-Upgrade "";
Unattended-Upgrade::Allowed-Origins "";
Unattended-Upgrade::Allowed-Origins:: "Debian stable";
DPkg "";
DPkg::Pre-Install-Pkgs "";
DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true";
DPkg::Post-Invoke "";
DPkg::Post-Invoke:: "if [ -x /usr/bin/debsums ]; then /usr/bin/debsums --generate=nocheck -sp /var/cache/apt/archives; fi";
Acquire "";
Acquire::http "";
Acquire::http::Timeout "10";
Acquire::ftp "";
Acquire::ftp::Timeout "10";

-- /etc/apt/preferences --

Package: *
Pin: release unstable
Pin-Priority: 500

Package: gnuplot
Pin: version 4.2.0-2
Pin-Priority: 1001

Package: libqt*
Pin: version 4.4.0-4+morn
Pin-Priority: 1001

-- /etc/apt/sources.list --

deb http://localhost:9999/debian/ stable main 
deb http://localhost:9999/debian/ lenny main
deb http://localhost:9999/debian/ sid main 
deb http://localhost:9999/debian/ experimental main 
deb-src http://localhost:9999/debian/ sid main 
deb-src http://localhost:9999/debian/ experimental main 

deb http://localhost:9999/marillat/ sid main 

#deb file:/var/cache/apt-build/repository apt-build main 
#deb file:/home/mornfall/dev/deb/ ./
# deb http://homer.mexico.debconf.org/debian/ sid main 
# deb http://homer.mexico.debconf.org/debian/ etch main 
# deb http://ftp.cz.debian.org/debian/ etch main 
#deb http://ftp.cz.debian.org/debian/ ../project/experimental main 
#deb http://ftp.cz.debian.org/debian/ etch main non-free contrib 
# deb-src http://homer.mexico.debconf.org/debian/ sid main 
#deb http://mentors.debian.net/debian sid contrib 

# deb http://security.debian.org/ etch/updates main 
# deb-src http://security.debian.org/ etch/updates main 

# deb ftp://ftp.nerim.net/debian-marillat/ etch main 
# deb ftp://ftp.nerim.net/debian-marillat/ sid main 

# deb http://snapshot.debian.net/archive pool kpowersave 
# deb http://snapshot.debian.net/archive pool powersave 
# deb-src http://kubuntu.no-ip.org/kubuntu dapper main 

# deb http://ftp.ch.debian-unofficial.org/mirror/debian-unofficial/debian/ sarge main contrib non-free 
#deb http://ftp.sk.debian-unofficial.org/debian/ sarge main contrib non-free 
#deb http://download.skype.com/linux/repos/debian/ stable non-free 

#deb http://kernel-archive.buildserver.net/debian-kernel/ trunk main

## Christian Marillat's Mult-Media Repository for Unstable
#deb http://www.debian-multimedia.org sid main

## RareWares/Debian Multi-Media Repository for Unstable
#deb http://www.rarewares.org/debian/packages/unstable/ ./

#deb http://kubuntu.org/packages/kde4-3.80.3/ edgy main

#deb http://deb.opera.com/opera/ unstable non-free
#deb http://www.xapian.org/debian/ unstable main

#deb http://anna.fi.muni.cz/~xrockai/adept-3-deb/ ./

#deb http://localhost/result ./

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.24-rc7-1-morn (PREEMPT)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt depends on:
ii  debian-archive-keyring   2008.04.16+nmu1 GnuPG archive keys of the Debian a
ii  libc6                    2.7-13          GNU C Library: Shared libraries
ii  libgcc1                  1:4.3.1-8       GCC support library
ii  libstdc++6               4.3.1-8         The GNU Standard C++ Library v3

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc                       <none>     (no description available)
ii  aptitude                      0.4.11.8-1 terminal-based package manager
ii  bzip2                         1.0.5-0.1  high-quality block-sorting file co
ii  dpkg-dev                      1.14.20    Debian package development tools
ii  lzma                          4.43-14    Compression method of 7z format in

-- no debconf information



--- End Message ---
--- Begin Message ---
Version: 0.7.22

Thanks for your reports and the various patches, but i think
the issue is now fixed in version 0.7.22 and i therefore close it.

extracted from the 0.7.22 changelog:
  [ Julian Andres Klode ]
  * apt-pkg/contrib/configuration.cc: Fix a small memory leak in
    ReadConfigFile.


The fix was applied in rev 1789 with the following diff:
--- apt-pkg/contrib/configuration.cc    2009-06-09 15:33:22 +0000
+++ apt-pkg/contrib/configuration.cc    2009-06-12 17:07:40 +0000
@@ -521,6 +521,7 @@
          F.getline(Buffer,sizeof(Buffer) / 2);

          Input += Buffer;
+         delete[] Buffer;
        }
       while (F.fail() && !F.eof());



Best regards / Mit freundlichen Grüßen,

David "DonKult" Kalnischkies


--- End Message ---

Reply to: