mimalloc: Application using redirection to mimalloc crashes on Windows 11 when opening a file dialog
A minimal program was created to reproduce the issue (look code sniped below). The program opens a file dialog using GetOpenFileName. The crash occurs right after the file dialog displays.
On Windows 10, the program runs successfully both with and without the mimalloc. On Windows 11, the program crashes when the mimalloc allocator is used. Callstack is attached.
Windows 11 Home single language Version 21H2 OS Build 22000.348 Windows Feature Experience Pack 1000.22000.348.0
Shell32.dll ver. 10.0.22000.348 ucrtbase.dll ver. 10.0.22000.1 ucrtbased.dll ver. 10.0.19041.685
Visual Studio 2022 ver. 17.0.2 MSVC ver. 143 x86/x64 14.30.30705 Windows SDK 10.0.19041.0
#include <windows.h>
#include <Commdlg.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
OPENFILENAME ofn;
char szFile[500];
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFile = szFile;
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
GetOpenFileName(&ofn);
MessageBox(NULL, ofn.lpstrFile, "File Name", MB_OK);
return 0;
}
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 25
Commits related to this issue
- update redirection dll's for windows 11 (issue #498) — committed to microsoft/mimalloc by daanx 2 years ago
Yes! I was able to contact the right people and they fixed the bugs (already quite a while ago). I am not sure if the fixes are already in some Windows update – have you tried if it works yet?
@daanx @vlserov To me this looks like a bug in shell32.dll since it uses HeapFree directly, and because it also occurs with oneTBB (i.e. it is not exclusive to mimalloc). More details here: https://github.com/oneapi-src/oneTBB/issues/665