forked from Imagelibrary/binutils-gdb
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 <aburgess@redhat.com>
This commit is contained in:
@@ -51,7 +51,7 @@ reopen_exec_file (void)
|
||||
|
||||
/* If the timestamp of the exec file has changed, reopen it. */
|
||||
struct stat st;
|
||||
int res = bfd_stat (exec_bfd, &st);
|
||||
int res = gdb_bfd_stat (exec_bfd, &st);
|
||||
|
||||
if (res == 0
|
||||
&& current_program_space->ebfd_mtime != 0
|
||||
@@ -70,8 +70,8 @@ validate_files (void)
|
||||
if (!core_file_matches_executable_p (current_program_space->core_bfd (),
|
||||
current_program_space->exec_bfd ()))
|
||||
warning (_("core file may not match specified executable file."));
|
||||
else if (bfd_get_mtime (current_program_space->exec_bfd ())
|
||||
> bfd_get_mtime (current_program_space->core_bfd ()))
|
||||
else if (gdb_bfd_get_mtime (current_program_space->exec_bfd ())
|
||||
> gdb_bfd_get_mtime (current_program_space->core_bfd ()))
|
||||
warning (_("exec file is newer than core file."));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user