RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1223557 - 'find -execdir' opens too many file descriptors
Summary: 'find -execdir' opens too many file descriptors
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: findutils
Version: 6.6
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: Branislav Náter
URL:
Whiteboard:
Depends On: 1309633
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-20 20:52 UTC by benjaminmoody
Modified: 2016-02-19 12:09 UTC (History)
2 users (show)

Fixed In Version: findutils-4.4.2-8.el6
Doc Type: Bug Fix
Doc Text:
Cause: If the -execdir option was given to find, it did not close file descriptors as they became unused. Consequence: The limit of open file descriptors was exceeded. Fix: An upstream patch has been applied to find source code to release file descriptors that become unused. Result: find -execdir no longer excessively consumes file descriptors.
Clone Of:
: 1309633 (view as bug list)
Environment:
Last Closed: 2016-01-14 17:24:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0038 0 normal SHIPPED_LIVE findutils bug fix update 2016-01-14 22:24:10 UTC

Internal Links: 1563265

Description benjaminmoody 2015-05-20 20:52:47 UTC
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.)

Comment 2 Kamil Dudka 2015-05-22 17:59:33 UTC
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 10 errata-xmlrpc 2016-01-14 17:24:49 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://rhn.redhat.com/errata/RHBA-2016-0038.html


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