-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application using scalable allocator crashes on Windows 11 when opening a file dialog #665
Comments
@myoung301 can you provide more details :
|
compiler: Visual Studio 2017 (15.0.0) Call stack from windbg:
|
@zheltovs could you please take a look? |
@myoung301, we were not able to reproduce the issue at the moment. |
@myoung301, we are able to reproduce the issue with your steps and got same call stack. |
Hi, could you please share some more details regarding the reproduction? We received a crash dump from a customer showing the exact same call stack, but I failed to reproduce the issue so far. What I tried: I compiled the example code above on Windows 10 (not 11) using Visual Studio 2019, Windows SDK 10.0.19041.0, C++14, Release, cl.exe 19.29.30137. The scalable allocator of oneTBB comes from revision 4eec89f. It seems some specific Windows setting or software is required to trigger the problem? |
We have customer reports of crashes showing the same stack trace. However, we use mimalloc as a custom allocator instead of oneTBBs. So the issue does not seem specific to oneTBB, but is more a general windows issue. However we also failed to reproduce the crashes on our dev machines or local VMs. I agree with @Sedeniono assessment that there must be some specific setting or software (probably containing explorer items) that triggers the crash. |
I and a colleague both confirmed that if we sign out of OneDrive, the crash goes away. We have to be careful to fully sign out (the 'Unlink this PC' option in settings). We've also reproduced the problem with mimalloc, as mentioned. So there is an issue when using either custom allocator and OneDrive on Windows 11. |
@myoung301 @vlserov I can confirm that the example posted above crashes both with oneTBB and mimalloc if OneDrive is syncing the Desktop. By that I mean OneDrive's option to backup the Desktop. Note that if you enable this option, the Desktop folder itself gets moved under the OneDrive folder. After some more debugging, I can confirm that one ingredient of the crash is indeed the registry path I mentioned above. More precisely, one requirement for the crash to occur is that the SID-key ("S-1-5-21-...") under I tested it with versions 10.0.22000.282 and 10.0.22000.348 of the shell32.dll and the Windows.FileExplorer.Common.dll files, and in both versions the FileOpen-Dialog crashes. In short, I think it is a bug in shell32.dll, where memory is allocated via a redirected malloc but then free'd directly (bypassing mimalloc/oneTBB); maybe someone can confirm this. More details below. One workaround is to ensure that the Desktop is not located under the OneDrive folder, or any other synced folder that is mentioned in the More details: The following image shows the first relevant part of Notice that it first gets the path to the Desktop ( If this is the case, the second virtual function call Now, back in So, I think we have a Microsoft bug in shell32.dll: Memory is freed not via an ordinary (and thus redirected) |
for MS folks, http://task.ms/38281009 |
@ChrisGuzak Am I interpreting your post correctly that the shell32.dll team at Microsoft is now aware of the issue? Otherwise, what does your link point to? |
@ChrisGuzak Is this article meant to be access by non MS people? Or can we get access to it? |
@ChrisGuzak what is the status on this? |
So MSFT appears to have fixed this issue with KB5020044 (preview) or KB5021255 (stable). The release notes for KB5020044 has this bullet point:
Our preliminary testing does suggest the crash we experienced on Windows 11 with the Open File dialog box has gone away with this Windows update. Digging into the Windows binaries (thanks @Sedeniono for his deep dive), previously (Windows 11 build 22000) CStorageProviderInfo::GetIconOverlayHandlerClsidArray allocates memory using operator new[](size_t, std::nothrow_t)
which is then freed with HeapFree in shell32.dll via operator delete. In Windows 11 build 22621, CStorageProviderInfo::GetIconOverlayHandlerClsidArray now calls a helper function CopyClsidsToCoTaskMemAlloc
which in turn calls CoTaskMemAlloc to allocate memory.
Instead of operator delete/HeapFree, this memory is then freed in shell32.dll by The use of CoTaskMem* effectively work arounds the malloc/HeapFree debacle. Regarding the use of HeapFree to free a malloc allocated pointer as seen in Windows 11 build 22000, I tend to believe this is not actually a MSFT bug. Instead, I think link-time optimisation is to blame here. My hunch is that shell32.dll is built as part of the same project as ntdll.dll, which is how the body of malloc (which just calls RtlAllocateHeap with GetProcessHeap) got inlined into shell32.dll's operator new. |
@myoung301 is this issue still relevant? |
@nofuturre - sorry, I can not confirm. I am no longer using the version of Windows that was problematic. |
If anyone encounter with this issue in future please open new issue with a link to this one |
A minimal program was created to reproduce the issue. The program opens a file dialog using GetOpenFileName.
On Windows 10, the program runs successfully both with and without the TBB scalable allocator.
On Windows 11, the program crashes when the scalable allocator is used. The crash occurs right after the file dialog displays. The application runs successfully with the scalable allocator removed.
The TBB allocator was enabled using the linker option:
The code:
The text was updated successfully, but these errors were encountered: