I'm facing an unknown exception thrown after I call the new
operator.
The new
operator is called after a long processing time (10h) to store output results. This code is implemented in a DLL that is loaded from a C# application running in .Net 4.5.
I created a MWE with the code below put into a for loop, but it throws an std::bad_alloc
as expected, while the real code throws unknown exception and falls to the catch(...)
statement.
Note that I am using Visual Studio 2013.
This is the code:
try {
char* output = new char[50000000];
} catch (const std::bad_alloc&) {
// Doesn't happen
printf("Bad Alloc\n");
} catch (const std::exception&) {
// Doesn't happen
printf("Standard Exception\n");
} catch (...) {
// Code falls here
printf("Unknown Exception\n");
}
If no one has a solution for this, can you at least please give ideas for debugging it? I've thought about using Windows API calls to check memory state before calling the new
operator, but I need more ideas.
What are all types of exceptions MSVC can throw upon operator new
and what can I do to retrieve information from those?