public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit 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 19:43:09 +0000	[thread overview]
Message-ID: <bug-30413-4717-RwXPjiT2Kc@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 #12 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=751c7c72c0105c7d55e58bba3c069c36a74c8937

commit 751c7c72c0105c7d55e58bba3c069c36a74c8937
Author: Tom de Vries <tdevries@suse.de>
Date:   Wed May 3 21:43:03 2023 +0200

    [gdb/build] Fix frame_list position in frame.c

    In commit 995a34b1772 ("Guard against frame.c destructors running before
    frame-info.c's") the following problem was addressed.

    The frame_info_ptr destructor:
    ...
      ~frame_info_ptr ()
      {
        frame_list.erase (frame_list.iterator_to (*this));
      }
    ...
    uses frame_list, which is a static member of class frame_info_ptr,
    instantiated in frame-info.c:
    ...
    intrusive_list<frame_info_ptr> frame_info_ptr::frame_list;
    ...

    Then there's a static frame_info_pointer variable named selected_frame in
    frame.c:
    ...
    static frame_info_ptr selected_frame;
    ...

    Because the destructor of selected_frame uses frame_list, its destructor
needs
    to be called before the destructor of frame_list.

    But because they're in different compilation units, the initialization
order and
    consequently destruction order is not guarantueed.

    The commit fixed this by handling the case that the destructor of
frame_list
    is called first, adding a check on is_linked ():
    ...
       ~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));
       }
    ...

    However, since then frame_list has been moved into frame.c, and
    initialization/destruction order is guarantueed inside a compilation unit.

    Revert aforementioned commit, and fix the destruction order problem by
moving
    frame_list before selected_frame.

    Reverting the commit is another way of fixing the already fixed
    Wdangling-pointer warning reported in PR build/30413, in a different way
than
    commit 9b0ccb1ebae ("Pass const frame_info_ptr reference for
    skip_[language_]trampoline").

    Approved-By: Simon Marchi <simon.marchi@efficios.com>
    Tested on x86_64-linux.
    PR build/30413
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30413

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-05-03 19:43 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
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 [this message]
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-RwXPjiT2Kc@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: link
Be 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).