--- In [email protected], PingShan Li <[EMAIL PROTECTED]> wrote:
>
> Our project is a C++ project. We use a third party
> library that has a C interface. We do not have access
> to the source code of that third party library. Some
> core files from our project show that the third party
> library has a bug that can cause crash on our project.
>    
> We tried to use try and catch in our project to prevent
> the bug in the third party library from crashing our
> application, but it does not work. I wrote a small
> testing program under Linux/gcc and found out I can
> not catch exception thrown from a DLL with C interface
> in my C++ test program. 

That's one fundamental difference between C and C++: both are compiled
in different object files.

> My question is: what is the best way to handle this
> situation? I want to protect my application from a bug
> in a third party library. Right now, the only solution
> I have is to spawn a child process to use the third
> party library, if the child prcess dies, I can spawn
> a new child process so that my application will keep
> on running.

That's IMO the safest way to go forth.
The only alternative (which is not 100% safe) is to find out under
what exact circumstances the library crashes and avoid these
circumstances when calling it. But this is really not safe.

Regards,
Nico

Reply via email to