10-17-2024 05:42 AM
How can I force SeqEdit crash to test crash recovery? Crash due to out of memory is not supported in the crash recovery procedure.
10-17-2024 07:11 PM - edited 10-17-2024 07:40 PM
Causing an exception in a non-execution thread that cannot be handled by TestStand, so the following C++ code causes a crash, which I would hope would be caught in the TestStand handler that you want to test:
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include <stdexcept> // For std::runtime_error
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#include <windows.h>
#include <process.h> // For _beginthreadex
// Function that the thread will execute
unsigned __stdcall ThreadFunction(void* param)
{
// Do something here
MessageBox(NULL, L"Thread Function Called!", L"Thread Message", MB_OK);
throw std::runtime_error("Exception from DLL");
return 0;
}
// Function that creates the new thread
extern "C" __declspec(dllexport) void CreateNewThread()
{
// Create a thread that runs ThreadFunction
uintptr_t threadHandle = _beginthreadex(
NULL, // Default security attributes
0, // Default stack size
ThreadFunction, // Pointer to the thread function
NULL, // Thread function parameter
0, // Run immediately after creation
NULL // Optionally receive thread identifier
);
if (threadHandle == 0) {
MessageBox(NULL, L"Failed to create thread", L"Error", MB_OK);
}
else {
// Optionally close the thread handle if not needed
CloseHandle((HANDLE)threadHandle);
}
}