From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [RFC 1/3] [gdb/symtab] Fix data race in index_cache::enable
Date: Wed, 2 Aug 2023 12:40:32 +0200 [thread overview]
Message-ID: <13aec698-1c68-567d-5412-38b7dad24d65@suse.de> (raw)
In-Reply-To: <43fcfbd2-115e-8458-8808-acdee98a2c83@polymtl.ca>
On 7/28/23 20:27, Simon Marchi wrote:
Hi Simon,
thanks for the review.
>> The race is between:
>> - the main thread setting index_cache::m_enabled
>> (due to command "set index-cache enabled on")
>> - a worker thread reading index_cache::m_enabled to determine whether an
>> index-cache entry for $exec needs to be written
>> (due to command "file $exec")
>>
>> Fix this by capturing the value of index_cache::m_enabled during the file
>> command.
> For completeness: in 30392, I initially suggested making m_enabled an
> std::atomic. To which you responded:
>
> By making it a std::atomic<bool>, we make this non-determinism
> defined behaviour, so tsan stops complaining, but we want
> deterministic behaviour instead.
>
> I agree with that. Capturing the value at the time of the command makes
> sense.
>
Ack, thanks for making that explicit.
> One comment on the implementation. Do we really need to save an
> index_cache_store_context object in cooked_index? Could we:
>
> - make get_store_context return it by value
> - std::move it to the thread (or just copy it, if it's not expected to
> be large) into the worker thread's closure (in
> cooked_index::start_writing_index)
> - pass it down by const-ref to whatever needs it
I've implemented this approach in v2 (
https://sourceware.org/pipermail/gdb-patches/2023-August/201273.html ).
I also realized that get_store_context is basically a constructor, so
I've remodeled things in this way as well.
Thanks,
- Tom
next prev parent reply other threads:[~2023-08-02 10:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 8:56 [RFC 0/3] [gdb/symtab] Fix data-races in gdb.base/index-cache.exp Tom de Vries
2023-07-28 8:56 ` [RFC 1/3] [gdb/symtab] Fix data race in index_cache::enable Tom de Vries
2023-07-28 18:27 ` Simon Marchi
2023-08-02 10:40 ` Tom de Vries [this message]
2023-07-28 8:56 ` [RFC 2/3] [gdb/symtab] Fix data race in bfd_open_file Tom de Vries
2023-07-28 8:56 ` [RFC 3/3] [gdb/symtab] Fix race on per_cu->queued Tom de Vries
2023-08-02 10:34 ` [RFC 0/3] [gdb/symtab] Fix data-races in gdb.base/index-cache.exp 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=13aec698-1c68-567d-5412-38b7dad24d65@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).