[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug binutils/15545] BFD cache modifies cacheable flag
From: |
nickc at redhat dot com |
Subject: |
[Bug binutils/15545] BFD cache modifies cacheable flag |
Date: |
Tue, 01 Aug 2023 13:36:08 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=15545
Nick Clifton <nickc at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at sourceware dot org |nickc at redhat dot com
--- Comment #4 from Nick Clifton <nickc at redhat dot com> ---
Hi Tom,
(In reply to Tom Tromey from comment #3)
> I forgot entirely about this bug.
Me too. :-)
> One option might be to save the mode so that the cache
> can properly reopen all closed fds.
I do not think that this will work. When bfd_cache_close_all()
calls fclose() all information is lost/made invalid, including
the file descriptor that was passed to bfd_fopen() in the first
place. So in order to be able to reopen the file bfd_fopen()
would need to find out (or be told) the mode, flags and pathname
used to create the original file descriptor and then save them
somewhere.
I still like my original solution. If a bfd has been opened
in such a way that it is uncacheable, then code should not
expect to close it and then magically have it be reopened.
> Another option might be to add a new API that doesn't carry
> this baggage.
You mean something like:
FUNCTION
bfd_cache_close_cacheables
SYNOPSIS
bool bfd_cache_close_cacheables (void);
DESCRIPTION
Close and remove all BFDs in the cache that can be safely
reopened by the BFD library later on. If any closed BFD has
an attached file then it is closed as well.
BFDs for which bfd_get_cacheable() returns true are considered
to be safe to close. This applies to most BFDs opened by the
library, with the notable exception of BFDs which were opened
by calling bfd_fopen() on an already opened file descriptor.
<<FALSE>> is returned if closing one of the file fails, <<TRUE>> is
returned if all is well.
That should be fairly easy to code. It would also be worthwhile updating
the description of the bfd_cache_close_all() function to specifically
mention that it will close uncacheable files, and pointing the reader at
this new function as an alternative.
Aside - it looks there is a potential infinite loop problem with
bfd_cache_close_all() since the call to bfd_cache_close() can
return without having changed bfd_last_cache:
while (bfd_last_cache != NULL)
ret &= bfd_cache_close (bfd_last_cache);
So this ought to be fixed too.
What do you think ?
Cheers
Nick
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug binutils/15545] BFD cache modifies cacheable flag,
nickc at redhat dot com <=
- [Bug binutils/15545] BFD cache modifies cacheable flag, tromey at sourceware dot org, 2023/08/01
- [Bug binutils/15545] BFD cache modifies cacheable flag, tromey at sourceware dot org, 2023/08/01
- [Bug binutils/15545] BFD cache modifies cacheable flag, nickc at redhat dot com, 2023/08/03
- [Bug binutils/15545] BFD cache modifies cacheable flag, tromey at sourceware dot org, 2023/08/03
- [Bug binutils/15545] BFD cache modifies cacheable flag, cvs-commit at gcc dot gnu.org, 2023/08/04