3

In my application, I found a core dump happening in an old 3rd party library for which there is no support provided. I don't want my application to restart because of this and I wrapped the code inside a try..catch block in order to catch the exception if a core dump happens inside that library.

Something like this

try {
  //call to thirdparty library
} catch (...) {
  //print the exception and return  
}

Is it guaranteed to catch exception if core happens? Is there any possibility that library don't throw any exception and my application restarts in case of core?

4
  • 3
    core dumps aren't necessarily caused by exceptions, so no. Jul 31, 2015 at 5:31
  • 3
    Core dumps are not C++ exceptions. An uncaught exception might result in a core dump, but a number of other things might result in a core dump too. For example an invalid memory access might. However, that's not a C++ exception and any C++ exception handler that catches an invalid memory access crash is a language extension. Jul 31, 2015 at 5:33
  • 1
    Also note that the fault could be caused by some wrong or unexpected inputs you pass to that library. I would wrap the function calls and put assertions checking all the parameters first. Jul 31, 2015 at 6:18
  • 3
    You need to wrap the library in its own process and communicate with that process from your own. Otherwise, the library can still, for example, dereference an invalid pointer and crash. You can also try experimenting to figure out if you can use the library in such a way that you don't trigger the crash. Sep 9, 2015 at 19:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.