# .NET: Stack overflow. / Process is terminated due to StackOverflowException

**Code:** `Stack overflow` · **Category:** .NET · **Seen on:** .NET

Infinite or very deep recursion exhausted the thread’s stack; .NET can’t catch it and terminates the process.

## Meaning

Property getters calling themselves, recursive ToString/Equals, circular object graphs in custom serializers, or DI registrations resolving each other in loops are typical.

## Common causes

- Property that returns itself (get => Name;)
- Recursive method without a base case
- Circular references in serialization/ToString
- Infinite event loops

## Quick fix

1. Look at the repeating frames in the crash output
2. Use backing fields for properties
3. Convert deep recursion to iteration

## Detailed fix by platform

### C#

1. 

```csharp
private string _name = "";
public string Name { get => _name; set => _name = value; }   // not: get => Name;
```


## How to diagnose

1. **Frames** — Which method repeats?
2. **Recursion** — Base case present?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/dotnet/stack-overflow-dotnet)
