.net application is blocked on start hanging in process explorer with 1 MB

2

I have a Windows Forms Application written on C# and it targets .net framework 4.8. I run this application on Windows 7 x86 on the customer's PC. My application works fine but time to time I have a mystic problem with its launch. Sometimes my application just refuse to start but when I open process explorer I see MyAplication.exe which holds 1MB of RAM. It seems that something is blocking my application. I examined windows events log but there are no errors. I also tried to write into the log file on the first line of Program.cs but it simply doesn't happen. I kill this 1 MB process and restart my application. It opens and work just fine or I have to restart it few times. I have experienced this kind of 1 MB RAM problem with my another WPF application and even with .net application from an external vendor. I created a dump file for my application using process explorer. On my personal PC on Windows 10 I used WinDbg application from the Windows Store to analyze dump file of my application. I see the following:

FAULTING_THREAD:  000002a0
PROCESS_NAME:  MyApplication.exe
ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.
EXCEPTION_CODE_STR:  80000003
MISSING_CLR_SYMBOL: 0

STACK_TEXT:  
002be670 77176c04 ntdll!KiFastSystemCallRet+0x0
002be674 771765ac ntdll!NtWaitForSingleObject+0xc
002be678 77161db1 ntdll!RtlpWaitOnCriticalSection+0x13e
002be6dc 77161c95 ntdll!RtlEnterCriticalSection+0x150
002be704 76e5cc0f rpcrt4!PerformRpcInitialization+0x29
002be748 76e665fd rpcrt4!RpcStringBindingComposeW+0x15
002be758 72ab1ec0 DialogFilterProc!InitDialogFilterProc+0x32d
002be810 72ab18b3 DialogFilterProc!ReleaseDialogFilterProc+0x17d
002be828 72ab2157 DialogFilterProc!InitDialogFilterProc+0x5c4
002be844 72ab22be DialogFilterProc!InitDialogFilterProc+0x72b
002be8a4 771887cc ntdll!LdrpCallInitRoutine+0x14
002be8c4 77195adb ntdll!LdrpRunInitializeRoutines+0x26f
002be9b8 7718faf2 ntdll!LdrpLoadDll+0x472
002beb2c 77192105 ntdll!LdrLoadDll+0xaf
002beb64 7523b246 KERNELBASE!LoadLibraryExW+0x215
002bebac 772aefa4 user32!__ClientLoadLibrary+0x60
002bece0 77176b3e ntdll!KiUserCallbackDispatcher+0x2e
002bed7c 772b4f21 user32!NtUserMessageCall+0xc
002bed80 772e5d6e user32!CallNextHookEx+0x10b
002bedb0 6d460ef0 tiptsf!TabletCallWndProc+0x5f
002bedd0 772a7a02 user32!DispatchHookW+0x33
002bedec 772a4999 user32!fnHkINLPCWPSTRUCTW+0x52
002bee20 772ae952 user32!__fnINLPCREATESTRUCT+0x8b
002bee50 77176b3e ntdll!KiUserCallbackDispatcher+0x2e
002beec4 772aeb5c user32!NtUserCreateWindowEx+0xc
002beec8 772aeaf0 user32!VerNtUserCreateWindowEx+0x1a3
002bf16c 772aec1c user32!_CreateWindowEx+0x201
002bf218 772aec77 user32!CreateWindowExW+0x33
002bf254 7682633f ole32!InitMainThreadWnd+0x3e
002bf28c 768263fc ole32!wCoInitializeEx+0xef
002bf2a4 768209ff ole32!CoInitializeEx+0x2ee
002bf2c4 7124ab8f clr!Thread::SetApartment+0x13b
002bf310 7123e1b7 clr!SystemDomain::SetThreadAptState+0x92
002bf330 7123e892 clr!SystemDomain::ExecuteMainMethod+0x18c
002bf810 71242498 clr!ExecuteEXE+0x4c
002bf868 712425be clr!_CorExeMainInternal+0xdc
002bf8a8 7123def5 clr!_CorExeMain+0x4d
002bf8e4 7185fa84 mscoreei!_CorExeMain+0xd6
002bf91c 718e7f16 mscoree!ShellShim__CorExeMain+0x99
002bf92c 718e4de3 mscoree!_CorExeMain_Exported+0x8
002bf934 7616ef3c kernel32!BaseThreadInitThunk+0xe
002bf940 77193618 ntdll!__RtlUserThreadStart+0x70
002bf980 771935eb ntdll!_RtlUserThreadStart+0x1b

SYMBOL_NAME:  DialogFilterProc!InitDialogFilterProc+32d
MODULE_NAME: DialogFilterProc
IMAGE_NAME:  DialogFilterProc.dll

STACK_COMMAND:  .ecxr ; kb ; dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; ** Pseudo Context ** Pseudo ** Value: 88f6c30 ** ; kb

FAILURE_BUCKET_ID:  BREAKPOINT_80000003_DialogFilterProc.dll!InitDialogFilterProc
OSPLATFORM_TYPE:  x86
OSNAME:  Windows 7
IMAGE_VERSION:  1.0.299.0
FAILURE_ID_HASH:  {e56a1c21-26f9-3e25-d015-b9f79339b457}
Followup:     MachineOwner

P.S: I disabled antivirus and windows defender but it didn't solve my problem. I have no internet access on the customer's PC. Not sure if it can have an impact on my problem.

Can anyone help me with this mystic problem? Any ideas are much appreciated!

c#
.net
dump
asked on Stack Overflow Oct 25, 2020 by Anton23

1 Answer

6

Lets read the call stack

clr!_CorExeMain
clr!_CorExeMainInternal

Main Method of managd code reached (SystemDomain::ExecuteMainMethod)

clr!ExecuteEXE
clr!SystemDomain::ExecuteMainMethod
clr!SystemDomain::SetThreadAptState

You most probably have an STAThread Apartment attribute on your Main method because there a COM Appartmentstate is set Thread::SetApartment

clr!Thread::SetApartment

COM initializes (CoInitializeEx)

ole32!CoInitializeEx
ole32!wCoInitializeEx
ole32!InitMainThreadWnd

COM needs a hidden window to pump messages (CreateWindowExW)

user32!CreateWindowExW
user32!_CreateWindowEx
user32!VerNtUserCreateWindowEx
user32!NtUserCreateWindowEx
ntdll!KiUserCallbackDispatcher
user32!__fnINLPCREATESTRUCT
user32!fnHkINLPCWPSTRUCTW
user32!DispatchHookW

Something in this case tiptsf has hooked (DispatchHookW) into window creation to inject its own functionality (TabletCallWndProc). This one is from Microsoft Ink I suspect.

tiptsf!TabletCallWndProc
user32!CallNextHookEx
user32!NtUserMessageCall
ntdll!KiUserCallbackDispatcher
user32!__ClientLoadLibrary

This loads some extension dll

KERNELBASE!LoadLibraryExW
ntdll!LdrLoadDll
ntdll!LdrpLoadDll
ntdll!LdrpRunInitializeRoutines
ntdll!LdrpCallInitRoutine

Now we initialize DialogFilterProc which had problems in Windows 7 around 2012

On my Win10 machine I do not have this DialogFilterProc found. Is this a Windows 7 machine? This one is not documented at all so there is little information what this one tries to do here. According to this it seems to be a System Service which could be disabled, hence the hang.

DialogFilterProc!InitDialogFilterProc
DialogFilterProc!InitDialogFilterProc
DialogFilterProc!ReleaseDialogFilterProc
DialogFilterProc!InitDialogFilterProc

The DialogFilter calls RpcStringBindingComposeW which apparently hangs. From the docs I can see that it deals with inter process communication. Either the COM apartment was not yet fully initialized which cause this RPC method to hang or the remote connection could not be established. See e.g. here for an example where this method is used.

rpcrt4!RpcStringBindingComposeW
rpcrt4!PerformRpcInitialization
ntdll!RtlEnterCriticalSection
ntdll!RtlpWaitOnCriticalSection
ntdll!NtWaitForSingleObject
ntdll!KiFastSystemCallRet

If the first issue is the premature loading of Microsoft Ink you can try to disable it and check if that works around your issue. If the issue persists you can try set on your main method the [STAThread] or [MTAThread] attribute. Perhaps another apartment mode will also resolve your deadlock. Or if that is really the Dialog Filter which tries to call into a service which did crash or was not running then you need to restart the service to make your UI pop up. As I could (hopefully) show you it is pretty easy to find out from any method what it is doing and how it can be turned off. Based on that you should have now plenty of further options to explore either the actual root cause or find a dirty workaround.

Addenum

Your DialogFilterProc.dll has version 1.0.299.0 which seems to be older than the one in the fix from 2012 which has 1.0.542.0. Installing the ancient fix could be the solution to your problem.

> File name File version    File size   Date    Time    Platform
> Dialogfilterproc.dll  1.0.542.0   13,312  24-Jul-12   17:11   x86
answered on Stack Overflow Oct 25, 2020 by Alois Kraus • edited Oct 25, 2020 by Alois Kraus

User contributions licensed under CC BY-SA 3.0