This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GDB crash due to endless recursion in namespace lookup


since one of this year's C++ namespace search related changes,
GDB will go into an endless recursion and crash due to stack
overflow when looking up symbols in the presence of a cycle
in the "using" directive graph.

For example, with the following test:

namespace A
  namespace B
      using namespace ::A;
  using namespace B;

using namespace A;

class test { };
test x;

int main() { }

I'm seeing:

(gdb) start
Temporary breakpoint 1 at 0x80000626: file, line 16.
Starting program: /home7/uweigand/fsf/gdb-head-build/gdb/a.out

Temporary breakpoint 1, main () at
16      int main() { }
(gdb) print x[0]
Segmentation fault (core dumped)

(The lookup that happens here is for operator[] -- which doesn't
exist, but in trying to find it we run into the endless loop.)

This is particularly annyoing as the SLES10 system library on
s390 and ppc contains exactly this construct in the header

namespace std
  namespace __gnu_cxx_ldbl128
      using namespace ::std;
  using namespace __gnu_cxx_ldbl128 __attribute__((__strong__));

which means it is present in just about every C++ executable.

(This seems specific to the SLES backport of the long-double
compatibility support.  The upstream implementation does not
have this cycle ...  But still, the general construct looks
to be valid C++ as far as I can tell.)

Any thoughts how to fix this?


  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]