]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/testsuite/ChangeLog
c++/24367: Infinite recursion of typedef substitution
authorKeith Seitz <keiths@redhat.com>
Thu, 25 Apr 2019 20:05:51 +0000 (13:05 -0700)
committerKeith Seitz <keiths@redhat.com>
Thu, 25 Apr 2019 20:06:52 +0000 (13:06 -0700)
commit725cbb63263d27e87f5a4f9b73281e7710de53e4
tree60962bd09743ddf401e082ceee91b5688d319a61
parent3d1cbb78936fbf2985ffd2ebf074841599ead788
c++/24367: Infinite recursion of typedef substitution

This bug finds another usage where we end up segfaulting while
normalizing user input.  inspect_type and replace_type recurse,
attempting to substitute the "real" symbol name for the typedef name.
However, since the both these names are the same, they keep calling
each other until the stack overflows.

A simple reproducer for it is given by

  typedef struct foo foo;
  int qux (foo *f) { return 0; }

  (gdb) b qux(foo*)
  Segmentation fault

inspect_type already contains some special handling to prevent a
similar situation from occurring with namespaces.  I wonder, however,
whether we need be so pedantic about the exact nature of the substitution.

This patch implements this rather more aggressive assumption that these
substitutions should be avoided whenever the replacement symbol's name is
exactly the same as the one we're trying to substitute.  [In the above
example, we're trying to substitute the tyepdef named "foo" with the symbol
named "foo" (a struct).]

gdb/ChangeLog:

PR c++/24367
* cp-support.c (inspect_type): Don't attempt substitutions
of symbol with the same name.

gdb/testsuite/ChangeLog:

PR c++/24367
* gdb.cp/meth-typedefs.cc (incomplete_struct)
(another_incomplete_struct, test_incomplete): New definitions.
(main): Use new definitions.
* gdb.cp/meth-typedefs.exp: Add new tests for `test_incomplete'
functions.
gdb/ChangeLog
gdb/cp-support.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/meth-typedefs.cc
gdb/testsuite/gdb.cp/meth-typedefs.exp