diff --git a/lldb/test/Shell/Process/Windows/wndproc_exception.cpp b/lldb/test/Shell/Process/Windows/wndproc_exception.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/Process/Windows/wndproc_exception.cpp @@ -0,0 +1,54 @@ +// clang-format off + +// Check that lldb doesn't crash when there's a nested exception. + +// REQUIRES: system-windows +// RUN: %clangxx_host -o %t.exe -luser32 -v -- %s +// RUN: %lldb -f %t.exe -o "run" + +#include + +static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, + LPARAM lParam) { + switch (uMsg) { + case WM_DESTROY: + PostQuitMessage(0); + return 0; + + case WM_PAINT: + *(volatile int *)nullptr = 1; + return 0; + } + return DefWindowProcA(hwnd, uMsg, wParam, lParam); +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, + int nCmdShow) { + const char CLASS_NAME[] = "Crash Window Class"; + + WNDCLASSA wc = {}; + + wc.lpfnWndProc = WindowProc; + wc.hInstance = hInstance; + wc.lpszClassName = CLASS_NAME; + + RegisterClassA(&wc); + + HWND hwnd = CreateWindowExA(0, CLASS_NAME, "Crash", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, + NULL, NULL, hInstance, NULL); + + if (hwnd == NULL) + return 0; + + ShowWindow(hwnd, nCmdShow); + + MSG msg = {}; + while (GetMessageA(&msg, NULL, 0, 0) > 0) { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + return 0; +}