EPiWiki.se  - EPiServer notes shared with others
 

Troubleshoot a StackOverflowException

[Edit]
The IIS restarts without any reason and in the application log in the event logs reports:
If the event log reports
Faulting application name: w3wp.exe, version: 7.0.6002.18005, time stamp: 0x49e03238
Faulting module name: kernel32.dll, version: 6.0.6002.18005, time stamp: 0x49e041d1
Exception code: 0xe053534f

Environment


Windows 2008 64bit
IIS 7

Salvation


It means that the IIS process has stopped because of a StackOverflowException, this is a harder situation sense what you want to look at are probably what the CLR stacks are doing, but when using the –crash argument to adplus it takes the memory dump to late so no running managed threads exists. Then the dump has to be generated earlier, this can be done by create a full memory dump when the StackOverflowException is thrown.

StopOnSOE.config



<adplus>
    <settings>
        <runmode> CRASH </runmode>
    </settings>

    <!-- defining and configuring exceptions -->
    <exceptions>
        <!-- First we redefine all exceptions -->
        <config>
            <code>AllExceptions</code>
            <actions1>Log</actions1>
            <actions2>MiniDump;Log;EventLog</actions2>
        </config>

        <newexception>
            <code> e053534f </code>
            <name> Stackoverflow </name>
        </newexception>
        <!-- Configuring the custom exception -->
        <config>
            <code> e053534f </code>
            <actions1>FullDump;Log;EventLog</actions1>
            <actions2>FullDump;Log;EventLog</actions2>
        </config>
    </exceptions>
</adplus>

And then start adplus with this configuration

Adplus -pn w3wp.exe -c StopOnSOE.config

This will start to listen to exceptions on the IIS and when a StackOverflowException is thrown it will create a full memory dump before the process terminate.
Open the dump in WinDbg
Load SOS extensions. And list the current CLR stack

0:047>.loadby sos mscorwks
0:047> !clrstack

Output



OS Thread Id: 0x1874 (47)
(!clrstack processes a max of 1000 stack frames)
Child-SP RetAddr Call Site
000000000c3e71c0 000007ff00d42044 EPiServer.Core.CategoryList..ctor(Int32)
...
000000000c3e8240 000007ff010da586 Development.MyRecursiveFunction()
000000000c3e8290 000007ff010da586 Development.MyRecursiveFunction()
000000000c3e82e0 000007ff010da586 Development.MyRecursiveFunction()
000000000c3e8330 000007ff010da586 Development.MyRecursiveFunction()
...

Open the code and examine the method that calling itself and cause the StackOverflowException
Version author:
Mattias Lövström

EPiServer version

All