public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Fix GDB crash due to infinite recursion in typedef substitution
@ 2020-05-28 13:37 Pedro Alves
  2020-05-28 13:37 ` [PATCH 1/1] replace_typedefs: handle templates in namespaces Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2020-05-28 13:37 UTC (permalink / raw)
  To: gdb-patches

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-30 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 13:37 [PATCH 1/1] Fix GDB crash due to infinite recursion in typedef substitution Pedro Alves
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

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).