]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Fix data race in try_open_dwop_file master
authorTom de Vries <tdevries@suse.de>
Thu, 28 May 2026 20:16:46 +0000 (22:16 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 28 May 2026 20:16:46 +0000 (22:16 +0200)
commitb5c67b520149fe04779a229a39dc32593394f329
tree49b115be7a90c3dd90acddb12d702a7d63cc9dc4
parent7f91647689e8fd3d9b1d07745f95ab12fbc24e7f
[gdb/symtab] Fix data race in try_open_dwop_file

The call to bfd_check_format in try_open_dwop_file:
...
    /* The operations below are not thread-safe, use a lock to synchronize
       concurrent accesses.  */
    static gdb::mutex mutex;
    gdb::lock_guard<gdb::mutex> lock (mutex);

    if (!bfd_check_format (sym_bfd.get (), bfd_object))
      return NULL;
...
accesses the sym_bfd.get () BFD, so it should be guarded by the global BFD
lock.

Fix this by:
- using the global BFD lock in gdb_bfd_check_format, and
- removing the local lock.

Likewise, use the global BFD lock in gdb_bfd_check_format_matches.

The local lock also guarded a call to gdb_bfd_record_inclusion, which doesn't
do any locking, so likewise use the global BFD lock in
gdb_bfd_record_inclusion.

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33809
gdb/dwarf2/read.c
gdb/gdb_bfd.c
gdb/gdb_bfd.h