How can linking a static library break C++ exception handling?

453 Views Asked by At

I had a recent problem where a thrown C++ exception was not caught and instead leads to program termination.

My current MWE is:

#include <stdexcept>
#include <cupti.h>
void foo(){
  CUpti_SubscriberHandle subscriber;
  cuptiSubscribe(&subscriber, (CUpti_CallbackFunc) 0, 0);
}
int main(){
  try{
    throw std::runtime_error("Hello");
  }catch(...){
  }
}

Compiling with g++ testRaise.cpp /sw/installed/CUDAcore/11.1.1/extras/CUPTI/lib64/libcupti_static.a -ldl -lpthread -lrt and running leads to terminate called after throwing an instance of 'std::runtime_error' which I can't explain.

What I found so far ("works"="exception is caught"):

As CUPTI is proprietary I don't know how that was build, but I fail to see how linking a static library can break the C++ exception handling/unwinding mechanism

Does anyone know, what could cause this, how it can be checked/verified and avoided?

0

There are 0 best solutions below