From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4BE62385740C; Thu, 14 Jul 2022 07:07:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4BE62385740C From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug gdb/29311] [gdb] ThreadSanitizer: data race (/lib64/libtsan.so.2+0x4c5e2) in free Date: Thu, 14 Jul 2022 07:07:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2022 07:07:22 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D29311 --- Comment #6 from Tom de Vries --- (In reply to Tom de Vries from comment #4) > (In reply to Tom de Vries from comment #3) > > (In reply to Tom de Vries from comment #2) > > > So, is this a problem with=20 > > order of destroying things? > >=20 > > First the threads need to be destroyed, before objects that may have be= en > > used by those threads? >=20 > Hmm, in a way it could be. >=20 > There's a static vector, which is written by the main thread at > initialization time, then read by various threads, and destroyed upon exit > by the main thread. >=20 > We don't wait on pending tasks before exit, so some of those could still = be > running and accessing the vector, or rather, what it points to. >=20 > This stops us from xfreeing the strings contained in the vector: > ... > diff --git a/gdb/charset.c b/gdb/charset.c > index 74f742e0aa7..e9d28fcb1b1 100644 > --- a/gdb/charset.c > +++ b/gdb/charset.c > @@ -694,7 +694,7 @@ struct charset_vector > { > ~charset_vector () > { > - clear (); > + charsets.clear (); > } >=20=20 > void clear () > ... > and that fixes the race condition from comment 2. https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;h=3D4f92e10cda1= 42fd1f213e01a53ca687e38cddf22 --=20 You are receiving this mail because: You are on the CC list for the bug.=