Rev 4750: Bug #583486, close the current-dir file descriptor in http://bazaar.launchpad.net/~jameinel/bzr/readdir_leaks_583486

John Arbash Meinel john at arbash-meinel.com
Thu May 20 22:23:59 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/readdir_leaks_583486

------------------------------------------------------------
revno: 4750
revision-id: john at arbash-meinel.com-20100520212347-y6onphkgkspziji2
parent: pqm at pqm.ubuntu.com-20100519215940-l5f6wtm2jc20ajpx
fixes bug(s): https://launchpad.net/bugs/583486
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: readdir_leaks_583486
timestamp: Thu 2010-05-20 16:23:47 -0500
message:
  Bug #583486, close the current-dir file descriptor
  
  This code path is triggered when you are given a bunch of files rather than directories
  to commands like 'commit' and 'status'. It would try to check for files in each
  path passed in, and leak a file descriptor for each one that was not a directory.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2010-04-29 03:25:12 +0000
+++ b/NEWS	2010-05-20 21:23:47 +0000
@@ -29,18 +29,23 @@
 * Reduce peak memory by one copy of compressed text.
   (John Arbash Meinel, #566940)
 
-
-* Selftest with versions of subunit that support ``stopTestRun`` will no longer
-  error. This error was caused by 2.0 not being updated when upstream
-  python merged the end of run patch, which chose ``stopTestRun`` rather than
-  ``done``. (Robert Collins, #571437)
-
 * Repositories accessed via a smart server now reject being stacked on a
   repository in an incompatible format, as is the case when accessing them
   via other methods.  This was causing fetches from those repositories via
   a smart server (e.g. using ``bzr branch``) to receive invalid data.
   (Andrew Bennetts, #562380)
 
+* Selftest with versions of subunit that support ``stopTestRun`` will no longer
+  error. This error was caused by 2.0 not being updated when upstream
+  python merged the end of run patch, which chose ``stopTestRun`` rather than
+  ``done``. (Robert Collins, #571437)
+
+* When passing a file to ``UTF8DirReader`` make sure to close the current
+  directory file handle after the chdir fails. Otherwise when passing many
+  filenames into a command line ``bzr status`` we would leak descriptors.
+  (John Arbash Meinel, #583486)
+
+
 bzr 2.0.5
 #########
 

=== modified file 'bzrlib/_readdir_pyx.pyx'
--- a/bzrlib/_readdir_pyx.pyx	2009-12-23 02:19:04 +0000
+++ b/bzrlib/_readdir_pyx.pyx	2010-05-20 21:23:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2008, 2009 Canonical Ltd
+# Copyright (C) 2006, 2008, 2009, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -307,6 +307,9 @@
         if orig_dir_fd == -1:
             raise_os_error(errno, "open: ", ".")
         if -1 == chdir(path):
+            # Ignore the return value, because we are already raising an
+            # exception
+            close(orig_dir_fd)
             raise_os_error(errno, "chdir: ", path)
     else:
         orig_dir_fd = -1



More information about the bazaar-commits mailing list