Introduction to debug Fatal Execution Engine Error in .net code

来源:互联网 发布:扑克牌读心术原理 知乎 编辑:程序博客网 时间:2024/06/10 07:49

  We have one .net application running in production server. It runs 2 hours or so and quits every day. It runs fine until I made some change intended for performance improvement. However, it turns out that modified code had bug. When application is put to run for long time for test, it crashes usually after some time which varies from 2 hours to 5 hours. When it crashes, it just disappears without any trace except the following errors in the application event log:

.NET Runtime version 2.0.50727.3615 - Fatal Execution Engine Error (000006427F44AE16) (80131506)

Faulting application myapp.exe, version 1.0.0.0, stamp 4d7753b2, faulting module mscorwks.dll, version 2.0.50727.3615, stamp 4be90280, debug? 0, fault address 0x000000000026e55a.

It is very hard to debug such crash since the exception can’t be caught with regular try-catch block. After 3 weeks investigation, I eventually kinda of solve this problem with two tools provided by Microsoft. 

  • cscript
  • windbg
  •  

    With the help from cscript, one can catch the exception and create memory dump when it happens. The uniqueness of this tool is that it can catch the exception from .NET Runtime.  In my case I use the following command to see what exception happens.

    cscript adplus.vbs -crash -FullOnFirst -p <PID>

    Here <PID> is the process id. And the culprit turns out to be access violation exception in mscorwks.dll. Then I use the below command with one configuration file to obtain full memory dump instead of mini memory dump of the crashed process.

    cscript.exe adplus.vbs -c c:/ADPlus.config

    Configuration file:

      

    With full memory dump, I can use tool windbg to execute the following command to make deep analysis.

    windbg -y SymbolPath -i ImagePath -z DumpFileName

     I found my .NET application crashes during the execution of.NET function SqlBulkCopy::WriteToServer, one DataTable object, one parameter of WriteToServer has heap corruption problem. Though now I still can’t understand why heap corruption occurs in the data memeory of that DataTable object, I managed to use one override form of WriteToServer function to work around this problem. The override function takes DataRow[] array as parameter, and doesn’t need DataTable. (Since I don’t understand why memory corruption happens, this problem is kinda of solved, I think. If anyone feels interested, or has any problem, please contact me. Thanks. ^_^)

    During my experience with windbg, I use the following command to get result. More commands can be searched via internet. Moreover, these is one really great blog for using windbg to debug .net application, I strongly recommend visiting it. Here is the address: http://blogs.msdn.com/b/tess/

    The command I used:

    CommandDescription.loadby sos mscorwksload sos in frame 2.0!clrstack -pview clr function argument!clrstack -aview clr stack variables.!clrstack -lview clr stack local variable~*e!clrstackList all managed code stack!do addrdump object at address!dd addrDisplay address!da addrPrint the content of array!dumpmt addrDisplay type of object at that address!gcroot addrDisplay which object is holding object at address!verifyheapVerify whether heap has problem
    原创粉丝点击
    热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 床边与墙有间隙怎么办 抽了烟头晕恶心怎么办 9个月宝宝口臭怎么办 狗舔了人的伤口怎么办 狗舔了结痂伤口怎么办 狗狗指甲变黑了怎么办 狗狗不肯剪指甲怎么办 厕所门对厨房门怎么办 房间门对着镜子怎么办 门直对着楼梯口怎么办 厨房门对着客厅怎么办 卧室正对着马路怎么办 主卧厕所对着床怎么办 卧室门对着床头怎么办 主卧厕所门对床怎么办 老人晕车怎么办最有效方法 货车油刹不好用怎么办 7岁儿童喉咙有痰怎么办 3岁宝宝喉咙有痰怎么办 冰箱正对厨房门怎么办 买了连廊高层怎么办 想买电玩瑞文怎么办 财位旁边有窗户怎么办 入室门对卧室门怎么办 卧室门对着大门怎么办 床给别人睡过了怎么办 镜子对着书房门怎么办 次卧对着卫生间怎么办 一楼房间太潮湿怎么办 房间里潮湿很重怎么办 儿童眼屎多又黄怎么办 地铁旁房子很吵怎么办 租的房子隔音差怎么办 花园洋房买了2楼怎么办 路由器wan口坏了怎么办 卧室有横梁压床怎么办 买了13层的房子怎么办 买了运费险换货怎么办 运费险一直没退怎么办 属相与日子相冲怎么办 人身上阴气太重怎么办