为了调试锁定文件问题,我们从 .NET 进程调用 SysInternal 的 Handle64.exe 4.11(通过具有异步输出重定向的 Process.Start
)。调用进程在 Process.WaitForExit
挂起,因为 Handle64 进程没有退出(超过两个小时)。
我们转储了相应的 Handle64 进程,并在 Visual Studio 2017 调试器中对其进行了检查。它显示了两个线程(“主线程”和“ntdll.dll!TppWorkerThread”)。
主线程的调用栈:
ntdll.dll!NtWaitForSingleObject () Unknown ntdll.dll!LdrpDrainWorkQueue() Unknown ntdll.dll!RtlExitUserProcess() Unknown kernel32.dll!ExitProcessImplementation () Unknown handle64.exe!000000014000664c() Unknown handle64.exe!00000001400082a5() Unknown kernel32.dll!BaseThreadInitThunk () Unknown ntdll.dll!RtlUserThreadStart () Unknown
工作线程的调用栈:
ntdll.dll!NtWaitForSingleObject() Unknown ntdll.dll!LdrpDrainWorkQueue() Unknown ntdll.dll!LdrpInitializeThread() Unknown ntdll.dll!_LdrpInitialize() Unknown ntdll.dll!LdrInitializeThunk() Unknown
我的问题是:为什么进程会在 LdrpDrainWorkQueue
中挂起?来自 https://stackoverflow.com/a/42789684/62838 ,我知道这是 Windows 10 并行加载器在工作,但为什么它会在退出进程时卡住?这可能是由我们如何从另一个进程调用 Handle64 引起的吗?即,我们是在做错什么,还是这是 Handle64 中的错误?
最佳答案
你等了多久?
根据 this analysis ,
The worker thread idle timeout is set to 30 seconds. Programs which execute in less than 30 seconds will appear to hang due to ntdll!TppWorkerThread waiting for the idle timeout before the process terminates.
我建议尝试设置那篇文章中指定的注册表项以禁用并行加载程序,看看这是否解决了问题。
Parent Key: HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\handle64.exe
Value Name: MaxLoaderThreads
Type: DWORD
Value: 1 to disable
关于c++ - 为什么进程会在 RtlExitUserProcess/LdrpDrainWorkQueue 中挂起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52649476/