From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uwfCA1J+vGncyzAAWB0awg (envelope-from ) for ; Thu, 19 Mar 2026 18:53:06 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JrFCH4++; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E2E5A1E0BC; Thu, 19 Mar 2026 18:53:05 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8CC461E08C for ; Thu, 19 Mar 2026 18:53:05 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E70664B9DB4B for ; Thu, 19 Mar 2026 22:53:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E70664B9DB4B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JrFCH4++ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 8E9134B9DB4B for ; Thu, 19 Mar 2026 22:52:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8E9134B9DB4B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8E9134B9DB4B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773960759; cv=none; b=cmB1mXQ7BAWmiWyHaZAR6MvWsgrHSPnnIdbJa+itu8/NDYJ6XiTWltpr72FRKU8qO+C8nndWLdmPyGxGPdBkChXQGWzAurQch6FaV4DFpDoSv+nNfpyl6If57SSMATcIwMnffQ0ByWabZ0HBd892PLo22/xebeM+k1FqxeC+fPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1773960759; c=relaxed/simple; bh=8pLrSdz5EHJR/R+Iz7i3pZ8t3I4CPKWEimbBh9N+LIU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=VvNqf1olvHIW6GIDc24bfJTeHRWdDRZMOec88tjURK0LOvwkf80WafxITWu8l8XZ+9bYUZ8OCReIJPT/Al9iz20FFF2o7uUTJltvHI0o1ibTDpBLuFTkE8Da3Xlz3kR3aJoo2DBbb0fF5VlVPTCLyTuIbyL5KqCJGzcsxJXIVzU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E9134B9DB4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773960759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pr5CUf8PPChH+AJnZSQ8s1Clc9xnSU/xqEVlbKaj+mc=; b=JrFCH4++McU7bD7FeQn5bPCWPu8HteOR+Oeq9aO26B+FDJMagBniunql5AERLghg+IVr2p kULRvvtCuGVKVfErRXRoakectuPg7rqmL4jy5440OCghTiXEM3nhSbdlNV7rE6ZoAeed6z V7Eq2GEleurSLxspb73qCMtm66ixFPE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-PPciPWpQOeKAjVRKSSKONQ-1; Thu, 19 Mar 2026 18:52:37 -0400 X-MC-Unique: PPciPWpQOeKAjVRKSSKONQ-1 X-Mimecast-MFC-AGG-ID: PPciPWpQOeKAjVRKSSKONQ_1773960756 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2CCFE195609F; Thu, 19 Mar 2026 22:52:36 +0000 (UTC) Received: from f42-zbm-amd (unknown [10.22.88.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52D561955F21; Thu, 19 Mar 2026 22:52:35 +0000 (UTC) Date: Thu, 19 Mar 2026 15:52:32 -0700 From: Kevin Buettner To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: Re: [PATCH] Add lock_guard to thread_pool::thread_count Message-ID: <20260319155232.766f6cc1@f42-zbm-amd> In-Reply-To: <20260312224604.1070829-1-tom@tromey.com> References: <20260312224604.1070829-1-tom@tromey.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 2iqiBd58wyDpcGmTCFMBk5oN7QAwCQ8kCv5gG_lZRtI_1773960756 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Thu, 12 Mar 2026 16:46:04 -0600 Tom Tromey 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