[C++] SpawnActor Bug

Hello guys,

I’m recently encountering fatal crashes when I debug my game with the -game command line argument and try to connect via Blueprint-Sessions to a listen server. Whenever I do this, my listenserver crashes and breaks on the following engine code line:

 UE_LOG(LogUObjectGlobals, Fatal, TEXT("Gamethread hitch waiting for resource cleanup on a UObject (%s) overwrite. Fix the higher level code so that this does not happen."), *OldName );

This is the line 1795 in UObjectGlobals.cpp. I’m using the binaries build of 4.7.2.
I seriously have no idea why this is happening, I spawn tons of actors and it only happens for a specific type of actors (I’m spawning an array of actors there, it crashes on the first one already …)
Another thing I observed is, that it seems to have a specific problem when handling (spawning?) the BoxComponent of that specific actor, as the OldName value is: OldName = L"BoxComponent /Game/Maps/AISMap.AISMap:PersistentLevel.BackgroundActorX0z0y0.Box"

If anyone got an idea why this is happening, I’d be really thankful, as the UE_LOG isn’t really helpful for me :frowning:

Thanks in advance :slight_smile:

PS: This is the callstack / crash report data, I hope this helps to investigate this:

Unknown exception - code 00000001 (first/second  not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp] [Line: 1795] 
Gamethread hitch waiting for resource cleanup on a UObject (BoxComponent //Game//Map

KERNELBASE + 35740 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:526]
UE4Editor_CoreUObject!StaticAllocateObject() + 2445 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1795]
UE4Editor_CoreUObject!StaticConstructObject() + 785 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:2226]
UE4Editor_CoreUObject!StaticDuplicateObjectEx() + 583 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1431]
UE4Editor_CoreUObject!StaticDuplicateObject() + 368 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\uobject\uobjectglobals.cpp:1391]
UE4Editor_Engine!AActor::CreateComponentFromTemplate() + 758 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\actorconstruction.cpp:646]
UE4Editor_Engine!USCS_Node::ExecuteNodeOnActor() + 504 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\scs_node.cpp:52]
UE4Editor_Engine!USimpleConstructionScript::ExecuteScriptOnActor() + 1190 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\simpleconstructionscript.cpp:373]
UE4Editor_Engine!AActor::ExecuteConstruction() + 489 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\actorconstruction.cpp:536]
UE4Editor_Engine!AActor::PostSpawnInitialize() + 672 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\actor.cpp:2311]
UE4Editor_Engine!UWorld::SpawnActor() + 2674 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\levelactor.cpp:336]
UE4Editor_MyGame_2725!AMGBackgroundManager::SpawnBackgroundActor() + 143 bytes [c:\users\\documents\unreal projects\MyGame\source\MyGame\private\actors\world\background\MGbackgroundmanager.cpp:201]
UE4Editor_MyGame_2725!AMGBackgroundManager::SpawnBackgroundActors() + 1251 bytes [c:\users\\documents\unreal projects\MyGame\source\MyGame\private\actors\world\background\MGbackgroundmanager.cpp:176]
UE4Editor_Engine!FTimerUnifiedDelegate::Execute() + 571 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\public\timermanager.h:38]
UE4Editor_Engine!FTimerManager::Tick() + 250 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\timermanager.cpp:515]
UE4Editor_Engine!UWorld::Tick() + 3872 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\leveltick.cpp:1156]
UE4Editor_Engine!UGameEngine::Tick() + 1453 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\gameengine.cpp:830]
UE4Editor!FEngineLoop::Tick() + 4179 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2257]
UE4Editor!GuardedMain() + 1404 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
1 Like

Quick Update:

When deleting that BoxComponent, it works! When I add that BoxComponent again, it doesn’t work again though …
Very strange :confused:

I fixed this for myself now by removing the box component, I’m still confused however … I hope someone can find the reason for this crash, so nobody encounters it in the future :slight_smile:

Hi -

In your setup do you have any events tied to your box component, an overlap event etc.?

Thank You

Eric Ketchum

Hi -

We haven’t heard back from you in a few days, but I am fairly confident in saying that this issue has been resolved with the a fix which is forthcoming in version 4.8. The issue revolved around box components and events tied to them and was not particular to C++ in particular.

Thank You

Eric Ketchum

Hey Eric,

sorry I forgot to answer, however I did not assign any delegates to it (overlaps/collisions/stuff like that), so I guess 4.8 might indeed solve that problem, thanks for the update!

Have a nice day,

Best Regards,

I don’t know about the fix, however, the person in your team might try to delete the build/intermediate/binaries folders and recreate the Project files if it’s indeed only happening on his PC, this solved some strange errors here and there for me :slight_smile: Good luck :slight_smile:

Does the fix for this error affect other components as well? A person on my team is getting this error on a SplineMeshComponent. We’re not wiring events to it. bGenerateOverlapEvents is also set to false. Usually several are constructed at runtime and later destroyed (DestroyComponent). Interestingly, I’m not getting the error on my PC, but he is on his.

Thanks.

I had this problem too in my project, if I remember correctly it was something like that:

  1. Add a component to BP based on some native class
  2. Then add same component from the c++ code with the same name, to make a “collision names”
  3. Try load map few times with this BP actor and observe the issue

The engine couldn’t to clean this actor component, but when I removed component added in BP, everything was working correctly.

Thank you. He is unable to do that as he is an artist and does not have the compiler tools on his machine. With our setup, he pulls a pre-compiled UE4Editor dll file for the project from P4 when we have new code changes that need to be pushed out.

I’m hoping whatever was fixed for the BoxComponent was something in a base class that both components share, but a confirmation or denial would be great!

In a project started in 4.8.2, still seeing this problem. We have two spawn classes that, if used, cause a fatal error with the same log entry as above, so I don’t think 4.8 fixes it.

Still getting this, as well. I’m trying to spawn copies of existing objects in my GameState class.

Stack trace: Imgur: The magic of the Internet

Hi and ,

Do you have any additional information about this issue? Is it only happening when certain objects are spawned? Are you spawning Blueprints derived from code classes, or instances of the code class itself? Would it be possible to see the code for the classes that are causing the problem as well as the code being used to spawn them?

,

Please feel free to grab my project from here: nimmod · GitHub

Please note that I only see this crash when playing a standalone game. Otherwise, I just get Actor Channel Errors.

Here’s how to reproduce it:
-Start a server with FirstPersonExample map as the map.
-Join the above server with another client.
-Join the VIP team with one client and any other team with the other client.
-As the VIP, walk in to the VIPTrigger that is in one of the corners of the map.
-This will trigger a Round Restart.
-Kaboom.

If you want to know what classes I’m trying to spawn, take a look at “ARoundManager_ForceRespawn::RestartRound”.

Hi ,

Thanks for providing the sample project that shows the issue. I was able to reproduce the crash in your project, but so far have not had much luck when trying to reproduce the crash in a new project. I’m still working on it, though.

Hey ,

Thanks for getting back to me. You say you haven’t had much luck trying to reproduce the crash in a new project. What happens, then? Do the objects actually respawn?

Thanks for your help,

Nim

I have been trying to simplify the restart code that you have as much as possible to recreate the crash in a new project. I am bouncing back and forth between not being able to compile the code at all, to a crash when opening the project (that produces a callstack that is slightly different from what I saw when restarting using the project that you provided).

From working through the code just prior to when the crash occurs in your project, it seemed to be related to one specific object in the scene, so I migrated that object into my new project and am trying to get the restart working the same way you are doing it to see if it will crash there as well.

Hi ,

Sorry for the delay on this. I was rather stumped by this one, and I recently managed to catch one of our senior engineers when he had a few spare minutes and ran this problem past him.

He said that this particular error occurs when attempting to create a new object over an existing object that hasn’t been completely cleaned up. The most likely cause for this is that the new object is being created with the same name/class/outer as an existing component, when the existing object cannot immediately clean up its resources in BeginDestroy.

We took a look at your restart code, and you do appear to be trying to spawn the new actors with new names, but there does not appear to be a guarantee that the new actor’s name is unique. You should be able to get past this crash by making sure that the names of any new actors are different from any existing actors that may still be waiting to get cleaned up. If you can guarantee that the names of the new actors will always be unique they should spawn without any problems, and GC will take care of the old actors.