How do I crash the App Pool?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 03:45:40

问题


Our ASP.NET 2 web application handles exceptions very elegantly. We catch exceptions in Global ASAX in Application_Error. From there we log the exception and we show a friendly message to the user.

However, this morning we deployed the latest version of our site. It ran ok for half an hour, but then the App Pool crashed. The site did not come back up until we restored the previous release.

How can I make the app pool crash and skip the normal exception handler? I\'m trying to replicate this problem, but with no luck so far.


Update: we found the solution. One of our pages was screenscraping another page. But the URL was configured incorrectly and the page ended up screenscraping itself infinitely, thus causing a stack overflow exception.


回答1:


The most common error that I have see and "pool crash" is the loop call.

public string sMyText
{
   get {return sMyText;}
   set {sMyText = value;}
} 

Just call the sMyText...




回答2:


In order to do this, all you need to do is throw any exception (without handling it of course) from outside the context of a request.

For instance, some exception raised on another thread should do it:

protected void Page_Load(object sender, EventArgs e)
{
   // Create a thread to throw an exception
   var thread = new Thread(() => { throw new ArgumentException(); });

   // Start the thread to throw the exception
   thread.Start();

   // Wait a short while to give the thread time to start and throw
   Thread.Sleep(50);
}

More information can be found here in the MS Knowledge Base




回答3:


Aristos' answer is good. I've also seen it done with a stupid override in the Page life cycle too when someone change the overriden method from OnInit to OnLoad without changing the base call so it recursed round in cirlces through the life cycle: i.e.

protected override void OnLoad(EventArgs e)
{
  //some other most likely rubbish code
  base.OnInit(e);
}



回答4:


You could try throwing a ThreadAbortException.



来源:https://stackoverflow.com/questions/3044752/how-do-i-crash-the-app-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!