-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Area-COM-APIIssue related to COM APIIssue related to COM APIIssue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.
Description
Relevant area(s)
WinGet CLI, COM API
Relevant command(s)
No response
Brief description of your issue
This is #5869, just without calling CoUninitialize - which replaces the access violation with a C++ exception due to attempting to launch a thread during process exit.
Steps to reproduce
I tried this code (complete project attached):
int main()
{
winrt::check_hresult(CoInitializeEx(nullptr, COINIT_MULTITHREADED));
// const struct Cleanup { ~Cleanup() { CoUninitialize(); } } cleanup; -- intentionally commented out
const auto packageManager{ CreateWinGetInstance<winget::PackageManager>(CLSID_PackageManager) };
auto catalog = packageManager.GetPackageCatalogByName(L"winget");
winrt::check_hresult(catalog.Connect().ExtendedErrorCode());
return 0;
}Expected behavior
It works.
Actual behavior
It crashes as it's trying to launch a thread during process exit.
# ChildEBP RetAddr
00 00d6f04c 62c92811 ucrtbased!issue_debug_notification+0x30 [minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp @ 28]
01 00d6f064 62ca513a ucrtbased!__acrt_report_runtime_error+0x11 [minkernel\crts\ucrt\src\appcrt\internal\report_runtime_error.cpp @ 154]
02 00d6f074 62ca459d ucrtbased!abort+0x1a [minkernel\crts\ucrt\src\appcrt\startup\abort.cpp @ 51]
03 00d6f0ac 62d4662e ucrtbased!terminate+0x7d [minkernel\crts\ucrt\src\appcrt\misc\terminate.cpp @ 59]
04 00d6f138 62d46b6f ucrtbased!FindHandler<__FrameHandler3>+0x42e [VCCRT\vcruntime\src\eh\frame.cpp @ 783]
05 00d6f178 62d46bbb ucrtbased!__InternalCxxFrameHandler<__FrameHandler3>+0x1af [VCCRT\vcruntime\src\eh\frame.cpp @ 396]
06 00d6f1a0 62d4552c ucrtbased!__InternalCxxFrameHandlerWrapper<__FrameHandler3>+0x2b [VCCRT\vcruntime\src\eh\frame.cpp @ 252]
07 00d6f1dc 771a4522 ucrtbased!__CxxFrameHandler3+0x2c [VCCRT\vcruntime\src\eh\i386\trnsctrl.cpp @ 217]
08 00d6f200 771a44f4 ntdll!ExecuteHandler2+0x26
09 00d6f2c8 7716b66f ntdll!ExecuteHandler+0x24
0a 00d6f2c8 765d5004 ntdll!KiUserExceptionDispatcher+0xf
0b 00d6f7f4 72a94977 KERNELBASE!RaiseException+0x64
0c 00d6f828 713a5a94 VCRUNTIME140!_CxxThrowException+0x67 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\throw.cpp @ 79]
0d 00d6f850 622739ec MSVCP140!std::_Throw_Cpp_error+0x34 [D:\a\_work\1\s\src\vctools\crt\github\stl\src\thread0.cpp @ 33]
0e (Inline) -------- WindowsPackageManager!std::thread::_Start+0x1ae [c:\program files\microsoft visual studio\2022\enterprise\VC\Tools\MSVC\14.44.35207\include\thread @ 85]
0f (Inline) -------- WindowsPackageManager!std::thread::{ctor}+0x1ae [c:\program files\microsoft visual studio\2022\enterprise\VC\Tools\MSVC\14.44.35207\include\thread @ 93]
10 00d6f954 62274423 WindowsPackageManager!AppInstaller::ShutdownMonitoring::TerminationSignalHandler::TerminationSignalHandler+0x41c [C:\__w\1\s\external\pkg\src\AppInstallerCLICore\ShutdownMonitoring.cpp @ 91]
11 (Inline) -------- WindowsPackageManager!std::_Construct_in_place+0x26 [c:\program files\microsoft visual studio\2022\enterprise\VC\Tools\MSVC\14.44.35207\include\xutility @ 476]
12 (Inline) -------- WindowsPackageManager!std::_Ref_count_obj2<AppInstaller::ShutdownMonitoring::TerminationSignalHandler>::{ctor}+0x2c [c:\program files\microsoft visual studio\2022\enterprise\VC\Tools\MSVC\14.44.35207\include\memory @ 2100]
13 (Inline) -------- WindowsPackageManager!std::make_shared+0x48 [c:\program files\microsoft visual studio\2022\enterprise\VC\Tools\MSVC\14.44.35207\include\memory @ 2913]
14 (Inline) -------- WindowsPackageManager!winrt::impl::create_and_initialize+0x8b [C:\__w\1\b\x86\Release\AppInstallerCLICore\Generated Files\winrt\base.h @ 7965]
15 (Inline) -------- WindowsPackageManager!winrt::make_self+0x8b [C:\__w\1\b\x86\Release\AppInstallerCLICore\Generated Files\winrt\base.h @ 8082]
16 00d6f99c 6227489d WindowsPackageManager!AppInstaller::WinRT::COMStaticStorageBase<AppInstaller::ShutdownMonitoring::TerminationSignalHandler>::Get+0x133 [C:\__w\1\s\external\pkg\src\AppInstallerSharedLib\Public\winget\COMStaticStorage.h @ 65]
17 00d6f9c8 6252d700 WindowsPackageManager!AppInstaller::ShutdownMonitoring::TerminationSignalHandler::Instance+0x4d [C:\__w\1\s\external\pkg\src\AppInstallerCLICore\ShutdownMonitoring.cpp @ 22]
18 (Inline) -------- WindowsPackageManager!AppInstaller::ShutdownMonitoring::ServerShutdownSynchronization::{dtor}+0x19 [C:\__w\1\s\external\pkg\src\AppInstallerCLICore\ShutdownMonitoring.cpp @ 340]
19 00d6f9f0 75319234 WindowsPackageManager!`AppInstaller::ShutdownMonitoring::ServerShutdownSynchronization::Instance'::`2'::`dynamic atexit destructor for 's_instance''+0x40
1a 00d6fa2c 75319151 ucrtbase!<lambda_f03950bc5685219e0bcd2087efbe011e>::operator()+0x8b
1b 00d6fa60 75319112 ucrtbase!__crt_seh_guarded_call<int>::operator()<<lambda_69a2805e680e0e292e8ba93315fe43a8>,<lambda_f03950bc5685219e0bcd2087efbe011e> &,<lambda_03fcd07e894ec930e3f35da366ca99d6> >+0x2e
1c 00d6fa9c 620fbcc8 ucrtbase!_execute_onexit_table+0x32
1d 00d6faa4 620fc112 WindowsPackageManager!__scrt_dllmain_uninitialize_c+0x13 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\utility\utility.cpp @ 398]
1e 00d6fadc 620fbfbe WindowsPackageManager!dllmain_crt_process_detach+0x45 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 182]
1f 00d6fae8 620fc23b WindowsPackageManager!dllmain_crt_dispatch+0x4e [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 226]
20 00d6fb28 620fc2dc WindowsPackageManager!dllmain_dispatch+0xb7 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 293]
21 00d6fb3c 77168ff6 WindowsPackageManager!_DllMainCRTStartup+0x1c [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp @ 334]
22 00d6fb5c 771a0df3 ntdll!LdrxCallInitRoutine+0x16
23 00d6fb80 7712b11c ntdll!LdrpCallInitRoutineInternal+0x22
24 00d6fbc8 77127259 ntdll!LdrpCallInitRoutine+0xae
25 00d6fc68 771240fc ntdll!LdrShutdownProcess+0x199
26 00d6fd38 7698b112 ntdll!RtlExitUserProcess+0x17c
27 00d6fd4c 62caa464 KERNEL32!ExitProcessImplementation+0x12
28 00d6fd58 62caa40e ucrtbased!exit_or_terminate_process+0x34 [minkernel\crts\ucrt\src\appcrt\startup\exit.cpp @ 142]
29 00d6fd90 62caa6d2 ucrtbased!common_exit+0x9e [minkernel\crts\ucrt\src\appcrt\startup\exit.cpp @ 288]
2a 00d6fda4 00faa232 ucrtbased!exit+0x12 [minkernel\crts\ucrt\src\appcrt\startup\exit.cpp @ 301]
2b 00d6fe04 00faa0ad WinGetBugTest!__scrt_common_main_seh+0x172 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 295]
2c 00d6fe0c 00faa458 WinGetBugTest!__scrt_common_main+0xd [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 331]
2d 00d6fe14 76975d49 WinGetBugTest!mainCRTStartup+0x8 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp @ 17]
2e 00d6fe24 7715d6db KERNEL32!BaseThreadInitThunk+0x19
2f 00d6fe7c 7715d661 ntdll!__RtlUserThreadStart+0x2b
30 00d6fe8c 00000000 ntdll!_RtlUserThreadStart+0x1b
Environment
WinGet 1.12.350 from NuGet.Metadata
Metadata
Assignees
Labels
Area-COM-APIIssue related to COM APIIssue related to COM APIIssue-BugIt either shouldn't be doing this or needs an investigation.It either shouldn't be doing this or needs an investigation.