public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* runtime_error and derived classes cause core dump on Solaris
@ 2005-09-22 19:18 Morten Boysen
  0 siblings, 0 replies; only message in thread
From: Morten Boysen @ 2005-09-22 19:18 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-09-22 19:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 19:18 runtime_error and derived classes cause core dump on Solaris Morten Boysen

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).