Subject: toolchain/24837: gcc C++ exceptions cause core dumps.
To: None <>
From: None <>
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
>Originator:     Richard Rauch
>Release:        NetBSD/amd64, NetBSD/i386 (circa 20040312)
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

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?)
#include <iostream> 
using namespace std;

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

int main (ijnt argc, char **argv)
        foo ();
    catch (const char *msg)
        cout << msg;
    return 0;
None known.

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

WORKAROUND: Compile with "-static".