It is possible that a function called directly or indirectly by the constructor monitor violates its exception specification and does not allow std::bad_exception . If you have not replaced the standard function to catch this, then this will explain the behavior that you see.
To test this hypothesis, you can try defining your own handler:
void my_unexpected() { std::cerr << "Bad things have happened!\n"; std::terminate(); } bool PyMonitor::connect() { std::set_unexpected( my_unexpected ); try { _monitor = new Monitor(_host, _calibration); } catch (...) { printf("oops!\n"); } }
If you get "Bad Things!" error message, then you have confirmed that this is so, but unfortunately, there may not be so many that you can do. If you're lucky, you can throw an exception from my_unexpected , which is allowed by the function exception specification, which currently fails, but in any case, your unexpected handler cannot end normally. He must quit or otherwise terminate.
To fix this, you really need to enter the called code and either fix it so that the exception is not violated, either by fixing the specification itself, or by fixing the code so that it does not throw an exception that is expected.
Another possibility is that when unpacking the stack, an exception is thrown due to the creation of the original exception. This will also lead to termination of the process. In this case, although you can replace the standard termination function, you have no option but to interrupt the program. The completion handler is not allowed to throw or return, it must interrupt the program.
source share