Bug 1309633 - 'find -execdir' opens too many file descriptors [el7]
Summary: 'find -execdir' opens too many file descriptors [el7]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: findutils
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Jakub Heger
URL:
Whiteboard:
: 1475645 1563265 (view as bug list)
Depends On:
Blocks: 1223557 1465901 1549617 1549689 1551061
TreeView+ depends on / blocked
 
Reported: 2016-02-18 10:54 UTC by Branislav Náter
Modified: 2021-12-10 14:36 UTC (History)
10 users (show)

Fixed In Version: findutils-4.5.11-6.el7
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of: 1223557
Environment:
Last Closed: 2018-10-30 08:09:20 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3128791 0 None None None 2017-07-27 07:06:07 UTC
Red Hat Product Errata RHBA-2018:3076 0 None None None 2018-10-30 08:09:32 UTC

Description Branislav Náter 2016-02-18 10:54:06 UTC
Reproduced on findutils-4.5.11-5.el7

+++ This bug was initially created as a clone of Bug #1223557 +++

Description of problem:

I'm using Scientific Linux 6.6, but I am fairly sure this is an RHEL problem.  When using the '-execdir' option to find, the program apparently opens a new file descriptor every time it runs the command, and never closes it.

As a result, if you're traversing a directory tree that contains more
than $(ulimit -n) files (1024 by default), find will fail with the
message

  find: Failed to save working directory in order to run a command on `foo': Too many open files


Version-Release number of selected component (if applicable):

findutils-4.4.2-6.el6.x86_64


Steps to Reproduce:

An easy way to see what is happening is to run "find . -execdir sh -c 'ls /proc/self/fd | wc -l' ';'".


Actual results:

The number of open file descriptors increases every time the command is run.  When it reaches 1024, find aborts with an error.


Expected results:

The number of file descriptors should be constant, and the 'find' command should succeed, regardless of how many files are found.


Additional info:

This problem doesn't occur with the Debian version of find (which is the same upstream version, 4.4.2.)


--- Additional comment from Kamil Dudka on 2015-05-22 13:59:33 EDT ---

Thank you for reporting the bug.

I believe the following upstream commit will fix it:

http://git.savannah.gnu.org/cgit/findutils.git/commit/?id=183115d0

diff --git a/find/pred.c b/find/pred.c
index d6bbaea..2a89a37 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -681,14 +681,16 @@ impl_pred_exec (const char *pathname,
                       0);
        }

       /* Actually invoke the command. */
       result = execp->ctl.exec_callback(&execp->ctl,
                                        &execp->state);
     }
+  if (local)
+    free_cwd (execp->wd_for_exec);
   if (target != pathname)
     {
       assert (local);
       free (target);
     }
   return result;
 }

Comment 1 Kamil Dudka 2016-02-18 14:51:27 UTC
Good point.  This was fixed upstream in v4.5.11-41-g183115d, so it is not included in the 4.5.11 upstream release, which the el7 findutils package is based on.

Comment 5 Kamil Dudka 2017-07-27 07:06:07 UTC
*** Bug 1475645 has been marked as a duplicate of this bug. ***

Comment 6 Kamil Dudka 2018-04-03 13:58:57 UTC
*** Bug 1563265 has been marked as a duplicate of this bug. ***

Comment 13 errata-xmlrpc 2018-10-30 08:09:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3076


Note You need to log in before you can comment on or make changes to this bug.