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 python/28856] Python pretty printer causes stack overflow when printing frame arguments
Date: Mon, 10 Oct 2022 10:14:04 +0000	[thread overview]
Message-ID: <bug-28856-4717-ml3XxoZWkC@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28856-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28856

--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Bruno Larsen <blarsen@sourceware.org>:

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

commit c29a6445a981cee5e8eebe3617ef5c049fd3409f
Author: Bruno Larsen <blarsen@redhat.com>
Date:   Mon Jul 25 14:06:37 2022 -0300

    gdb/frame: Add reinflation method for frame_info_ptr

    Currently, despite having a smart pointer for frame_infos, GDB may
    attempt to use an invalidated frame_info_ptr, which would cause internal
    errors to happen.  One such example has been documented as PR
    python/28856, that happened when printing frame arguments calls an
    inferior function.

    To avoid failures, the smart wrapper was changed to also cache the frame
    id, so the pointer can be reinflated later.  For this to work, the
    frame-id stuff had to be moved to their own .h file, which is included
    by frame-info.h.

    Frame_id caching is done explicitly using the prepare_reinflate method.
    Caching is done manually so that only the pointers that need to be saved
    will be, and reinflating has to be done manually using the reinflate
    method because the get method and the -> operator must not change
    the internals of the class.  Finally, attempting to reinflate when the
    pointer is being invalidated causes the following assertion errors:

    check_ptrace_stopped_lwp_gone: assertion `lp->stopped` failed.
    get_frame_pc: Assertion `frame->next != NULL` failed.

    As for performance concerns, my personal testing with `time make
    chec-perf GDB_PERFTEST_MODE=run` showed an actual reduction of around
    10% of time running.

    This commit also adds a testcase that exercises the python/28856 bug with
    7 different triggers, run, continue, step, backtrace, finish, up and down.
    Some of them can seem to be testing the same thing twice, but since this
    test relies on stale pointers, there is always a chance that GDB got lucky
    when testing, so better to test extra.

    Regression tested on x86_64, using both gcc and clang.

    Approved-by: Tom Tomey <tom@tromey.com>

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

  parent reply	other threads:[~2022-10-10 10:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03 11:45 [Bug python/28856] New: " jwakely.gcc at gmail dot com
2022-02-03 11:46 ` [Bug python/28856] " jwakely.gcc at gmail dot com
2022-02-03 11:49 ` jwakely.gcc at gmail dot com
2022-02-03 12:02 ` fweimer at redhat dot com
2022-02-03 19:01 ` ssbssa at sourceware dot org
2022-02-03 20:50 ` jwakely.gcc at gmail dot com
2022-02-03 21:15 ` ssbssa at sourceware dot org
2022-02-03 21:29 ` simark at simark dot ca
2022-02-03 22:19 ` jwakely.gcc at gmail dot com
2022-02-07 17:51 ` blarsen at redhat dot com
2022-03-21 13:23 ` cvs-commit at gcc dot gnu.org
2022-03-24 14:28 ` simon.marchi at polymtl dot ca
2022-10-10 10:14 ` cvs-commit at gcc dot gnu.org [this message]
2022-10-10 10:23 ` blarsen at redhat dot com
2023-08-03 15:59 ` tromey at sourceware dot org
2024-01-13 18:50 ` ssbssa at sourceware dot 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-28856-4717-ml3XxoZWkC@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).