System Namespace


.NET Framework Class Library
StackOverflowException Class

The exception that is thrown when the execution stack overflows because it contains too many nested method calls. This class cannot be inherited.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class StackOverflowException _
    Inherits SystemException
Visual Basic (Usage)
Dim instance As StackOverflowException
C#
[SerializableAttribute]
[ComVisibleAttribute(true)]
public sealed class StackOverflowException : SystemException
Visual C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class StackOverflowException sealed : public SystemException
JScript
public final class StackOverflowException extends SystemException
Remarks

StackOverflowException is thrown for execution stack overflow errors, typically in case of a very deep or unbounded recursion. The Localloc Microsoft intermediate language (MSIL) instruction throws StackOverflowException.

StackOverflowException uses the HRESULT COR_E_STACKOVERFLOW, which has the value 0x800703E9. For a list of initial property values for a StackOverflowException object, see the StackOverflowException constructors.

NoteNote:

The value of the inherited Data property is always nullNothingnullptra null reference (Nothing in Visual Basic).

Version Considerations

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 the Common Language Runtime.

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition Platform Note: A thrown StackOverflowException cannot be caught by a try-catch block. Consequently, the exception causes the process to terminate immediately.

Inheritance Hierarchy

System..::.Object
  System..::.Exception
    System..::.SystemException
      System..::.StackOverflowException
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
See Also

Reference

Other Resources

Tags :


Community Content

Brian Grunkemeyer - MSFT
What is e053534f? It's a soft stack overflow from the CLR.
If you're using a native debugger and seeing Windows' RaiseException being called with a parameter of 0xe053534f, you might be a bit confused about what this number might mean. Hopefully this will save you a little bit of time.

This is a "soft" stack overflow coming from the Common Language Runtime.

#define EXCEPTION_SOFTSO 0xe053534f // 0xe0000000 | 'SSO'

You should debug that like you would any other stack overflow - ie, figure out where your thread went recursive and don't do that. Also look for large stack allocations using C's alloca or C#'s stackalloc keyword. (As for the "soft" part - the CLR will probe for some stack space before starting an operation that is hard to undo, avoiding a real stack overflow and the tricky backout code necessary to properly clean up state. This may happen more often when you're running in a host that cares about recovering from stack overflows, and I suspect constrained execution regions will hit this too when probing for stack space.)

Here are other interesting CLR exception codes passed to RaiseException. I'm putting them here so that search engines can find them. From corexcep.h:

// All COM+ exceptions are expressed as a RaiseException with this exception
// code. If you change this value, you must also change
// bcl\src\system\Exception.cs's _COMPlusExceptionCode value.

#define EXCEPTION_MSVC 0xe06d7363 // 0xe0000000 | 'msc'
#if defined(FEATURE_PAL) && !defined(FEATURE_CORECLR)
#define EXCEPTION_COMPLUS 0xe0524f54 // 0xe0000000 | 'ROT'
#else

#ifdef FEATURE_USE_INSTANCE_TAGGED_SEH_CODES
#define EXCEPTION_COMPLUS 0xe0434352 // 0xe0000000 | 'CCR'
#else //FEATURE_USE_INSTANCE_TAGGED_SEH_CODES
#define EXCEPTION_COMPLUS 0xe0434f4d // 0xe0000000 | 'COM'
#endif //FEATURE_USE_INSTANCE_TAGGED_SEH_CODES

#endif

#define EXCEPTION_HIJACK 0xe0434f4e // 0xe0000000 | 'COM'+1

#define EXCEPTION_SOFTSO 0xe053534f // 0xe0000000 | 'SSO'
// We can not throw internal C++ exception through managed frame.
// At boundary, we will raise an exception with this error code

// This is the exception code to report SetupThread failure to caller of reverse pinvoke
// It is misleading to use our COM+ exception code, since this is not a managed exception.
// In the end, we picked e0455858 (EXX).
#define EXCEPTION_EXX 0xe0455858 // 0xe0000000 | 'EXX'

Tags :

Page view tracker