From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] Add lock_guard to thread_pool::thread_count
Date: Thu, 19 Mar 2026 15:52:32 -0700 [thread overview]
Message-ID: <20260319155232.766f6cc1@f42-zbm-amd> (raw)
In-Reply-To: <20260312224604.1070829-1-tom@tromey.com>
On Thu, 12 Mar 2026 16:46:04 -0600
Tom Tromey <tom@tromey.com> wrote:
> I think there's a possible race when calling thread_pool::thread_count
> from a worker thread, if the main thread changes the number of threads
> at the same time.
>
> When this code was initially written, we didn't worry about this,
> because this was only accessed from the main thread. This is no
> longer the case, though.
>
> This patch fixes any potential problem by adding a lock_guard to the
> method. This doesn't seem too harmful because this is not called very
> much and because I doubt this lock is highly contended.
>
> While doing this I noticed that thread_pool::do_post_task could access
> m_sized_at_least_once and m_thread_count without holding the lock.
> This patch changes this method as well.
LGTM.
Approved-by: Kevin Buettner <kevinb@redhat.com>
prev parent reply other threads:[~2026-03-19 22:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 22:46 Tom Tromey
2026-03-19 22:52 ` Kevin Buettner [this message]
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=20260319155232.766f6cc1@f42-zbm-amd \
--to=kevinb@redhat.com \
--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