Application crashed with access violation exception (0xC0000005) when exiting

0

The application is a WPF application based on .NET Framework 4.5. It is built in x86 mode, and running on Windows 7 (32bit).

When exiting the application by clicking the close button of the main window, it crashed sometimes.

This is main info analyzed from the dump file.

In XXX.exe.824.dmp the assembly instruction at clr!RCW::EnterContext+18 in C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll from Microsoft Corporation has caused an access violation exception (0xC0000005) when trying to write to memory location 0x00000008 on thread 2

This is the call stack info from the dump file.

  Source                       Arg 1       Arg2        Arg3        Arg4

clr!RCW::EnterContext+18     7e6ec72     3d9ab88     c4e7d31     381f8ac    
clr!RCW::ReleaseAllInterfacesCallBack+41     5745bc0     c4e7d21     381f8ac     17aee40    
clr!RCW::Cleanup+41     3d9ab88     7e6e944     0000000     381f8f0    
clr!RCWCleanupList::ReleaseRCWListRaw+d     0000000     381f8f0     0000000     381f8cc    
clr!RCWCleanupList::ReleaseRCWListInCorrectCtx+d1     0305028     c4e7d91     035a148     0000209    
clr!RCWCleanupList::CleanupAllWrappers+14d     c4e78a9     0000000     02aa860     0000001    
clr!RCWCache::ReleaseWrappersWorker+22d     0000000     c4e78d9     0000000     5e9bccc    
clr!ReleaseRCWsInCaches+59     c4e7b01     0000000     5e9bccc     02a0460    
clr!InnerCoEEShutDownCOM+76     c4e7bd5     7eb1f23     0000000     02a0460    
clr!WKS::GCHeap::FinalizerThreadStart+38a     0000000     0000000     0000000     0000000    
clr!Thread::intermediateThreadProc+4d     02a0460     381ffb0     73537f5     02a0460    
kernel32!BaseThreadInitThunk+e     02a0460     ba58f32     0000000     0000000    
ntdll!__RtlUserThreadStart+70     7f2a8c0     02a0460     0000000     0000000    
ntdll!_RtlUserThreadStart+1b     7f2a8c0     02a0460     0000000     0000000    

Here is another one from WinDbg:

[0x0]   ntdll!KiFastSystemCallRet   
[0x1]   ntdll!NtWaitForMultipleObjects + 0xc   
[0x2]   KERNELBASE!WaitForMultipleObjectsEx + 0x100   
[0x3]   kernel32!WaitForMultipleObjectsExImplementation + 0xe0   
[0x4]   kernel32!WaitForMultipleObjects + 0x18   
[0x5]   kernel32!WerpReportFaultInternal + 0x186   
[0x6]   kernel32!WerpReportFault + 0x70   
[0x7]   kernel32!BasepReportFault + 0x20   
[0x8]   kernel32!UnhandledExceptionFilter + 0x1af   
[0x9]   ntdll!__RtlUserThreadStart + 0x62   
[0xa]   ntdll!_EH4_CallFilterFunc + 0x12   
[0xb]   ntdll!_except_handler4 + 0x8e   
[0xc]   ntdll!ExecuteHandler2 + 0x26   
[0xd]   ntdll!ExecuteHandler + 0x24   
[0xe]   ntdll!RtlDispatchException + 0x127   
[0xf]   ntdll!KiUserExceptionDispatcher + 0xf   
[0x10]   clr!RCW::EnterContext + 0x18   
[0x11]   clr!RCW::ReleaseAllInterfacesCallBack + 0x41   
[0x12]   clr!RCW::Cleanup + 0x41   
[0x13]   clr!RCWCleanupList::ReleaseRCWListRaw + 0xd   
[0x14]   clr!RCWCleanupList::ReleaseRCWListInCorrectCtx + 0xd1   
[0x15]   clr!RCWCleanupList::CleanupAllWrappers + 0x14d   
[0x16]   clr!RCWCache::ReleaseWrappersWorker + 0x22d   
[0x17]   clr!ReleaseRCWsInCaches + 0x59   
[0x18]   clr!InnerCoEEShutDownCOM + 0x76   
[0x19]   clr!WKS::GCHeap::FinalizerThreadStart + 0x38a   
[0x1a]   clr!Thread::intermediateThreadProc + 0x4d   
[0x1b]   kernel32!BaseThreadInitThunk + 0xe   
[0x1c]   ntdll!__RtlUserThreadStart + 0x70   
[0x1d]   ntdll!_RtlUserThreadStart + 0x1b   

I have tried add the following config in the application config file(xxx.exe.config), while none of them takes effect.

    <configuration>
      <runtime>
        <legacyCorruptedStateExceptionsPolicy enabled="true" />
        <gcConcurrent enabled="false" />
      </runtime>  
    </configurtion>

So how to handle or avoid the crash?

c#
.net
crash
clr
rcw
asked on Stack Overflow Apr 6, 2021 by WPInfo • edited Apr 6, 2021 by WPInfo

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0