From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 9C542393BA74 for ; Tue, 15 Nov 2022 21:57:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9C542393BA74 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 2AFLvXCw008027 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Nov 2022 16:57:38 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2AFLvXCw008027 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1668549458; bh=Iu+x7m2KYGlvVeEmlAYpSgOxnu5KVMGFvwRJ8kOSg2c=; h=Date:Subject:To:References:From:In-Reply-To:From; b=JZOrVMN0suueb2pDqDZEPap9sb0wiXzcL6kzaSEPbW3rFQLIDdSyO8Z2YpP3nKfbo y0S1OsXijPNSVrR8i3IJT/fqbqhVWFy4xfuZpraevbPY/tfkfwVCkWLn9VumYr9bnw qj6NYvG/xhcHHG1vZUA07prC+2YmdM1QOd/AX+qU= Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 74D0D1E11E; Tue, 15 Nov 2022 16:57:33 -0500 (EST) Message-ID: <4065164f-f473-1c9d-7b24-2420b00f47a3@polymtl.ca> Date: Tue, 15 Nov 2022 16:57:32 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH] Guard against frame.c destructors running before frame-info.c's Content-Language: fr To: =?UTF-8?Q?K=c3=a9vin_Le_Gouguec?= , gdb-patches@sourceware.org References: <20221115204821.1260141-1-legouguec@adacore.com> From: Simon Marchi In-Reply-To: <20221115204821.1260141-1-legouguec@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 15 Nov 2022 21:57:33 +0000 X-Spam-Status: No, score=-3038.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP 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 11/15/22 15:48, Kévin Le Gouguec wrote: > On x86_64-windows, since 04e2ac7b2a7, we observe this internal error: > > [...]/gdbsupport/intrusive_list.h:458: internal-error: erase_element: > Assertion `elem_node->prev != INTRUSIVE_LIST_UNLINKED_VALUE' failed. > > Breaking in the destructors for intrusive_list and frame_info_ptr shows that > in this configuration, the destructors for frame.c's statically-stored > objects are run before frame-info.c's: > > Thread 1 hit Breakpoint 7, intrusive_list intrusive_base_node >::~intrusive_list (this=0x7ff69c418c90 > , __in_chrg=) > [...]/../gdbsupport/intrusive_list.h:250 > 250 clear (); > (gdb) bt > #0 intrusive_list > > ::~intrusive_list (this=0x7ff69c418c90 , > __in_chrg=) [...]/../gdbsupport/intrusive_list.h:250 > #1 0x00007ff69b78edba in __tcf_1 () [...]/frame-info.c:27 > #2 0x00007ff9c457aa9f in msvcrt!_initterm_e () > from C:\Windows\System32\msvcrt.dll > #3 0x00007ff69b8246a6 in captured_main_1 (context=0x5ffe00) > [...]/main.c:1111 > #4 0x00007ff69b825149 in captured_main (data=0x5ffe00) [...]/main.c:1320 > #5 0x00007ff69b8251b1 in gdb_main (args=0x5ffe00) [...]/main.c:1345 > #6 0x00007ff69b5d1730 in main (argc=2, argv=0x751730) [...]/gdb.c:32 > (gdb) c > Continuing. > > Thread 1 hit Breakpoint 8, frame_info_ptr::~frame_info_ptr > (this=0x7ff69c418e20 , __in_chrg=) > [...]/frame-info.h:74 > 74 if (is_linked ()) > (gdb) bt > #0 frame_info_ptr::~frame_info_ptr (this=0x7ff69c418e20 , > __in_chrg=) [...]/frame-info.h:74 > #1 0x00007ff69b79a643 in __tcf_1 () [...]/frame.c:1675 > #2 0x00007ff9c457aa9f in msvcrt!_initterm_e () from > C:\Windows\System32\msvcrt.dll > #3 0x00007ff69b8246a6 in captured_main_1 (context=0x5ffe00) > [...]/main.c:1111 > #4 0x00007ff69b825149 in captured_main (data=0x5ffe00) [...]/main.c:1320 > #5 0x00007ff69b8251b1 in gdb_main (args=0x5ffe00) [...]/main.c:1345 > #6 0x00007ff69b5d1730 in main (argc=2, argv=0x751730) [...]/gdb.c:32 > --- > gdb/frame-info.h | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/frame-info.h b/gdb/frame-info.h > index 3369b114326..893b6632363 100644 > --- a/gdb/frame-info.h > +++ b/gdb/frame-info.h > @@ -76,7 +76,11 @@ class frame_info_ptr : public intrusive_list_node > > ~frame_info_ptr () > { > - frame_list.erase (frame_list.iterator_to (*this)); > + /* If this node has static storage, it may be deleted after > + frame_list. Attempting to erase ourselves would then trigger > + internal errors, so make sure we are still linked first. */ > + if (is_linked ()) > + frame_list.erase (frame_list.iterator_to (*this)); > } > > frame_info_ptr &operator= (const frame_info_ptr &other) > -- > 2.25.1 > Do you have a way to reproduce, so we can experiment with it? Simon