gpt4 book ai didi

c# - .NET 4.5 : internal error in the . NET 运行时 (80131506)/禁用并发 GC

转载 作者:IT王子 更新时间:2023-10-29 04:31:37 25 4
gpt4 key购买 nike

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

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

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

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

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

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

    <?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 个线程具有以下堆栈跟踪:

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(这就是我实际列出配置的目的)。

我认为这总结了我到目前为止设法找到的内容。我真的需要一些帮助来处理这个问题。

最佳答案

我借鉴了我过去在申请中的经验。如果在终结器级别之前未处理异常,则可能会导致这种情况,如果发生这种情况……它将使应用程序崩溃。

在对 GC 配置进行任何操作之前..

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

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

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

关于c# - .NET 4.5 : internal error in the . NET 运行时 (80131506)/禁用并发 GC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19154014/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com