我有一个ServiceStack(4.0.46)网络服务,在启动时运行良好,但是在处理了一些和请求后,确定性时间非常长(通常在30到24小时之间),它会最终会遇到处理请求(它收到的很好),并使用以下堆栈跟踪:
来自System.Threading.Thread
的这个特殊功能似乎挂起(在最后一行):
[SecuritySafeCritical]
private void Start(ref StackCrawlMark stackMark)
{
this.StartupSetApartmentStateInternal();
if (this.m_Delegate != null)
((ThreadHelper) this.m_Delegate.Target).SetExecutionContextHelper(ExecutionContext.Capture(ref stackMark, ExecutionContext.CaptureOptions.IgnoreSyncCtx));
this.StartInternal(CallContext.Principal, ref stackMark); //HANGS HERE
}
当服务正常运行时,this.StartInternal
将立即返回。这里不太可能存在.NET框架错误,因此我想知道可能导致此行为的原因。
Thread
个实例是从AppHostHttpListenerPoolBase.ListenerCallback()
的以下部分ThreadPool
获取的,该Thread.Start()
也调用了 this.threadPoolManager.Peek((ThreadStart) (() =>
{
this.ProcessRequestContext(context);
this.threadPoolManager.Free();
})).Start(); //HANGS HERE
:
import sys
from PyQt4 import QtGui, QtCore
app = QtGui.QApplication(sys.argv)
mainWindow = QtGui.QWidget()
width = mainWindow.frameGeometry().width()
height = mainWindow.frameGeometry().height()
我尝试检查所有正在运行的线程(包括框架和外部库代码)的详细堆栈,但是没有看到任何可以解释为什么上述函数无法完成的死锁或其他任何迹象。该项目托管在一个控制台中。使用AppSelfHostBase
instead of a AppHostHttpListenerPoolBase
没有帮助。
我几周来一直在努力解决这个相当低级且难以快速重现的问题,并且缺乏调试的想法并希望能够解决它。因此,非常欢迎任何建议!
这里有一个非常类似的问题:Thread.Start is not returning in some sparse cases in my c# application