I tried to make a "Stack overflow" exception.
This code throws an exception on x64 Debug.
void DumpSystem::makeStackOverflow()
{
static int callCount = 0;
++callCount;
makeStackOverflow();
}
But, This code don't throws an exception on x64 Release The x64 Release xxx.exe was LOOP without causing a "Stack Overflow" exception.
Build Option : "SEH(/EHa)"
I want to create a "Dump File" using "SetUnhandledExceptionFilter".
This is the code I used
LONG saveDumpfile(EXCEPTION_POINTERS* ex);
unsigned __stdcall saveDumpFileForStackOverflow(void* arg)
{
EXCEPTION_POINTERS* ex = static_cast<EXCEPTION_POINTERS*>(arg);
return saveDumpfile(ex);
}
LONG exceptionHandling(EXCEPTION_POINTERS* ex)
{
if (ex &&
ex->ExceptionRecord &&
ex->ExceptionRecord->ExceptionCode == EXCEPTION_STACK_OVERFLOW)
{
HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0,
saveDumpFileForStackOverflow, ex, NULL, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
return EXCEPTION_EXECUTE_HANDLER;
}
return saveDumpfile(ex);
}
void registrationDumpSystem()
{
::SetUnhandledExceptionFilter(exceptionHandling);
}
LONG saveDumpfile(EXCEPTION_POINTERS* ex)
{
if (ex == NULL)
return EXCEPTION_EXECUTE_HANDLER;
LONG result = EXCEPTION_EXECUTE_HANDLER;
//%APPDATA% : C:\Users\[user name]\AppData\Roaming
wstring filePath = getAppDataFolderPath();
SHCreateDirectoryEx(NULL, filePath.c_str(), NULL);
filePath.append(TEXT("\\Dump.dmp"));
HANDLE file = CreateFile(filePath.c_str(),
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (file == INVALID_HANDLE_VALUE)
{
DWORD lerr = GetLastError();
return lerr;
}
HANDLE processHandle = GetCurrentProcess();
DWORD processId = GetCurrentProcessId();
MINIDUMP_EXCEPTION_INFORMATION mei;
mei.ThreadId = GetCurrentThreadId();
mei.ExceptionPointers = ex;
mei.ClientPointers = false;
MiniDumpWriteDump(processHandle, processId, file,
MiniDumpNormal, &mei, NULL, NULL);
CloseHandle(file);
return result;
}
main.cpp
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
registrationDumpSystem();
//to do
return 0;
}
"x64 Debug exe" it is work. so i can make "dump.dmp" file.
but, "x64 release exe" is't work. i can't make "dump.dmp" file
enter image description here I want to know why the program does not exit on x64 release.
please, could you tell me this reason?