简体   繁体   English

IIS应用程序池意外崩溃

[英]IIS application pool crashing unexpectedly

We are facing a very tricky issue for almost one week now and we are still unable to solve it. 现在我们已经面临将近一个星期的棘手问题,而我们仍然无法解决。

The issue is that we have an application pool on IIS who is crashing and recycling several times a day. 问题是我们在IIS上有一个应用程序池,该池每天崩溃和回收几次。

We monitored what's happening on event viewer but the error there was not enough detailed. 我们监视了事件查看器上发生的事情,但是错误没有足够详细。

Example of the 2 errors (2 seconds between them) from windows event viewer : Windows事件查看器中的2个错误(它们之间2秒)的示例:

Error 1 : 错误1:

Event Id : 1000

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/20/ROOT

Process ID: 14300

Exception: System.ObjectDisposedException

Message: Cannot access a disposed object.
Object name: 'System.Net.Sockets.NetworkStream'.

StackTrace:    at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.FtpClient.FtpSocketStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.Net.FtpClient.FtpSocketStream.WriteLine(Encoding encoding, String buf)
   at System.Net.FtpClient.FtpClient.Execute(String command)
   at System.Net.FtpClient.FtpClient.Disconnect()
   at System.Net.FtpClient.FtpClient.Dispose()
   at System.Net.FtpClient.FtpClient.Finalize()

Error 2: 错误2:

Event Id : 1325 赛事编号:1325

  Faulting application name: w3wp.exe, version: 8.5.9600.16384, time stamp: 0x52157ba0
    Faulting module name: KERNELBASE.dll, version: 6.3.9600.18666, time stamp: 0x58f32841
    Exception code: 0xe0434352
    Fault offset: 0x00015608
    Faulting process id: 0x37dc
    Faulting application start time: 0x01d35b56102b1ddf
    Faulting application path: C:\windows\SysWOW64\inetsrv\w3wp.exe
    Faulting module path: C:\windows\SYSTEM32\KERNELBASE.dll
    Report Id: b9f70358-c76a-11e7-8111-0cc47a0c4e39
    Faulting package full name: 
    Faulting package-relative application ID: 

At this moment, we were able to find which error is making app pool crashing. 目前,我们能够找到导致应用程序池崩溃的错误。 It concerns accessing disposed object from FtpClient library. 它涉及从FtpClient库访问已处置的对象。 But we were still not able to find what in our code is doing such this call. 但是我们仍然无法找到代码中正在执行此调用的内容。

Then, we decided to install DebugDiag ( https://www.microsoft.com/en-us/download/details.aspx?id=49924 ). 然后,我们决定安装DebugDiag( https://www.microsoft.com/zh-cn/download/details.aspx?id=49924 )。 A very powerful tool by the way. 顺便说一句非常强大的工具。 We launched DebugDiag for monitoring app pool crashes and we were able to generate a very detailed report (in .mhtml format). 我们启动了DebugDiag来监视应用程序池崩溃,并能够生成非常详细的报告(.mhtml格式)。

Here is the full call stack : .NET Call Stack 这是完整的调用堆栈: .NET调用堆栈

[[HelperMethodFrame]] 
System_ni!System.Net.Sockets.NetworkStream.Write(Byte[], Int32, Int32)+673bde 
System.Net.FtpClient.FtpSocketStream.Write(Byte[], Int32, Int32)+33 
System.Net.FtpClient.FtpSocketStream.WriteLine(System.Text.Encoding, System.String)+44 
System.Net.FtpClient.FtpClient.Execute(System.String)+1c6 
System.Net.FtpClient.FtpClient.Disconnect()+57 
System.Net.FtpClient.FtpClient.Dispose()+46 
System.Net.FtpClient.FtpClient.Finalize()+10 
[[DebuggerU2MCatchHandlerFrame]] 
[[ContextTransitionFrame]] 
[[GCFrame]] 
[[DebuggerU2MCatchHandlerFrame]] 

Full Call Stack 完整通话堆栈

KERNELBASE!RaiseException+48 
clr!RaiseTheExceptionInternalOnly+27c 
clr!IL_Throw+141 
[[HelperMethodFrame]] 
System_ni!System.Net.Sockets.NetworkStream.Write(Byte[], Int32, Int32)+673bde 
System.Net.FtpClient.FtpSocketStream.Write(Byte[], Int32, Int32)+33 
System.Net.FtpClient.FtpSocketStream.Write(Byte[], Int32, Int32)+33 
System.Net.FtpClient.FtpSocketStream.WriteLine(System.Text.Encoding, System.String)+44 
System.Net.FtpClient.FtpSocketStream.WriteLine(System.Text.Encoding, System.String)+44 
System.Net.FtpClient.FtpClient.Execute(System.String)+1c6 
System.Net.FtpClient.FtpClient.Disconnect()+57 
System.Net.FtpClient.FtpClient.Dispose()+46 
System.Net.FtpClient.FtpClient.Finalize()+10 
clr!MethodTable::FastBox+b0 
clr!MethodTable::CallFinalizer+139 
clr!CallFinalizer+a6 
clr!FinalizerThread::FinalizeAllObjects+a6 
clr!FinalizerThread::FinalizeAllObjects_Wrapper+14 
clr!Thread::DoExtraWorkForFinalizer+1b1 
clr!Thread::DoExtraWorkForFinalizer+234 
clr!Thread::DoExtraWorkForFinalizer+5f8 
[[DebuggerU2MCatchHandlerFrame]] 
clr!Thread::DoExtraWorkForFinalizer+137 
clr!Thread::DoADCallBack+30f 
[[ContextTransitionFrame]] 
clr!Thread::DoExtraWorkForFinalizer+19f 
clr!FinalizerThread::DoOneFinalization+129 
[[GCFrame]] 
clr!FinalizerThread::FinalizeAllObjects+a6 
clr!FinalizerThread::FinalizerThreadWorker+ed 
clr!Thread::DoExtraWorkForFinalizer+1b1 
clr!Thread::DoExtraWorkForFinalizer+234 
clr!Thread::DoExtraWorkForFinalizer+5f8 
[[DebuggerU2MCatchHandlerFrame]] 
clr!ManagedThreadBase::FinalizerBase+33 
clr!FinalizerThread::FinalizerThreadStart+d4 
clr!Thread::intermediateThreadProc+55 
kernel32!BaseThreadInitThunk+24 
ntdll!__RtlUserThreadStart+2f 
ntdll!_RtlUserThreadStart+1b 

We were able to find the exception that made the pool crashing but we are still unable to find which part of our code is doing the call. 我们能够找到导致池崩溃的异常,但仍无法找到代码的哪一部分正在执行调用。 At the bottom of the call stack, you can noticed that the first event is : ntdll!_RtlUserThreadStart+1b which I really don't know .. 在调用堆栈的底部,您会注意到第一个事件是:ntdll!_RtlUserThreadStart + 1b,我真的不知道..

So I would be glad to have some help to solve this 2 questions : 因此,很高兴能为您解决这两个问题提供帮助:

  • How to find in my code what is creating the bug ? 如何在我的代码中找到造成此错误的原因?
  • How can such error making my application pool crashed and recycled ? 这种错误如何导致我的应用程序池崩溃和回收?

Environment : - IIS 8.5 - Application pool CLR version 4 - Windows Server 2012 R2 环境:-IIS 8.5-应用程序池CLR版本4-Windows Server 2012 R2

The message Cannot access a disposed object means that the garbage collector has disposed your object, which you then try to use. 消息Cannot access a disposed object表示垃圾收集器已处置了您的对象,然后您尝试使用该对象。

Are you calling the FtpClient with using , are you doing a .close() ? 您是否正在using调用FtpClient,是否正在执行.close()

The error logs aren't actually useful, it would be better if you posted your code instead. 错误日志实际上并没有用,如果您发布代码则更好。

Also, put you code inside try...catch so that you can capture the error rather than leaving it unhandled. 另外,将代码放在try...catch这样您就可以捕获错误而不是不处理。 Sometimes file transfers fail so you need to be doing something like the following : 有时文件传输失败,因此您需要执行以下操作:

try { 
    using(Stream s = ftpClient.OpenRead()) { 
    // perform your transfer 
    } 
} 
catch(Exception) {
 // Typical exceptions here are IOException, SocketException, or a FtpCommandException 
}

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

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