vsgWin32::Win32_Window attempts to destroy its window handle, _window, in its destructor by calling DestroyWindow(_window). However, because vsgWin32::Win32WindowProc (the window message handling CALLBACK) calls DefWindowProc (the default window message handler), when a WM_CLOSE message is received, the window's closed and destroyed before the destructor runs.
This is especially bad because HWNDs are reused for new windows, so the destructor could potentially destroy another process' unrelated window. Thankfully, it's unlikely as Windows actively defends against this kind of bug, using some of a HWND's bits for the window table index and some for a generation number so the same index won't turn into the same HWND when it's reused until those bits have been exhausted.
I used this patch to identify the unwanted window murderer, based on this OldNewThing post: https://devblogs.microsoft.com/oldnewthing/20111026-00/?p=9263
who-killed-my-window.patch
vsgWin32::Win32_Windowattempts to destroy its window handle,_window, in its destructor by callingDestroyWindow(_window). However, becausevsgWin32::Win32WindowProc(the window message handlingCALLBACK) callsDefWindowProc(the default window message handler), when aWM_CLOSEmessage is received, the window's closed and destroyed before the destructor runs.This is especially bad because
HWNDs are reused for new windows, so the destructor could potentially destroy another process' unrelated window. Thankfully, it's unlikely as Windows actively defends against this kind of bug, using some of a HWND's bits for the window table index and some for a generation number so the same index won't turn into the same HWND when it's reused until those bits have been exhausted.I used this patch to identify the unwanted window murderer, based on this OldNewThing post: https://devblogs.microsoft.com/oldnewthing/20111026-00/?p=9263
who-killed-my-window.patch