From a357defdfe2af758d5ec9f0040949bf1db4cbe53 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 9 Nov 2024 13:45:50 -0700 Subject: Lock bfd_stat and bfd_get_mtime PR gdb/31713 points out some races when using the background DWARF reader. This particular patch fixes some of these, namely the ones when using the sim. In this case, the 'load' command calls reopen_exec_file, which calls bfd_stat, which introduces a race. BFD only locks globals -- concurrent use of a single BFD must be handled by the application. To this end, this patch adds locked wrappers for bfd_stat and bfd_get_mtime. I couldn't reproduce these data races but the original reporter tested the patch and confirms that it helps. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31713 Approved-By: Andrew Burgess --- gdb/objfiles.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gdb/objfiles.c') diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 76d17f5..84866e1 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -281,7 +281,7 @@ objfile::objfile (gdb_bfd_ref_ptr bfd_, program_space *pspace, if (obfd != nullptr) { - mtime = bfd_get_mtime (obfd.get ()); + mtime = gdb_bfd_get_mtime (obfd.get ()); /* Build section table. */ build_objfile_section_table (this); -- cgit v1.1