From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 6A9903858D1E for ; Thu, 14 Jul 2022 18:43:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A9903858D1E 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 9DDF31FB54; Thu, 14 Jul 2022 18:43:32 +0000 (UTC) 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 8899E133A6; Thu, 14 Jul 2022 18:43:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8KU4INRj0GLsFAAAMHmgww (envelope-from ); Thu, 14 Jul 2022 18:43:32 +0000 Message-ID: <1d267cea-387f-f2de-ed72-b6020b80bb4e@suse.de> Date: Thu, 14 Jul 2022 20:43:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [committed][gdb/symtab] Fix data race in ~charset_vector Content-Language: en-US To: Tom Tromey , Tom de Vries via Gdb-patches References: <20220714061923.GA543@delia.home> <87mtdbsirb.fsf@tromey.com> From: Tom de Vries In-Reply-To: <87mtdbsirb.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2022 18:43:34 -0000 On 7/14/22 19:31, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> The problem is that we're freeing the charset_vector elements in the destructor, > Tom> which may still be used by a worker thread. > > Could you say how this happens? > What is the worker thread doing? > As I understand it, the worker thread is executing do_finalize which uses a string (host_charset_name or some such) contained in the charset_vector, which is being destroyed in the main thread. But that's a guess, thread sanitizer didn't report what the worker thread was doing: "[failed to restore the stack]". > Normally I think gdb should be waiting for background tasks to finish > before proceeding with this sort of destruction. If this is coming from > the parallel DWARF reader, maybe we need some higher level API to > cleanly shut down those threads first. Well, the worker threads are detached, so they run until process exit. We can not detach them, and do a join, but that postpones process exit. We could try to do pthread_cancel, but still there might be some waiting involved. This was sofar the only case I found of this type of race, so I thought it reasonable to fix like this. If there are more cases, that might not be practical. Thanks, - Tom