public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Morten Boysen <boysen@snaps.dk>
To: gcc-help@gcc.gnu.org
Subject: runtime_error and derived classes cause core dump on Solaris
Date: Thu, 22 Sep 2005 19:18:00 -0000	[thread overview]
Message-ID: <4333037F.2090302@snaps.dk> (raw)

Hi everyone,

I am experiencing truoble with I throw a runtime_error or any of its 
derived classes in a programme I am writing.

A compressed version of the source looks like this:

file a.cc:

struct record; // Simple type with raw data

class A { // The class from where the exception is thrown.
	vector<record> cache;
}

record A::getRecord()
{
	...
	if (cache.empty())
		throw std::runtime_error("Cache empty");
	...
}

file b.cc

void foo()
{
	A a;
	record r;
	...
	try {
		r = a.getRecord();
	}
	catch (const std::exception &e) {
		// Write a log message calling e.what()
		return;
	}
}

When throwing a runtime_error or a derived class, the programme core 
dumps. The stack trace shows, that the crash happens when calling 
runtime_error::what() (Even if the exception is a derived class). If I 
comment out the call to e.what, the programme crashes in the destructor 
of runtime_error.

If I throw an int or logic_error, everything works fine. I have even 
tried to make a little test-programme, but I cannot reproduce the error.

[mbo@tmchdomestic42 testClient]$ gcc --version
2.95.3

[mbo@tmchdomestic42 testClient]$ uname -a
SunOS tmchdomestic42 5.8 Generic_117350-04 sun4u sparc SUNW,Sun-Fire-V210

P.S. I am not absolutely sure, that we are using the libstdc++ from this 
version of the compiler. Has this problem been seen with another version?






On a different note, a colleague of mine told me of a problem where an 
exception thrown in a function in a different .so file caused a core 
dump, as long as the exception is not thrown in the function that is 
being called directly in the .so file.

It looks a bit like http://gcc.gnu.org/bugzilla/show_bug.cgi?id=8755

Has anyone heard of this problem?


If You need any further information, I will be happy to supply them.

Kind regards
Morten Boysen

                 reply	other threads:[~2005-09-22 19:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4333037F.2090302@snaps.dk \
    --to=boysen@snaps.dk \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).