# Crash: check(Event.IsValid()) in StateTreeEvents.h:119 — CaptureNewStateEvents treats an unchanged frame's states as newly entered 

**URL:** <https://forums.unrealengine.com/t/crash-check-event-isvalid-in-statetreeevents-h-119-capturenewstateevents-treats-an-unchanged-frames-states-as-newly-entered/2736441>\
**Category:** Issues and Bug Reporting (Unreal Engine)\
**Tags:** unreal-engine\
**Created:** [July 17, 2026, 3:39pm UTC](https://forums.unrealengine.com/t/crash-check-event-isvalid-in-statetreeevents-h-119-capturenewstateevents-treats-an-unchanged-frames-states-as-newly-entered/2736441 "2026-07-17T15:39:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamSackbirdDEV1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AdamSackbirdDEV1](https://forums.unrealengine.com/u/AdamSackbirdDEV1)\
**Post date:** [July 17, 2026, 3:39pm UTC](https://forums.unrealengine.com/t/crash-check-event-isvalid-in-statetreeevents-h-119-capturenewstateevents-treats-an-unchanged-frames-states-as-newly-entered/2736441/1 "2026-07-17T15:39:40Z")

</div>

### Summary

FStateTreeExecutionContext::CaptureNewStateEvents (StateTreeExecutionContext.cpp, ~line 2503) initializes UniqueStates to all of NewFrame.ActiveStates and only narrows it when the StateID comparison loop finds a divergence. For a frame whose active states are fully identical to the previous frame (an untouched parent frame while a transition re-selects inside a linked-asset frame below it), the loop never breaks, so every state is treated as newly entered.

Because state selection skips re-walking the common prefix (~line 5182), the identical frame’s per-depth entries in FramesStateSelectionEvents are never written and are empty. If that frame contains two or more active states with “Event Required to Enter”: the first empty entry takes the “steal” branch and adds an invalid FStateTreeSharedEvent to EventsInUse (~2546); the second empty entry then matches it (two null TSharedPtrs compare equal), takes the copy branch, and _EventToCapture (~2541) trips check(Event.IsValid()) in FStateTreeSharedEvent::operator_ (StateTreeEvents.h:119).

Side effect even with a single required-event state: the steal branch overwrites the state’s stored captured event with the empty one, which breaks event-payload bindings and fires the ensure(SharedEvent.IsValid()) in StateTreeInstanceData.cpp:284 on the next read.

### What Type of Bug are you experiencing?

AI

### Steps to Reproduce

1. Create a StateTree sub-asset ST\_Sub (Component schema) with two sibling child states A and B; give A a Delay task and an On State Completed → B transition.
2. Create a main StateTree: under Root, a state P1 with Event Required to Enter (tag Test.Event, any payload struct), and its child P2 as a Linked Asset state pointing at ST\_Sub, also with Event Required  
to Enter Test.Event (both with “Consume Event On Select” off).
3. Add a transition into P1 on event Test.Event, run the tree on a StateTreeComponent, send the event.
4. When A’s delay completes and the internal A → B transition fires inside the linked frame, the assert hits.

### Expected Result

I can transition states without a crash

### Observed Result

Unreal Crashes

### Affects Versions

5.6

### Platform(s)

Windows

---

<div class="post-metadata">

**Author:** ![James.Keeling](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@James.Keeling](https://forums.unrealengine.com/u/James.Keeling)\
**Post date:** [August 19, 2026, 7:41pm UTC](https://forums.unrealengine.com/t/crash-check-event-isvalid-in-statetreeevents-h-119-capturenewstateevents-treats-an-unchanged-frames-states-as-newly-entered/2736441/2 "2026-08-19T19:41:26Z")

</div>

This should be fixed in 5.8. I know we added functionality to support similar cases where a child state could be selected while keeping the state with a required event in a sustained transition. What you are describing reminds me very much of the use case we were solving with the fix. If you would like, I can track down the GitHub commit if you want to cherrypick or manually add the change yourself to 5.6. There may be some other work also needed since it is from 2 versions later.

-James
