I have a function in which I call getaddrinfo()
to get an sockaddr*
which targets memory is allocated by the system.
As many may know, you need to call
catch(int& X) { std::cout << "caught a X" << std::endl; }
That doesn't catch an X
, it catches an int&
. Since there is no matching catch block, the exception is uncaught, stack unwinding doesn't occur, and __finally
handlers don't run.
You can put catch (...)
in your thread entrypoint (which is main()
for the primary thread) in order to make sure that stack unwinding occurs, although some exceptions are unrecoverable, that's never true of a C++ exception.