From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/1] Fix GDB crash due to infinite recursion in typedef substitution
Date: Thu, 28 May 2020 14:37:23 +0100 [thread overview]
Message-ID: <20200528133724.24634-1-palves@redhat.com> (raw)
This fixes the bug exposed by the "gdb: Remove C++ symbol aliases from
completion list" commit. See here for the original investigation and
discussions:
https://sourceware.org/pipermail/gdb-patches/2020-May/168972.html
In a nutshell, the bug is that if you do
(gdb) b gdb::option::bool[TAB]
while debugging GDB itself, then the top GDB crashes with infinite
recursion within the replace_typedefs machinery.
The bug was exposed with completion because when doing completion, GDB
now calls cp_canonicalize_string_no_typedefs for every symbol that
matches. However, the recursion bug is also reproducible if you just
set a breakpoint at any of the "bad" symbols too without completion.
I.e., "b $bad_symbol[ENTER]".
The log in the commit itself is described in terms of the added
testcase, not of the GDB internals.
In GDB's case, the recursion happens when you set a breakpoint in a
symbol that includes a templated named boolean_option_def:
gdb::option::boolean_option_def<filename_partial_match_opts>::....
because we have typedefs named boolean_option_def in the global
namespace in the program. Here, in stack.c for example:
using boolean_option_def
= gdb::option::boolean_option_def<frame_print_options>;
Pedro Alves (1):
replace_typedefs: handle templates in namespaces
gdb/cp-support.c | 71 +++++++++++-
.../cp-replace-typedefs-ns-template.cc | 116 +++++++++++++++++++
.../cp-replace-typedefs-ns-template.exp | 127 +++++++++++++++++++++
3 files changed, 310 insertions(+), 4 deletions(-)
create mode 100644 gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.cc
create mode 100644 gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
base-commit: 636edd0018b72d67ee224e868fb277a658e9b984
--
2.14.5
next reply other threads:[~2020-05-28 13:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 13:37 Pedro Alves [this message]
2020-05-28 13:37 ` [PATCH 1/1] replace_typedefs: handle templates in namespaces Pedro Alves
2020-05-28 22:13 ` Keith Seitz
2020-05-30 15:34 ` Pedro Alves
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=20200528133724.24634-1-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@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).