Subject: toolchain/24837: gcc C++ exceptions cause core dumps.
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <rkr@olib.org>
List: netbsd-bugs
Date: 03/18/2004 05:07:42
>Number:         24837
>Category:       toolchain
>Synopsis:       gcc C++ exceptions cause core dumps.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 18 05:08:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Richard Rauch
>Release:        NetBSD/amd64, NetBSD/i386 (circa 20040312)
>Organization:
n/a
>Environment:
NetBSD socrates 1.6ZK NetBSD 1.6ZK (socrates) #7: Fri Mar 12 16:25:52 CST 2004  root@socrates:/usr/netbsd/current/src/sys/arch/amd64/compile/obj.amd64/socrates amd64

>Description:
When trying to use a C++ program with exceptions on a recent NetBSD
-current system (both AMD64 and i386), instead of getting an exception
caught, I get a core dump.

On AMD, the corefile just has one address (unlabeled) in the backtrace.

On i386, a more useful backtrace is seen, showing __start, etc., and may
be more helpful.

(Aside: Does this indicate a deeper problem with AMD64 and backtraces?
Should I file a separate PR?)
>How-To-Repeat:
#include <iostream> 
using namespace std;

void foo (void)
{
    throw "Catch me if you can.";
}

int main (ijnt argc, char **argv)
{
    try
    {
        foo ();
    }
    catch (const char *msg)
    {
        cout << msg;
    }
    return 0;
}
>Fix:
None known.

However, Krister Walfrid confirms this problem on his system, and
suggests:

WORKAROUND: Compile with "-static".
>Release-Note:
>Audit-Trail:
>Unformatted: