This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR gold/17896: Plugin_manager::release_input_file leaks file descriptors
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Cary Coutant <ccoutant at google dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 28 Jan 2015 10:37:18 -0800
- Subject: Re: PATCH: PR gold/17896: Plugin_manager::release_input_file leaks file descriptors
- Authentication-results: sourceware.org; auth=none
- References: <20150128180803 dot GA15015 at intel dot com> <CAHACq4qe28_25baOH2QCnT9pGv6SoRce78DLLpqt9b_jQpEdcg at mail dot gmail dot com>
On Wed, Jan 28, 2015 at 10:28 AM, Cary Coutant <ccoutant@google.com> wrote:
>> + PR gold/17896
>> + * plugin.cc: Include <unistd.h> and <cerrno>.
>> + (Plugin_manager::release_input_file): Close file descriptor when
>> + called from the claim_file hook. Otherwise, release the object.
>> + if (::close(f.fd) < 0)
>
> File descriptors for object files are managed by the Descriptors
> class; we should never call ::close() directly.
>
> Calling obj->unlock() on the file should be sufficient to release the
> descriptor. It may not be closed immediately, but it will get closed
> eventually if we get close to running out of file descriptors. If
> Descriptors::close_some_descriptor() for some reason doesn't consider
> that descriptor available for closing, then there's a bug elsewhere.
>
Well, gold never releases those file descriptors. I will leave this
bug to you.
--
H.J.