3

If I write this code

  protected void Page_Load(object sender, EventArgs e)
    {
        Page_Load(sender, e);
    }

I get the an Error (endless recursion):

enter image description here

and the w3wp.exe process is terminated from task manager.

Fine...

however if i do:

throw new ApplicationException(); //or SystemException();

it appears in just a regular exception page. ( w3wp.exe is still up).

questions :

  • what kind of exceptions causing the w3wp.exe to shutdown ?
  • what kind of exceptions causing the Application Pool to shutdown ?

p.s. according to what ive just written , please think about the following scenario : i can write a web page , host my site in a farm of sites , and i can terminate the whole w3wp.exe process by creating recursion ..... ( also others will have trouble)...

Can you please answer my questions ?

thanks.

Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • Take a look at the application log - exception details should show up there. – Oded Apr 17 '12 at 13:01
  • @moguzalp No. Also on non-debugging mode. but thats fine. I dont have true exception in production. i just want to understand which exceptions can terminate what....( just testing to learn) – Royi Namir Apr 17 '12 at 13:04

3 Answers3

1

This is most likely the famous StackoverflowException. It's caused by an infinite loop since you're calling the method Page_Load again and again.

From MSDN:

In prior versions of the .NET Framework, your application could catch a StackOverflowException object (for example, to recover from unbounded recursion). However, that practice is currently discouraged because significant additional code is required to reliably catch a stack overflow exception and continue program execution.

Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default. Consequently, users are advised to write their code to detect and prevent a stack overflow. For example, if your application depends on recursion, use a counter or a state condition to terminate the recursive loop. Note that an application that hosts the common language runtime (CLR) can specify that the CLR unload the application domain where the stack overflow exception occurs and let the corresponding process continue. For more information, see ICLRPolicyManager Interface and Hosting Overview.

You may want to have a look at this answer:

https://stackoverflow.com/a/4802309/284240

Community
  • 1
  • 1
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
  • hi tim yeah I know , but this is just 1 exception among many. i want my mind to be orginized with : `WHICH EXCEPTION (their characteristics) CAN TEMINATE` : **1)AppPool 2)w3wp** – Royi Namir Apr 17 '12 at 13:11
  • I'm pretty sure that `OutOfMemoryException` will have the same effect. – volpav Apr 17 '12 at 13:20
  • 1
    @volpav nope `Insufficient memory to continue the execution of the program.` w3wp.exe is still up. – Royi Namir Apr 17 '12 at 13:21
  • (okay, now I'm just guessing) how about `AccessViolationException`? – volpav Apr 17 '12 at 13:28
0

The reason for the exception is memory overflow. There are many ways how an application can cause this, there is no point to guess specific scenarios. I imaging good hosting providers should be protected from misbehaving applications.

Eliyahu
  • 435
  • 1
  • 3
  • 12
-3

to add to the answers which alrdy are available. u cant bring down the whole process because every website in a server runs in a seperate AppDomain. so if ur code misbehaves only ur appdomain wud be killed.

Parv Sharma
  • 12,581
  • 4
  • 48
  • 80
  • 1
    Can you please try to keep the txt spch 2 a minmum? lso prop caps wud b nice. –  Apr 17 '12 at 14:41