From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23751 invoked by alias); 23 Feb 2002 19:59:04 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 23616 invoked from network); 23 Feb 2002 19:58:59 -0000 Received: from unknown (HELO dibbler.ne.mediaone.net) (24.218.57.139) by sources.redhat.com with SMTP; 23 Feb 2002 19:58:59 -0000 Received: (from rodrigc@localhost) by dibbler.ne.mediaone.net (8.11.0/8.11.0) id g1NK0No03708; Sat, 23 Feb 2002 15:00:23 -0500 Date: Sat, 23 Feb 2002 12:56:00 -0000 From: Craig Rodrigues To: libstdc++@gcc.gnu.org Cc: gcc@gcc.gnu.org Subject: Throwing exception in constructor causes segfault Message-ID: <20020223150023.A3639@attbi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-SW-Source: 2002-02/txt/msg01384.txt.bz2 Hi, The following testcase was submitted in PR 5757: class X { public: X () { throw ""; } ~X () { } }; int main () { try { X *p = new X[4]; delete[]p; } catch (...) { } return 0; } 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
, argc=1, ubp_av=0xbffff754, init=0x8048670 <_init>, fini=0x8048a50 <_fini>, rtld_fini=0x4000cf28 <_dl_fini>, stack_end=0xbffff74c) at ../sysdeps/generic/libc-start.c:129 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? Thanks. -- Craig Rodrigues http://www.gis.net/~craigr rodrigc@attbi.com