Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.

Exception problem

aurora_s
Beginner
332 Views
Hi,
Im having problems with exception propagation through dll boundaries.
In my main function I've implemented a try/catch statment with a catch(int a) and the default catch(...).
Inside the try, I call another function that is imported from a shared library, but when an exception is raised there (say "throw 1"), the try/catch of the main function doesnt see the type of the exception, and uses the default catch.
If I do the same thing but without crossing the dll boundaries, all is OK.
I've checked that the runtime library is the same (/MDd) in both places.
Version: 11.1.070
Thanks in advance!
0 Kudos
8 Replies
Dale_S_Intel
Employee
332 Views
Any chance you could come up with a small runnable test case that illustrates the problem?
Thanks!

Dale
aurora_s
Beginner
332 Views
I've already done a "small runnable test case", but it works fine, so I want to know if there is any typical newbie-user issue with this. The schema looks like this:
-----------------------------------------------------
//The .exe imports a .lib with another function
extern "C++"{
int main(){
try{
f();
} catch(int asdf){
.....
}catch(...)
{
..... //It always use this catch
}
}
}
------------------------------------------------------
//In the dll
....
extern "C++"{
int f(){
throw 1;
}
}
-------------------------------------------------------
Thanks!
Dale_S_Intel
Employee
332 Views
In your original case, does it work as you expect when you compile with Microsoft's compiler?
Dale
aurora_s
Beginner
332 Views
With the vsc compiler, it crashes when I do "throw 1" with the message:

"Unhandled exception at 0x6165934c (msvcp90d.dll) in HP_import.exe: 0xC0000005: Access violation reading location 0xffffffffffffffff."
Dale_S_Intel
Employee
332 Views
So you see similar behavior with the Microsoft compiler as with the Intel compiler?
Dale
aurora_s
Beginner
332 Views
When "throw 1" ... in intel compiler it jump to the default catch statment and in vsc++ compiler, the whole application crashes.
Thanks!
Dale_S_Intel
Employee
332 Views
Ah, so just to be clear, the desired behavior is that the throw 1 in the callee (which passes through one or more dll boundaries) should be caught by the catch in main, not the default handler. If I understand correctly, that's what happens with no dll's involved, but across dll's, the icl built binary will catch in the default handler, while the MS built binary will crash, i.e. not catch it anywhere?
aurora_s
Beginner
332 Views
Yes, that's it! :)
Reply