When Address Sanitizer is enabled, the Open Dialog Box cannot be shown. It hangs forever. Thank you.
It hangs when running hr = pFileOpen->Show(NULL);
#include <windows.h>
#include <shobjidl.h>
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED |
COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
IFileOpenDialog* pFileOpen;
// Create the FileOpenDialog object.
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
if (SUCCEEDED(hr))
{
// Show the Open dialog box.
hr = pFileOpen->Show(NULL);
pFileOpen->Release();
}
CoUninitialize();
}
return 0;
}
Partial workaround for older VS:
To make this occur less often, add SetProcessAffinityMask(GetCurrentProcess(), 1);
at the beginning of your program. This seem to fix completely Open Dialog case, but doesn't fix more complex occurrences. (Be sure not to keep this workaround for normal program runs, as it effectively disables running on multiple CPU cores)