From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@lucon.org (H.J. Lu) To: hjl@sea.lucon.org (hjl) Cc: oliva@dcc.unicamp.br, matthew@ooc.com, jbuck@synopsys.com, egcs@cygnus.com, support@ooc.com Subject: A bad EH bug Date: Fri, 30 Oct 1998 19:14:00 -0000 Message-id: References: X-SW-Source: 1998-10/msg01295.html > > > > > On Tue, Oct 13, 1998 at 02:48:36PM -0700, Joe Buck wrote: > > > > >> Please send a complete test case (a complete program) to > > >> egcs-bugs@cygnus.com, so that the experts will be able to run it through > > >> and figure out what goes wrong. > > > > > This demonstrates the problem quite effectively. However, I'm afraid > > > it's rather big. I had a (quick) crack at isolating the problem with > > > little success. > > # gcc bad.cc -g # a.out Foo::Foo Foo::~Foo zsh: 12158 segmentation fault ./a.out # gdb a.out (gdb) r (gdb) r Starting program: /home/hjl/bugs/g++/opt.3/a.out Foo::Foo Foo::~Foo Program received signal SIGSEGV, Segmentation fault. 0x804a2b1 in __cp_pop_exception (p=0x4002fbaa) at /home/work/misc/gnu/src/egcs-1.1/gcc/cp/exception.cc:211 211 --p->handlers; (gdb) bt #0 0x804a2b1 in __cp_pop_exception (p=0x4002fbaa) at /home/work/misc/gnu/src/egcs-1.1/gcc/cp/exception.cc:211 #1 0x804947e in Base::dispatch (this=0xbffffc17, x=0) at bad.cc:80 #2 0x80494e9 in main () at bad.cc:101 BTW, it failed on Solaris/Sparc. But it works on HP-UX 10.20. It seems it affects all platforms with DWARF2 based EH. FYI, egcs 1.0.3 is ok. It must be a new bug. I'd like to see it be fixed in egcs 1.1.1. Could someone please clean it up and put it into the g++ testsuite? Thanks. -- H.J. Lu (hjl@gnu.org) --- #include class Base { public: int dispatch (int); }; class Derived : public Base { }; class Foo { public: Foo (); ~Foo (); int getValue (int); }; template class OBObjVar { T* ptr; public: OBObjVar (T *p) : ptr (p) {} ~OBObjVar() { delete ptr; } T* operator->() const { return ptr; } }; Foo * getFoo (); Foo::Foo () { printf ("Foo::Foo\n"); } Foo::~Foo () { printf ("Foo::~Foo\n"); } int Foo::getValue (int x) { return x; } Foo* getFoo () { return new Foo; } int Base::dispatch (int x) { int y = 1; while (y) { OBObjVar f = getFoo (); try { y = f->getValue (x); } catch (const char *s) { printf ("Base::dispatch: %s\n", s); if (x == 0) { y = 0; continue; } throw; } catch (int) { continue; } if (y == 0) { f->getValue (y); throw "Throw an exception!"; } break; } return y; } int main () { Derived x; try { x.dispatch (0); } catch (const char *s) { printf ("Caught: %s\n", s); } }