Quick answer: EXCEPTION_STACK_OVERFLOW means a thread used up its call stack. In Unreal the usual cause is unbounded recursion: a function that ends up calling itself through a delegate, a damage or overlap event, or a setter and its notify. Open the call stack, find the group of frames that repeats, and break that cycle with a changed-value check or a re-entrancy guard. The less common causes are deep recursion over large data, a very large local variable, and a thread created with a small stack.

The editor or the packaged game closes, and the crash reporter shows Unhandled Exception: EXCEPTION_STACK_OVERFLOW above a call stack where the same function names repeat down the window. Sometimes there is no crash reporter at all and the process simply disappears. This guide explains what the engine is reporting, how to read the repeating frames to find the cycle, and the fix for each cause, with C++ you can adapt. Blueprint recursion has its own guards and messages, covered near the end.

The exact error

In the crash reporter window and in the log:

Unhandled Exception: EXCEPTION_STACK_OVERFLOW

UnrealEditor_MyGame!UHealthComponent::SetHealth() [D:\Projects\MyGame\Source\MyGame\HealthComponent.cpp:31]
UnrealEditor_MyGame!AHeroCharacter::HandleHealthChanged() [D:\Projects\MyGame\Source\MyGame\HeroCharacter.cpp:88]
UnrealEditor_MyGame!UHealthComponent::SetHealth() [D:\Projects\MyGame\Source\MyGame\HealthComponent.cpp:31]
UnrealEditor_MyGame!AHeroCharacter::HandleHealthChanged() [D:\Projects\MyGame\Source\MyGame\HeroCharacter.cpp:88]
UnrealEditor_MyGame!UHealthComponent::SetHealth() [D:\Projects\MyGame\Source\MyGame\HealthComponent.cpp:31]
...

(Delegate frames between the two functions are left out here.) The first line is fixed text from the engine’s Windows crash handler: it prints Unhandled Exception: followed by the name of the Windows exception. The underlying code is 0xC00000FD, which is what Windows Event Viewer and a debugger show for the same crash.

There is a second way this crash can look. The engine can only report the exception if enough stack is left to run its handler. When there is not, the process exits with no dialog and no call stack, and whatever launched it reports exit code -1073741571, which is 0xC00000FD as a signed number. A game that closes instantly with that exit code is the same bug. The general Windows view of this code, for any engine, is in How to Fix Exception Code 0xc00000fd (Stack Overflow) Crashes in Your Game.

On Linux, macOS and Android there is no separate name for it. A stack overflow arrives as a segmentation fault (SIGSEGV) or a bad access, with the same repeating frames in the call stack.

What a stack overflow is

Every thread has a fixed block of memory called its stack. Each function call takes a slice of it for the return address, saved registers and local variables, and gives the slice back when the function returns. The size is set when the thread is created and does not grow. A stack overflow happens when calls nest so deeply, or one call asks for so much, that the block runs out.

The amount of room depends on the thread. On Windows, Unreal Build Tool links Unreal executables with a main-thread stack of 12,000,000 bytes by default. Threads the engine or your code create have their own sizes, and worker threads are usually much smaller. The game thread survives many thousands of nested calls. Recursion with no end condition still fills it in well under a second.

This is a different failure from an access violation. Nothing is wrong with any pointer. The program asked for one more stack frame than exists.

The common causes

What the call stack looks likeCauseFix
Two to four of your functions repeat as a group, with delegate or event frames between themAn event handler triggers the same event again: a broadcast whose listener calls the function that broadcasts, damage that is answered with damage, a setter and its notify calling each otherFix 1
One function repeats by itselfDirect recursion with a missing or unreachable end condition. Also the typo of calling BeginPlay() where you meant Super::BeginPlay()Correct the end condition or the call
A recursive function of yours repeats, and the crash depends on the size of the level or dataRecursion that is correct and too deep: flood fill, tree or graph traversal, a graph with a cycleFix 2
A short call stack with nothing repeating, often with __chkstk as the top frameA very large local variable or arrayFix 3
The error text includes Crash in runnable thread and a thread name, or the frames are a worker thread’sThe code ran on a thread with a small stackFix 4
The repeating frames are engine script functions such as UObject::ProcessEvent, UFunction::Invoke and ProcessLocalScriptFunctionBlueprint recursionBlueprint section
Only engine frames, none from your module, while loading, saving or cooking one assetThe engine recursing over very deep asset data, such as deeply nested widgets or a long chain of referencesFind the asset in the log lines before the crash and flatten or split it

For the second row the compiler sometimes helps. MSVC emits warning C4717 (“recursive on all control paths, function will cause runtime stack overflow”) when it can prove a function always calls itself. Read your build warnings.

How to read the repeating frames

  1. Get the call stack as text. The crash reporter window shows it, and the same text is in the log under the project’s Saved/Logs folder and in the crash folder under Saved/Crashes. Where Are Unreal Engine Crash Logs? lists the locations for packaged games.
  2. Ignore the top few frames. They show where the stack happened to run out, which can be anywhere, including an innocent engine function.
  3. Find the group that repeats. Scroll down until you see the same sequence of functions a second and third time. That sequence, read from bottom to top, is the cycle: A calls B, B calls C, C calls A.
  4. Read the line numbers. Each frame names the file and line of the call that leads to the next frame up. In the example above, HeroCharacter.cpp:88 is the line in the handler that calls SetHealth, and HealthComponent.cpp:31 is the broadcast.
  5. Find what started it, if you need to. Crash reports cut off very long stacks, so the first call into the cycle is often missing. Launch the editor from the IDE with F5 and repeat the steps. With a debugger attached, Visual Studio stops on the faulting line with 0xC00000FD: Stack overflow, and the Call Stack window has the frames.

If the frames show addresses or UnknownFunction where names should be, the build has no debug symbols next to it. How to Read an Unreal Engine Crash Log covers getting names back.

Fix 1: break the event cycle

The most common version in gameplay code is a setter that broadcasts, with a listener that calls the setter:

// HealthComponent.cpp
void UHealthComponent::SetHealth(float NewHealth)
{
	Health = FMath::Clamp(NewHealth, 0.f, MaxHealth);
	OnHealthChanged.Broadcast(Health);             // always notifies
}

// HeroCharacter.cpp, bound to OnHealthChanged
void AHeroCharacter::HandleHealthChanged(float NewHealth)
{
	// keep health on whole numbers
	HealthComponent->SetHealth(FMath::RoundToFloat(NewHealth));   // broadcasts again, which calls this again
}

Neither function looks recursive when read alone. Together they never return. Two changes to the setter fix it, and the first one is enough for most cases:

// HealthComponent.h (private)
bool bBroadcastingHealth = false;     // a plain bool, not a bitfield
// HealthComponent.cpp
void UHealthComponent::SetHealth(float NewHealth)
{
	const float Clamped = FMath::Clamp(NewHealth, 0.f, MaxHealth);
	if (FMath::IsNearlyEqual(Clamped, Health))
	{
		return;                                    // nothing changed: no broadcast, no cycle
	}
	Health = Clamped;

	if (bBroadcastingHealth)
	{
		return;                                    // called from a listener: store the value, do not notify again
	}
	TGuardValue<bool> Guard(bBroadcastingHealth, true);   // true until this function returns
	OnHealthChanged.Broadcast(Health);
}

The early return on an unchanged value ends the rounding example, because rounding an already rounded number changes nothing. The guard handles listeners that really do change the value: the nested call stores it and returns instead of starting a second broadcast. TGuardValue sets the flag and restores the old value when it goes out of scope, on every return path. It takes a reference, which is why the flag cannot be a uint8 : 1 bitfield. Listeners that already ran saw the earlier value, so a listener that must be exact should read the component’s current health.

The same cycle shows up in other shapes:

// ThornsEnemy.cpp
#include "Kismet/GameplayStatics.h"
#include "Engine/DamageEvents.h"

float AThornsEnemy::TakeDamage(float DamageAmount, const FDamageEvent& DamageEvent,
	AController* EventInstigator, AActor* DamageCauser)
{
	const float Applied = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
	if (DamageCauser && Applied > 0.f)
	{
		// hurts whoever hit us. Two thorns enemies, or an enemy caught in its own explosion, never stop.
		UGameplayStatics::ApplyDamage(DamageCauser, ThornsDamage, GetController(), this, UDamageType::StaticClass());
	}
	return Applied;
}

Give reflected damage its own damage type and never reflect that type:

// ThornsDamageType.h
UCLASS()
class MYGAME_API UThornsDamageType : public UDamageType
{
	GENERATED_BODY()
};
// ThornsEnemy.cpp, inside TakeDamage
const UClass* TypeClass = DamageEvent.DamageTypeClass.Get();
const bool bIsReflected = TypeClass && TypeClass->IsChildOf(UThornsDamageType::StaticClass());

if (DamageCauser && DamageCauser != this && Applied > 0.f && !bIsReflected)
{
	UGameplayStatics::ApplyDamage(DamageCauser, ThornsDamage, GetController(), this, UThornsDamageType::StaticClass());
}

Fix 2: replace deep recursion with a loop

Some recursion is correct and still too deep. A recursive flood fill visits one cell per nested call, so on a 512 by 512 grid a winding region can nest more than two hundred thousand calls:

void AGridMap::Fill(FIntPoint Cell, TSet<FIntPoint>& Visited) const
{
	if (!IsWalkable(Cell) || Visited.Contains(Cell))
	{
		return;
	}
	Visited.Add(Cell);
	Fill(Cell + FIntPoint(1, 0), Visited);
	Fill(Cell + FIntPoint(-1, 0), Visited);
	Fill(Cell + FIntPoint(0, 1), Visited);
	Fill(Cell + FIntPoint(0, -1), Visited);
}

It passes every test on a small map and crashes on the first large one. Keep the work list in a TArray, which lives on the heap and can grow, and loop:

void AGridMap::Fill(FIntPoint Start, TSet<FIntPoint>& Visited) const
{
	TArray<FIntPoint> Open;
	Open.Push(Start);

	while (Open.Num() > 0)
	{
		const FIntPoint Cell = Open.Pop();
		if (!IsWalkable(Cell) || Visited.Contains(Cell))
		{
			continue;
		}
		Visited.Add(Cell);
		Open.Push(Cell + FIntPoint(1, 0));
		Open.Push(Cell + FIntPoint(-1, 0));
		Open.Push(Cell + FIntPoint(0, 1));
		Open.Push(Cell + FIntPoint(0, -1));
	}
}

The stack depth is now constant whatever the map size. The same shape works for trees and dependency graphs. For any graph that can contain a cycle, such as dialogue nodes that link back, the visited set is what stops the traversal from running forever, in either version.

Where you keep a recursive function because the depth is small by design, make the design explicit with a depth parameter:

void UDialogueRunner::RunNode(const FDialogueNode& Node, int32 Depth)
{
	if (!ensureMsgf(Depth < 64, TEXT("Dialogue chain deeper than 64 at node %s"), *Node.Id.ToString()))
	{
		return;
	}
	// ... run the node, then:
	// RunNode(NextNode, Depth + 1);
}

A data error now produces one logged ensure with the node’s name instead of a crash with no context. The early return still works in Shipping builds, where the ensure itself is compiled out by default.

Fix 3: move large locals to the heap

A local array is carved out of the stack the moment the function is entered:

void AWorldGen::BuildHeightmap()
{
	float Heights[1024 * 1024];        // about 4 MB of stack for one call
	// ...
}

That is a third of the game thread’s stack and more than many worker threads have in total. The crash has a short call stack with nothing repeating, and on Windows the top frame is often __chkstk, the routine MSVC calls on entry to a function with a large frame. Use a container that allocates on the heap:

void AWorldGen::BuildHeightmap()
{
	TArray<float> Heights;
	Heights.SetNumZeroed(1024 * 1024);
	// ...
}

A TArray with a large TInlineAllocator, a TStaticArray and big structs passed by value sit on the stack too. A buffer of a few kilobytes is harmless once and costly inside a recursive function, where every level of nesting pays for it again.

Fix 4: give your threads enough stack

When you create a thread yourself, you choose its stack size, and a number copied from an example may be far too small for what the thread ends up doing:

// third argument is the stack size in bytes
Thread = FRunnableThread::Create(this, TEXT("PathWorker"), 64 * 1024);      // 64 KB: easy to exhaust

Thread = FRunnableThread::Create(this, TEXT("PathWorker"), 1024 * 1024);    // 1 MB
Thread = FRunnableThread::Create(this, TEXT("PathWorker"), 0);              // 0 asks for the default size

On Windows, a crash on such a thread adds Crash in runnable thread PathWorker to the error text, which tells you which stack ran out. Code that you hand to the engine’s task system, for example through AsyncTask or ParallelFor, runs on worker threads whose stack size is not yours to set. A recursive routine that is safe on the game thread can overflow there, so make it iterative before moving it.

The main thread’s size is a link setting (DefaultStackSize in UBT’s Windows target settings). Raising it buys room for recursion that is bounded and merely deep. It does nothing for a cycle, which fills any stack you give it.

Blueprint recursion and the engine’s guards

The Blueprint virtual machine counts nested script calls and loop iterations and stops a script that goes too far. The messages in the log are:

Infinite script recursion (120 calls) detected - see log for stack trace
Runaway loop detected (over 1,000,000 iterations) - see log for stack trace

The first fires when Blueprint functions nest to the depth set by the console variable bp.ScriptRecurseLimit, 120 by default (older UE4 versions report 250 calls). The second uses Maximum Loop Iteration Count under Edit > Project Settings > Engine > General Settings > Blueprints. In the editor these end the Play session with an error and a Blueprint call stack instead of a crash. The live guides on Blueprint infinite loop crashes and “Infinite Loop detected” in a For Loop cover fixing the graphs.

What matters for this crash is where the guards exist. They are compiled into the editor and into Debug and Development builds. In Test and Shipping game builds they are compiled out. A Blueprint event that calls itself forever is stopped at 120 calls in the editor, and in a Shipping build it keeps nesting native frames until the stack is gone, which is reported as EXCEPTION_STACK_OVERFLOW with the script functions from the causes table repeating. If the editor has ever shown you the recursion message for a graph, fix the graph and leave the limit alone. A cycle can also pass through both languages: C++ fires a Blueprint event whose graph calls the C++ function that fired it. The guard from Fix 1, on the C++ side, stops it.

What Bugnet can and cannot report here

A stack overflow is the crash an in-process reporter can promise least. Bugnet’s Unreal SDK binds FCoreDelegates::OnHandleSystemError, the delegate the engine broadcasts while it handles a fatal error, and files fatal errors, failed check and verify and ensure failures with the engine’s error text and recent log lines. Whether that handler gets to run after a stack overflow is not up to the SDK. As described above, the engine reports the exception only when enough stack is left to run its own handling, and otherwise the process exits with code -1073741571 and nothing is sent. Plan as if a stack overflow produces no automatic report. Bugnet also does not process minidumps or symbolicate native call stacks.

What does work is catching the runaway before the stack is gone. The depth check in Fix 2 raises an ensure failure while the thread is still healthy, the SDK reports ensure failures, and reports with the same title stack into one entry with an occurrence count, so one bad dialogue asset shows up as one entry instead of a wave of silent exits. Ensures are compiled out of Shipping builds by default, so this covers the builds your testers run; check vs ensure vs verify explains what ships. For the cases nothing catches, a player’s report from the in-game form (“the game closed when two spike enemies hit each other”) arrives with the game version and recent log lines, which is often enough to find the pair of handlers. The report fields are described in the bug reports documentation.

Frequently asked questions

What does Unhandled Exception: EXCEPTION_STACK_OVERFLOW mean in Unreal Engine?

A thread ran out of call stack. The usual cause is a function that ends up calling itself without end, often indirectly through a delegate, a damage or overlap event, or a setter and its notify. Less often it is very deep recursion over large data, a very large local variable, or a thread created with a small stack.

How do I find what caused a stack overflow in Unreal?

Open the call stack from the crash reporter or the log and skip the top few frames. Look for the group of functions that repeats, because that group is the cycle, and the file and line on each frame is the call that leads to the next one. If the start of the cycle is cut off, reproduce the crash with the debugger attached and read the Call Stack window.

Why does my Unreal game close with exit code -1073741571 and no crash report?

That number is 0xC00000FD, the Windows stack overflow code. The engine can only report a stack overflow if enough stack is left to run its crash handling, and when there is not, the process exits with that code and no dialog. Treat it as the same bug and look for runaway recursion.

Can I fix a stack overflow by increasing the stack size in Unreal?

Only when the recursion is bounded and simply deep. For a thread you create, pass a larger stack size as the third argument of FRunnableThread::Create. Recursion with no end condition fills a stack of any size, so the cycle has to be broken with a changed-value check, a re-entrancy guard or an iterative loop.

Why does infinite Blueprint recursion crash a Shipping build but only show an error in the editor?

The Blueprint virtual machine has guards that stop a script after too many nested calls or loop iterations and log an infinite script recursion or runaway loop message. Those guards are compiled into the editor and Development builds and compiled out of Test and Shipping game builds. Without them the recursion continues until the native stack is exhausted.

Skip the top frames and find the group of functions that repeats: that group is the cycle. Break it where a handler calls back into the function that notified it, with a changed-value check or a TGuardValue flag.