简体   繁体   English

APPCRASH StackOverflowException clr.dll c00000fd

[英]APPCRASH StackOverflowException clr.dll c00000fd

I am running a .Net console application that executes 24 hrs a day. 我正在运行一个每天24小时执行的.Net控制台应用程序。 It has a bug that occurs about once every 6 days. 它有一个大约每6天发生一次的错误。

I would like your assistance to fix this bug. 我希望得到您的帮助来解决这个问题。 First I will provide some background, and then I will provide the exception messaging. 首先,我将提供一些背景知识,然后我将提供异常消息。

Unfortunately I do not have steps to reproduce. 不幸的是我没有重现的步骤。 You will see why as you read on. 你会在阅读时看到原因。

First some background: 首先是一些背景:

I have robust exception handling in my code (or so I thought). 我的代码中有强大的异常处理(或者我认为)。 For example I have a try...catch block in my Main() method that captures any unhandled exceptions and if they are FATAL it restarts the underlying task. 例如,我在Main()方法中有一个try ... catch块,它捕获任何未处理的异常,如果它们是FATAL,则重新启动底层任务。 It works great for any exceptions generated from my own code. 它适用于我自己的代码生成的任何异常。

I cannot explain why the below exception isn't handled in my code. 我无法解释为什么我的代码中没有处理以下异常。 My best guess is that clr.dll exceptions do not get caught within the managed stack. 我最好的猜测是clr.dll异常不会在托管堆栈中被捕获。 And if that is the case, I do not know how to generate a stack trace. 如果是这种情况,我不知道如何生成堆栈跟踪。 I don't even know where to begin to fix this. 我甚至不知道从哪里开始解决这个问题。

The process I am running is using the following versions and modules: 我正在运行的进程使用以下版本和模块:

  • C# .Net Framework 4.6.1 C#.Net Framework 4.6.1
  • Console App project type Console App项目类型
  • System.Net.WebClient System.Net.WebClient
  • log4net log4net的
  • Windows 7 64-bit Windows 7 64位

At the time of the crash I checked RAM and HDD: both have plenty of free space. 在崩溃时我检查了RAM和HDD:两者都有足够的可用空间。

About the code I'm executing. 关于我正在执行的代码。 The process is a continous loop that downloads data from a website and saves it to a text file. 该过程是一个连续循环,从网站下载数据并将其保存到文本文件中。 If there is an error, it is logged using log4net. 如果有错误,则使用log4net记录。

The basic loop is this: 基本循环是这样的:

 for (int i = 0; i < 5; i++)
            {
                try
                {
                    return new WebClient().DownloadString(url);
                }
                catch 
                {
                    Thread.Sleep(500); // slow it down.
                }
            }

The following is the only message that displays in my console window when the exception occurs: (no stack trace displayed) 以下是发生异常时在控制台窗口中显示的唯一消息:(未显示堆栈跟踪)

Process is terminated due to StackOverflowException

My console application completely freezes up and a dialog window pops up with the following information (closing this dialog also terminates my application) 我的控制台应用程序完全冻结,弹出一个对话框窗口,其中包含以下信息(关闭此对话框也会终止我的应用程序)

 Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: foo.goo.BatchExecutor.exe
  Application Version:  1.0.0.0
  Application Timestamp:    5a50f3eb
  Fault Module Name:    clr.dll
  Fault Module Version: 4.7.2117.0
  Fault Module Timestamp:   59cf5105
  Exception Code:   c00000fd
  Exception Offset: 0002429f
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:    1033
  Additional Information 1: 28e8
  Additional Information 2: 28e8aacd8abfe32876bc8363e8e5c526
  Additional Information 3: 6916
  Additional Information 4: 6916665ca52ff482d854f190abcf46b2

The only other place I could find information about the crash is in the Windows Event Log: 我能找到有关崩溃的唯一信息是在Windows事件日志中:

Log Name:      Application
Source:        Application Error
Date:          1/23/2018 5:51:46 PM
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      FOOGOO
Description:
Faulting application name: foo.goo.BatchExecutor.exe, version: 1.0.0.0, time stamp: 0x5a50f3eb
Faulting module name: clr.dll, version: 4.7.2117.0, time stamp: 0x59cf5105
Exception code: 0xc00000fd
Fault offset: 0x0002429f
Faulting process id: 0x1e00
Faulting application start time: 0x01d39169354e41a7
Faulting application path: C:\Users\Owner\Desktop\SHARED\foo.goo.BatchExecutor\foo.goo.BatchExecutor.exe
Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Report Id: 21b9b2a4-00a9-11e8-9f6c-94c69110a719
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2018-01-24T01:51:46.000000000Z" />
    <EventRecordID>1852</EventRecordID>
    <Channel>Application</Channel>
    <Computer>FOOGOO</Computer>
    <Security />
  </System>
  <EventData>
    <Data>foo.goo.BatchExecutor.exe</Data>
    <Data>1.0.0.0</Data>
    <Data>5a50f3eb</Data>
    <Data>clr.dll</Data>
    <Data>4.7.2117.0</Data>
    <Data>59cf5105</Data>
    <Data>c00000fd</Data>
    <Data>0002429f</Data>
    <Data>1e00</Data>
    <Data>01d39169354e41a7</Data>
    <Data>C:\Users\Owner\Desktop\SHARED\foo.goo.BatchExecutor\foo.goo.BatchExecutor.exe</Data>
    <Data>C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll</Data>
    <Data>21b9b2a4-00a9-11e8-9f6c-94c69110a719</Data>
  </EventData>
</Event>

*****UPDATE WITH SOLUTION WORKAROUND ***** *****更新解决方案*****

I have given up trying to handle this exception within .Net. 我已放弃尝试在.Net中处理此异常。 I found an effective workaround. 我找到了一个有效的解决方法。 This workaround applies to Windows, specifically any version with an Event Viewer. 此解决方法适用于Windows,特别是具有事件查看器的任何版本。

Workaround Instructions. 解决方法说明。

1) Open control panel->Admin Tools->Event Viewer->Windows Logs->Applications. 1)打开控制面板 - >管理工具 - >事件查看器 - > Windows日志 - >应用程序。

2) Select the offending event. 2)选择违规事件。 In my case, it is state ERROR, and matches the example that you see above. 在我的例子中,它是状态ERROR,并匹配您在上面看到的示例。

3) On the right hand side click "Attach Task to This Event". 3)在右侧单击“将任务附加到此事件”。

4) Complete the wizard. 4)完成向导。 In my case, I restart my application. 就我而言,我重启了我的申请。

5) Save the task. 5)保存任务。

6) Now switch over to Task Scheduler and find the task. 6)现在切换到任务计划程序并找到任务。 Click Properties. 单击属性。 Click through the tabs and configure the Task as you see fit. 单击选项卡并根据需要配置任务。

*****UPDATE WITH SOLUTION WORKAROUND ***** *****更新解决方案*****

I have given up trying to handle this exception within .Net. 我已放弃尝试在.Net中处理此异常。 I found an effective workaround. 我找到了一个有效的解决方法。 This workaround applies to Windows, specifically any version with an Event Viewer. 此解决方法适用于Windows,特别是具有事件查看器的任何版本。

Workaround Instructions. 解决方法说明。

1) Open control panel->Admin Tools->Event Viewer->Windows Logs->Applications. 1)打开控制面板 - >管理工具 - >事件查看器 - > Windows日志 - >应用程序。

2) Select the offending event. 2)选择违规事件。 In my case, it is state ERROR, and matches the example that you see above. 在我的例子中,它是状态ERROR,并匹配您在上面看到的示例。

3) On the right hand side click "Attach Task to This Event". 3)在右侧单击“将任务附加到此事件”。

4) Complete the wizard. 4)完成向导。 In my case, I restart my application. 就我而言,我重启了我的申请。

5) Save the task. 5)保存任务。

6) Now switch over to Task Scheduler and find the task. 6)现在切换到任务计划程序并找到任务。 Click Properties. 单击属性。 Click through the tabs and configure the Task as you see fit. 单击选项卡并根据需要配置任务。

I suggests to use ProcDump , it can be configured to generate a crash dump when the StackOverflowException occurs. 我建议使用ProcDump ,它可以配置为在发生StackOverflowException时生成崩溃转储。

procdump -accepteula -e 1 -f C00000FD.STACK_OVERFLOW -g -ma <PID> <OUTPUT PATH>

Then analyze the dump file using one of this tools Visual studio , windbg , debugdiag , clrmd . 然后使用Visual studiowindbgdebugdiagclrmd等工具之一分析转储文件。

I suggest trying DebugDiag ( https://www.microsoft.com/en-us/download/details.aspx?id=49924 ) to capture the crash and analyse the resulting process dump. 我建议尝试使用DebugDiag( https://www.microsoft.com/en-us/download/details.aspx?id=49924 )来捕获崩溃并分析生成的进程转储。 Make sure you include pdbs alongside your exe, to make diagnosis easier: in the Project properties, Build tab: set the Configuration to the configuration that you use to build the exe. 确保在exe旁边包含pdbs,以便于诊断:在Project属性的Build选项卡中:将Configuration设置为用于构建exe的配置。 In the Output section, Advanced button, set the Debugging information to Pdb (or Full). 在“输出”部分的“高级”按钮中,将“调试信息”设置为“Pdb”(或“完整”)。

To help collect a stack trace, PHPTower, you can do what I did and subscribe to the AppDomain.CurrentDomain.UnhandledException event of your program at the beginning of your Main() function 为了帮助收集堆栈跟踪PHPTower,您可以执行我所做的操作并在Main()函数开头订阅程序的AppDomain.CurrentDomain.UnhandledException事件

The signature of the event handler looks like the following, allowing you to get the exception, and output a stack trace with the Exception.ToString() method. 事件处理程序的签名如下所示,允许您获取异常,并使用Exception.ToString()方法输出堆栈跟踪。

    private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
    {
        File.AppendAllLines(FileName, e.ExceptionObject.ToString());
    }

Happy hunting! 快乐狩猎!
-cadatoiva -cadatoiva

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM