Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH v2 2/2] [gdb/symtab] Fix data race in try_open_dwop_file
Date: Wed, 27 May 2026 23:55:36 +0200	[thread overview]
Message-ID: <c7677dec-8fd3-4b0e-8358-1c4308549dfb@suse.de> (raw)
In-Reply-To: <878q947f5n.fsf@tromey.com>

On 5/27/26 10:48 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> AFAIU, bfd_check_format does locking, but it's only used to [1]:
> Tom> ...
> Tom> lock the internal global data structures of BFD (like its global cache
> Tom> or some global counter), but not data in individual `bfd *`instances.
> Tom> ...
> 
> Tom> So while it does do locking, it's not sufficient.
> 
> How so?
> 
> I mean, since it's a recursive lock, it's not like locking it some more
> can cause a problem.  But at the same time I don't think it adds any
> more protection.

Well, the race is on fields of individual "bfd *" instances.

More specifically, this write in bfd_cache_delete:
...
   abfd->last_io = bfd_io_force;
...
vs one of these reads (abfd->format or abfd->direction) in:
...
   if (!bfd_read_p (abfd)
       || (unsigned int) abfd->format >= (unsigned int) bfd_type_end)
...

As pointed out by Simon, the bfd code doesn't provide any locking for that.

So the gdb wrappers provide the additional locking needed.  AFAIU, this 
is not specific to these wrappers, all gdb_bfd wrapper are needed for 
the same reason.

Thanks,
- Tom

  reply	other threads:[~2026-05-27 21:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-16 18:09 [PATCH v2 0/2] [gdb] TSAN fixes Tom de Vries
2026-02-16 18:09 ` [PATCH v2 1/2] [gdb/symtab] Replace per-BFD lock with global BFD lock Tom de Vries
2026-03-04 20:20   ` Tom Tromey
2026-03-05 21:13     ` Tom de Vries
2026-02-16 18:09 ` [PATCH v2 2/2] [gdb/symtab] Fix data race in try_open_dwop_file Tom de Vries
2026-03-04 20:29   ` Tom Tromey
2026-05-27 19:16     ` Tom de Vries
2026-05-27 20:48       ` Tom Tromey
2026-05-27 21:55         ` Tom de Vries [this message]
2026-03-03 15:34 ` [PING][PATCH v2 0/2] [gdb] TSAN fixes Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7677dec-8fd3-4b0e-8358-1c4308549dfb@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox