aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-03-23 15:19:20 -0600
committerTom Tromey <tom@tromey.com>2024-04-16 14:02:15 -0600
commit20bf7711bce2188c1af985a87df23c4653c2cc7a (patch)
tree1694e1225dc42af7cd6b46d07e6323bd7bcd4a33 /bfd/libbfd.h
parentbacc61fd3e6fd61a59fb59bcc657be17a381520d (diff)
downloadfsf-binutils-gdb-20bf7711bce2188c1af985a87df23c4653c2cc7a.zip
fsf-binutils-gdb-20bf7711bce2188c1af985a87df23c4653c2cc7a.tar.gz
fsf-binutils-gdb-20bf7711bce2188c1af985a87df23c4653c2cc7a.tar.bz2
Avoid cache race in bfd_check_format_matches
Running the gdb test suite with the thread sanitizer enabled shows a race when bfd_check_format_matches and bfd_cache_close_all are called simultaneously on different threads. This patch fixes this race by having bfd_check_format_matches temporarily remove the BFD from the file descriptor cache -- leaving it open while format-checking proceeds. In this setup, the BFD client is responsible for closing the BFD again on the "checking" thread, should that be desired. gdb does this by calling bfd_cache_close in the relevant worker thread. An earlier version of this patch omitted the "possibly_cached" helper function. However, this ran into crashes in the binutils test suite involving the archive-checking abort in bfd_cache_lookup_worker. I do not understand the purpose of this check, so I've simply had the new function work around it. I couldn't find any comments explaining this situation, either. I suspect that there may still be races related to this case, but I don't think I have access to the platforms where gdb deals with archives. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31264
Diffstat (limited to 'bfd/libbfd.h')
-rw-r--r--bfd/libbfd.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index d106262..5e8ed9e 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1055,6 +1055,8 @@ void *bfd_arch_default_fill (bfd_size_type count,
/* Extracted from cache.c. */
bool bfd_cache_init (bfd *abfd) ATTRIBUTE_HIDDEN;
+bool bfd_cache_set_uncloseable (bfd *abfd, bool value, bool *old) ATTRIBUTE_HIDDEN;
+
FILE* bfd_open_file (bfd *abfd) ATTRIBUTE_HIDDEN;
/* Extracted from hash.c. */