- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.070Thanks in advance!
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any chance you could come up with a small runnable test case that illustrates the problem?
Thanks!
Dale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your original case, does it work as you expect when you compile with Microsoft's compiler?
Dale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So you see similar behavior with the Microsoft compiler as with the Intel compiler?
Dale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When "throw 1" ... in intel compiler it jump to the default catch statment and in vsc++ compiler, the whole application crashes.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, that's it! :)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page