Assertion failure when setting text field in HUD

My game crashes consistently with the error cause

Assertion failed: Index >= 0
[File:d:\buildfarm\buildmachine_++ue4+release-4.11\engine\source\runtime\coreuobject\public\uobject\UObjectArray.h]
[Line: 401]

The crash is 100% reproducible, but occurs after an indeterminate period of time, sometimes 10 seconds, sometimes a minute or two - suggesting a race condition perhaps? Running in the debugger from Visual Studio, the cause appears to originate in my HUD Blueprint. This has a Tick event handler which updates on-screen UMG text widgets. There are a set of widgets for each (player) character in the game. The first part of the handler iterates through the players - this appears to work as when I break the link to the next section of the graph, the code runs.

The next section of the graph looks up the player records in the game instance using the name in the player’s widget as a key, then extracts the HP and max HP from that data structure, and stores them in the respective text fields of my HudPlayerStatusBP.

I can prevent the assertion firing by breaking the links to the calls to SetText. The text fields appear to be showing correct values up to that point so I am fairly confident I am not accessing random memory,

Am now strongly suspecting this is a GC problem, trying to find the culprit… any hints for finding out which objects are being released?

Hi Rudy, I am now convinced this is a GC problem caused my me, I have called AddToRoot() on an object I had allocated with NewObject<>() and it now seems to be behaving itself. This is therefore Not A Bug.

Hello lordGoldemort,

I have a few questions for you that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. When you say that your issue originates from your “HUD blueprint”, is this an actual HUD Blueprint or do you mean that this is a UMG widget blueprint?
  2. Can you reproduce this issue in a clean project?
  3. If so, could you provided a detailed list of steps to reproduce this issue in a clean project?
  4. Could you provide screen shots of any blueprints (from the repro) that may be involved with this issue?
  5. Could you provide the complete call stack that you are getting?

Hello lordGoldemort,

I am happy to hear that your issue has been resolved. I will be converting your last comment to answer. Thank you for your information and time.

Make it a great day