From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id E47703954C74 for ; Wed, 16 Nov 2022 07:05:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E47703954C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x333.google.com with SMTP id r9-20020a1c4409000000b003cfdd569507so877442wma.4 for ; Tue, 15 Nov 2022 23:05:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ej9i57mjgLVTOJDxXfjW7Ue+1p8yrNh7wRIaBVDRdkA=; b=ETqbYgdzp3Q1/soOrKZiizaCIGcncE5ORdhuZsk5KqG+6RkRhvZITVqZVVP3f+/iIi rkd3+WNPH1QVEB2xWYHXiZNvKgqQ6cDWtHh4yQJLUy8k7xj2ECZ+vNSuBENfMyp7B01d ufoHRlI/6E8N5jgMhNfJVqWt+KQany/8oa2tbGtzugi9+GWJzMYg9NfacOLqj4GnZ4m9 hrGa5Hh3PJN7bVMpIJVAPV+CNbRi7A1Z2SzLX1+FuAgN5Y4B9jgKEv97Hsilxh0w3GH1 MTRldInLTs7dtdj+QSXJsW8uc8V3gh6iaAraMh28bkll2K3CHRzt1jM7UPD4mPSVevkA /C/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ej9i57mjgLVTOJDxXfjW7Ue+1p8yrNh7wRIaBVDRdkA=; b=L9yBcDsdIsqJXzv6rNLT/UeqwOFrypllWkah9FT6hmdfXSzOPm4oZFIgb2u8h9wL/t sCBgfkFgbaQwMN7oWKfhxsYxKryUw8Gilt4vIO0ZopP4JIxPLirXWExVbVQh0+W1/6CX csKQFV/1UATAdneCbK7SvVkv2SoMhafQ6ddfVdhxkLF60fNR03IYjp5bKkAJd0b5ub0Y afy5TKhYKJpzMseZcgxQbJSdPcR/ALS6OZJ8x2j+Z+sOc2eFBDSAJ2AktPxdIQhPtPvr Im0ruEdS6TTFceAdhaCtDysLakyZUQ91ydzkUiy2VxBXu6BcjV/uVSZyl+KBqPSxCi89 UCxw== X-Gm-Message-State: ANoB5pnhEpmp0++eXbJlW/YWXWQYMHhFi/X/wauAAII9M0duLFWwmQLm lyhW5uLfnYcwU+ME7DMgxpqDl9LsSbTefQ== X-Google-Smtp-Source: AA0mqf4l7trTJzT4MHqROvWmjcNRWj5XgRbJoGsLlUMshbwbtNvE7vrCJxJQgY7Nz5nRE4vbqgdgdw== X-Received: by 2002:a05:600c:12ca:b0:3cf:98e8:3e48 with SMTP id v10-20020a05600c12ca00b003cf98e83e48mr1129371wmd.56.1668582313379; Tue, 15 Nov 2022 23:05:13 -0800 (PST) Received: from legouguec-Precision-7550 ([2a01:e0a:253:fe0:71fb:5d18:40e3:39da]) by smtp.gmail.com with ESMTPSA id o24-20020a5d58d8000000b00236695ff94fsm14092713wrf.34.2022.11.15.23.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 23:05:12 -0800 (PST) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Simon Marchi Cc: Tom Tromey , Simon Marchi via Gdb-patches Subject: Re: [PATCH] Guard against frame.c destructors running before frame-info.c's In-Reply-To: <9994be80-c436-32ee-f6a3-174858683054@polymtl.ca> (Simon Marchi's message of "Tue, 15 Nov 2022 20:19:22 -0500") References: <20221115204821.1260141-1-legouguec@adacore.com> <4065164f-f473-1c9d-7b24-2420b00f47a3@polymtl.ca> <87v8nfbtix.fsf@tromey.com> <9994be80-c436-32ee-f6a3-174858683054@polymtl.ca> Date: Wed, 16 Nov 2022 08:05:11 +0100 Message-ID: <87k03vv0pk.fsf@adacore.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: --=-=-= Content-Type: text/plain Simon Marchi writes: > Thanks, this reproduces for me too. The patch looks good to me: > > Approved-By: Simon Marchi Thanks! Trailer appended in the attached. I think I'll need help to install this; it's my first patch for GDB AFAIR, so I don't believe I have push rights yet. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Guard-against-frame.c-destructors-running-before-fra.patch >From af4c192fd2d598836aa208d88035aa0dab5aa89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Tue, 15 Nov 2022 16:08:04 +0100 Subject: [PATCH] Guard against frame.c destructors running before frame-info.c's 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_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 Approved-By: Simon Marchi --- 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 --=-=-=--