This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

runtime_error and derived classes cause core dump on Solaris


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]