This is the mail archive of the
mailing list for the GCC project.
Throwing exception in constructor causes segfault
- From: Craig Rodrigues <rodrigc at attbi dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 23 Feb 2002 15:00:23 -0500
- Subject: Throwing exception in constructor causes segfault
The following testcase was submitted in PR 5757:
X *p = new X;
If this example is run, a segfault occurs.
The backtrace of the segfault is:
#0 operator delete(void*) (ptr=0x804aa34) at del_opv.cc:36
#1 0x08048963 in main () at t.cpp:20
#2 0x401202ae in __libc_start_main (main=0x8048890 <main>, argc=1,
ubp_av=0xbffff754, init=0x8048670 <_init>, fini=0x8048a50 <_fini>,
rtld_fini=0x4000cf28 <_dl_fini>, stack_end=0xbffff74c)
I don't know how this stuff works, but I am guessing
that for some reason, during the stack unwinding, the
destructor is being called on *p, even though it
is not fully constructed, and this is causing problems.
Does anyone have any ideas about this?