Bug 11271 - posix call nftw() leaks file handles on FTW_CHDIR
Summary: posix call nftw() leaks file handles on FTW_CHDIR
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-10 22:24 UTC by Hans-Georg Thien
Modified: 2014-06-30 18:49 UTC (History)
1 user (show)

See Also:
Host: i?86-*-linux*
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
testcase (564 bytes, text/plain)
2010-02-11 01:54 UTC, Hans-Georg Thien
Details
Makefile for the testcode (80 bytes, text/plain)
2010-02-11 01:56 UTC, Hans-Georg Thien
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Georg Thien 2010-02-10 22:24:56 UTC
It seems that the POSIX call nftw() doesn't clean up correctly when the flag
FTW_CHDIR is used.

Example:

one directory - without containing subdirectories - containing 4 files.

int my_callback()
{   
    return 0;
}

if nftw is called 1000 times as in

   nftw("." , my_callback, 20, FTW_CHDIR)

then I am left with 1000 open file handles afterwards.
Comment 1 Hans-Georg Thien 2010-02-11 01:54:40 UTC
Created attachment 4586 [details]
testcase

source code to reproduce the issue.

download the Makefile attachment and type 

   make

to build.

This should produce two binaries

   ./ok    - which works as expected
   ./buggy - which shows the described bug when executed

the only difference is that the flag FTW_CHDIR is used in ./buggy
Comment 2 Hans-Georg Thien 2010-02-11 01:56:45 UTC
Created attachment 4587 [details]
Makefile for the testcode

simpy type

   make

to build. See upload comment on 'main.cpp' on how to use the testcase
Comment 3 Ulrich Drepper 2010-02-11 04:32:44 UTC
Fixed in git.