public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug build/30413] [gdb/build] error: storing the address of local variable ‘<anonymous>’ in ‘frame_info_ptr::frame_list.intrusive_list<frame_info_ptr>::m_back’ [-Werror=dangling-pointer=] Date: Wed, 03 May 2023 10:49:39 +0000 [thread overview] Message-ID: <bug-30413-4717-Norgdg5NjS@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30413-4717@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30413 --- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> --- I think the thing the warning complains about is that adding to the list is unconditional, and removing from the list is conditional (on is_linked), and the compiler can't figure out that for the temporary object is_linked () == true. [ You could reason that the warning is too aggressive, but that may be intentional, I'm not sure. ] The test on is_linked was introduced because of trying to accommodate the scenario mentioned in the comment: ... ~frame_info_ptr () { /* 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)); } ... So perhaps we can fix this by removing the is_linked test. The code was added because the static frame_list and the static frame_info_ptr where in different compilation units, but that's no longer the case. So I'm thinking of: ... diff --git a/gdb/frame.c b/gdb/frame.c index 36fb02f3c8e..c47244b8cb2 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1733,6 +1733,11 @@ get_current_frame (void) static frame_id selected_frame_id = null_frame_id; static int selected_frame_level = -1; +/* See frame-info-ptr.h. This definition should come before any definition of + a static frame_info_ptr. */ + +intrusive_list<frame_info_ptr> frame_info_ptr::frame_list; + /* The cached frame_info object pointing to the selected frame. Looked up on demand by get_selected_frame. */ static frame_info_ptr selected_frame; @@ -3275,10 +3280,6 @@ maintenance_print_frame_id (const char *args, int from_tty) /* See frame-info-ptr.h. */ -intrusive_list<frame_info_ptr> frame_info_ptr::frame_list; - -/* See frame-info-ptr.h. */ - frame_info_ptr::frame_info_ptr (struct frame_info *ptr) : m_ptr (ptr) { diff --git a/gdb/frame.h b/gdb/frame.h index 6ed8db0af56..fff5c248070 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -257,8 +257,8 @@ class frame_info_ptr : public intrusive_list_node<frame_info_ptr> /* 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)); + gdb_assert (is_linked ()); + frame_list.erase (frame_list.iterator_to (*this)); } frame_info_ptr &operator= (const frame_info_ptr &other) ... -- You are receiving this mail because: You are on the CC list for the bug.
next prev parent reply other threads:[~2023-05-03 10:49 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-02 16:57 [Bug build/30413] New: " vries at gcc dot gnu.org 2023-05-02 16:59 ` [Bug build/30413] " vries at gcc dot gnu.org 2023-05-02 20:48 ` tromey at sourceware dot org 2023-05-02 20:52 ` mark at klomp dot org 2023-05-02 20:54 ` mark at klomp dot org 2023-05-03 10:07 ` vries at gcc dot gnu.org 2023-05-03 10:49 ` vries at gcc dot gnu.org [this message] 2023-05-03 10:49 ` vries at gcc dot gnu.org 2023-05-03 13:56 ` simon.marchi at polymtl dot ca 2023-05-03 15:11 ` cvs-commit at gcc dot gnu.org 2023-05-03 15:43 ` mark at klomp dot org 2023-05-03 16:40 ` vries at gcc dot gnu.org 2023-05-03 16:53 ` simon.marchi at polymtl dot ca 2023-05-03 18:00 ` vries at gcc dot gnu.org 2023-05-03 19:43 ` cvs-commit at gcc dot gnu.org 2023-05-03 19:56 ` vries at gcc dot gnu.org 2023-05-03 20:15 ` vries at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-30413-4717-Norgdg5NjS@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=gdb-prs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).