[omniORB] Re: Exception Handling is thread safe?
Sai-Lai Lo
S.Lo@orl.co.uk
Tue, 24 Mar 1998 11:14:24 GMT
1. egcs 1.0.2 or gcc-2.8.1 *does not* have thread safe exceptions.
However, on x86 linux and other platforms that use PC range table to
handle exception. The generated code works most of the time unless you
are so unlucky to have a thread-switch in a small critical region (a few
tens of instructions) *and* the new thread also throws an exception.
The same cannot be said for platforms that use setjmp/longjmp to handle
exception. On these platforms, multithread eh just doesn't work.
2. The current development snapshots *does* have thread safe exceptions.
However, there is a bug in the generated code which causes omniORB2
programs to hang (actually the bug causes it to call a destructor
infinite times).
I did some investigation yesterday and have isolated the problem into a
small test case. The bug has been reported to egcs-bugs. I hope it will
be fixed soon.
The workaround is simple. I could release a patch to omniidl2 to
generate the workaround code. However, I'm reluctant to do so at the
moment because the same compiler bug may hit other parts of the code and
may be much harder to track down.
For those who are interested, the following is the test case that shows
the compiler bug. The bug causes eg3_{impl,clt} to hang.
Sai-Lai
--------------------------------------------
#include <iostream.h>
class B {
public:
B(int v) : pd_v(v) {}
private:
int pd_v;
B();
};
class D {
public:
D() { cerr << "ctor D" << endl; }
~D() { cerr << "dtor D" << endl; }
};
void f()
{
_again:
D tmpvar;
try {
B ex(1);
throw ex;
}
catch (...) {
cerr << "I'm here" << endl;
throw;
}
goto _again;
}
int
main(int argc, char** argv)
{
try {
f();
}
catch (const B& ex) {
cerr << "Got B exception" << endl;
}
return 0;
}
-----------------------------------------------