.NET 4.5:.NET 运行时中的内部错误 (80131506)/禁用并发 GC [英] .NET 4.5: internal error in the .NET Runtime (80131506) / disabling concurrent GC

查看:81
本文介绍了.NET 4.5:.NET 运行时中的内部错误 (80131506)/禁用并发 GC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个长时间运行的 .NET 4.5 应用程序随机崩溃,并在事件日志的问题标题中留下了我提到的消息.该问题在 3 台不同的机器和 2 个不同的系统(2008 R2 和 2012)上重现.应用程序不使用任何不安全/非托管的组件,它是纯托管的 .NET,唯一非托管的是 CLR 本身.

I have a long-running .NET 4.5 application that crashes randomly, leaving the message I've mentioned in the question title in the event log. The issue is reproduced on 3 different machines and 2 different systems (2008 R2 and 2012). Application doesn't use any unsafe/unmanaged components, it's pure managed .NET, with the only unmanaged thing being the CLR itself.

这是我从转储中提取的崩溃站点的堆栈跟踪:

Here's the stack trace of the crash site that I've extracted from the dump:

clr.dll!MethodTable::GetCanonicalMethodTable()  
clr.dll!SVR::CFinalize::ScanForFinalization()  - 0x1a31b bytes  
clr.dll!SVR::gc_heap::mark_phase()  + 0x328 bytes   
clr.dll!SVR::gc_heap::gc1()  + 0x95 bytes   
clr.dll!SVR::gc_heap::garbage_collect()  + 0x16e bytes  
clr.dll!SVR::gc_heap::gc_thread_function()  + 0x3e bytes    
clr.dll!SVR::gc_heap::gc_thread_stub()  + 0x77 bytes    
kernel32.dll!BaseThreadInitThunk()  + 0x1a bytes    
ntdll.dll!RtlUserThreadStart()  + 0x21 bytes    

此问题与此处讨论的问题非常相似,所以我尝试了该主题中建议的解决方案,但都没有帮助:

This issue closely resembles the one that was discussed here, so I tried the solutions suggested in that topic, but none of them helped:

  • 我试过安装 这个 修补程序,但它不会安装在我的任何机器上(KB2640103 不适用,或者被您计算机上的其他条件阻止),这实际上是有道理的,因为我使用的是 4.5,而不是 4.0.

  • I've tried installing this hotfix, but it won't install on any of my machines (KB2640103 does not apply, or is blocked by another condition on your computer), which actually makes sense, because I'm using 4.5, not 4.0.

我尝试过禁用并发 GC 和/或启用服务器 GC.现在我的 app.config 的相关部分如下所示:

I've tried disabling concurrent GC and/or enabling server GC. Right now the relevant part of my app.config looks like this:

<?xml version="1.0"?>
<configuration>        
    <runtime>
        <gcConcurrent enabled="false"/>
        <gcServer enabled="true" />
    </runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>    </startup></configuration>

虽然奇怪的是我仍然在进程转储中找到多个与 GC 相关的线程.除了发生崩溃的那个,还有 7 个线程具有以下堆栈跟踪:

Though the weird thing is I still find multiple GC-related threads in the process dump. Besides the one the crash occurs in, there are 7 threads with the following stack trace:

ntdll.dll!NtWaitForSingleObject()  + 0xa bytes  
KERNELBASE.dll!WaitForSingleObjectEx()  + 0x9a bytes    
clr.dll!CLREventBase::WaitEx()  + 0x13f bytes   
clr.dll!CLREventBase::WaitEx()  + 0xf7 bytes    
clr.dll!CLREventBase::WaitEx()  + 0x78 bytes    
clr.dll!SVR::t_join::join()  + 0xd8 bytes   
clr.dll!SVR::gc_heap::scan_dependent_handles()  + 0x65 bytes    
clr.dll!SVR::gc_heap::mark_phase()  + 0x347 bytes   
clr.dll!SVR::gc_heap::gc1()  + 0x95 bytes   
clr.dll!SVR::gc_heap::garbage_collect()  + 0x16e bytes  
clr.dll!SVR::gc_heap::gc_thread_function()  + 0x3e bytes    
clr.dll!SVR::gc_heap::gc_thread_stub()  + 0x77 bytes    
kernel32.dll!BaseThreadInitThunk()  + 0x1a bytes    
ntdll.dll!RtlUserThreadStart()  + 0x21 bytes    

这让我想知道我是否能以某种方式搞砸禁用并发 GC(这就是我实际列出的配置).

Which makes me wondering if I could somehow screw up disabling the concurrent GC (that's what I actually listed the config for).

我认为到目前为止我已经找到了.我真的可以使用一些帮助来处理这个问题.

I think that wraps up what I've managed to find so far. I could really use some help on how to proceed with dealing with this issue.

推荐答案

我借鉴了我过去在我们的应用程序中的经验.如果异常在 Finalizer 级别之前未得到处理,则可能会导致这种情况,如果它发生......它将使应用程序崩溃.

I am drawing from my past experience in our application. This could be caused if an exception goes unhandled till the Finalizer level, and if it goes... it will crash the application.

在对 GC 配置做任何事情之前..

Before doing anything on the GC configuration..

快速检查... 您是否在使用任务并行库?.如果是,请确保您正确处理异常.如果来自不同线程的异常没有得到处理,它会一直运行到 Finalizer,然后使应用程序崩溃.有几种方法可以巧妙地处理它们.处理聚合"异常是一种方法(我们曾经解决过!).

One quick check... Are you using task parallel libraries?. If yes make sure you are handling exceptions properly. If exceptions from different threads are left unhandled it goes till Finalizer which then crashes the application. There are couple of ways to handle them neatly. Handling 'Aggregate' Exception is one way (that we used to solve!).

http://msdn.microsoft.com/en-us/library/dd537614.aspx

我没有 50 分来添加评论,所以将其添加为答案...

这篇关于.NET 4.5:.NET 运行时中的内部错误 (80131506)/禁用并发 GC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆