From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 83B613858C50 for ; Fri, 4 Aug 2023 00:08:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83B613858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BAD471F74D; Fri, 4 Aug 2023 00:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691107699; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GJIOpGq5RAR0X/gPla8AmC55vfHGV1yqItNPVXLs6HA=; b=oE/l1+3wErCuSt+SUrn5C0obO9jqvfwruJpawjJAmkxwepcc/MZBa+AfPHBPrQqNoqeerp smU5iVkO1DKjAdA2lI1tQUJHLAbVqhO9RZ+gJi2AfZGY4jBfRJFKqcMb8oGI+Rv58SrGtc BaCl0OV2s1JWLD37p9kPdLXZiPB8jYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691107699; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GJIOpGq5RAR0X/gPla8AmC55vfHGV1yqItNPVXLs6HA=; b=Xm+iVpjbiTJJeSt+/K8etizyDZkaRalD0zDlrZp9phDTt6TD/co08r2Gzqy/PUNUFVS4O2 F0MXpZv4lhKgR7Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A7E43134B0; Fri, 4 Aug 2023 00:08:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iTrLJ3NBzGSbLgAAMHmgww (envelope-from ); Fri, 04 Aug 2023 00:08:19 +0000 Message-ID: <079ff325-8cec-7df7-0efc-e458aacda534@suse.de> Date: Fri, 4 Aug 2023 02:08:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/6] [gdb/symtab] Fix data race on index_cache::m_enabled To: Tom Tromey , Tom de Vries via Gdb-patches References: <20230802095305.3668-1-tdevries@suse.de> <20230802095305.3668-2-tdevries@suse.de> <87v8dxdyzm.fsf@tromey.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <87v8dxdyzm.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 8/2/23 21:29, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> With gdb build with -fsanitize=thread and test-case gdb.base/index-cache.exp I > Tom> run into: > [race] > > Tom> Fix this by capturing the value of index_cache::m_enabled in the main thread, > Tom> and using the captured value in the worker thread. > > Thanks for the patch. I have some stylistic nits but otherwise it seems > fine to me. > > Tom> + struct index_cache_store_context ctx (global_index_cache); > > I think we tend to avoid the struct/class keyword in cases like this now. > > Tom> + const struct index_cache_store_context &ctx) > > ... basically everywhere. > > Tom> +index_cache_store_context::index_cache_store_context (const index_cache &ic) > Tom> +{ > Tom> + m_enabled = ic.enabled (); > > It's better to use the initializer syntax like > > : m_enabled (ic.enabled ()) > > This can be in the header if possible (I didn't try). > > Tom> +struct index_cache_store_context > Tom> +{ > Tom> + friend class index_cache; > Tom> + > Tom> + index_cache_store_context(const index_cache &ic); > > Single-argument constructors should be 'explicit' as a rule. Ack, fixed in a v3 version ( https://sourceware.org/pipermail/gdb-patches/2023-August/201339.html ). Thanks, - Tom