Crash on closing PIE or BP

hello,

I’m having a crash every time I close a PIE session or closing my character BP window. this never happened in 4.9 and I haven’t touched my code in months (probably since 4.7). just recently I converted it from 4.9 to 4.10 and now that I actually tried to play I get this crash.

so whenever I do PIE and close it, or open my character blueprint and close it, the engine will crash into this:

Assertion failed: ChildCount >
AttachChildren.Num()
[File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp]
[Line: 676] AttachChildren count
increased while detaching ‘None’,
likely caused by OnAttachmentChanged
introducing new children, which could
lead to an infinite loop.

this is the callstack for the PIE crash:

UE4Editor-Engine.dll!USceneComponent::OnComponentDestroyed() Line 676	C++
UE4Editor-Engine.dll!UActorComponent::BeginDestroy() Line 388	C++
UE4Editor-Engine.dll!UPrimitiveComponent::BeginDestroy() Line 855	C++
UE4Editor-CoreUObject.dll!UObject::ConditionalBeginDestroy() Line 659	C++
UE4Editor-CoreUObject.dll!CollectGarbageInternal(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 1362	C++
UE4Editor-CoreUObject.dll!CollectGarbage(EObjectFlags KeepFlags, bool bPerformFullPurge) Line 1400	C++
UE4Editor-UnrealEd.dll!UEditorEngine::EndPlayMap() Line 328	C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 978	C++

and this is the callstack for closing my character BP:

UE4Editor-Engine.dll!USceneComponent::OnComponentDestroyed() Line 676	C++
UE4Editor-Engine.dll!AActor::MarkComponentsAsPendingKill() Line 3722	C++
UE4Editor-Engine.dll!UWorld::DestroyActor(AActor * ThisActor, bool bNetForce, bool bShouldModifyLevel) Line 640	C++
UE4Editor-Engine.dll!UWorld::EditorDestroyActor(AActor * ThisActor, bool bShouldModifyLevel) Line 471	C++
UE4Editor-Kismet.dll!FBlueprintEditor::DestroyPreview() Line 7863	C++

in both cases it crashes into USceneComponent::OnComponentDestroyed(), on this line:

checkf(ChildCount > AttachChildren.Num(), TEXT("AttachChildren count increased while detaching '%s', likely caused by OnAttachmentChanged introducing new children, which could lead to an infinite loop."), *Child->GetName());

I checked with the debugger and ChildCount is 1, and AttachChildren.Num() is also 1. and the scenecomponent definately looks like it’s owned by my Character.

maybe it’s worth pointing out that I use several other custom-made C++ Components that I attach to my Character.

any ideas of something new that could introduce this?

Similar thing happens for me in a packaged multiplayer project. The error pops up when the server goes offline/closes or sometimes even when the last remaining client disconnects. The Log-file says the following:

Assertion failed: ChildCount > AttachChildren.Num() [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.10\Engine\Source\Runtime\Engine\Private\Components\SceneComponent.cpp] [Line: 676] 
AttachChildren count increased while detaching 'StaticMeshComponent0', likely caused by OnAttachmentChanged introducing new children, which could lead to an infinite loop.

Hello,

I have a few questions in order to gather the information we need to attempt a repro on this crash:

  • Could you provide the logs from your crash?
  • Could you provide your Machine ID from the Crash Reporter window? Also, ensure that you hit send on the Crash Report.
  • Are you able to reproduce the issue in a clean project?

Hello,

thank you for your response.

  • I’ll attach the log files for the packaged game. The files with the suffixes “_2” and “_3” are the logs from the clients, the one without suffix is the server one:
    http://www.struggleofmages.com/files/Logs.zip

  • The machine ID is the following: 695E24FB4D4B6838B5EACD9651F02A91

  • I could not reproduce this issue with a clean third person c++ project.

Hi, we had the exact same issue while upgrading to 4.10.

In void USceneComponent::OnComponentDestroyed() while looping on children one of them has its AttachParent null (we didn’t found how it is even possible to be in AttachChildren list without having any AttachParent).

We hot fixed our engine sources to handle this case:

	int32 ChildCount = AttachChildren.Num();
	while (ChildCount > 0)
	{
		if (USceneComponent* Child = AttachChildren.Last())
		{
			if (AttachParent)
			{
				Child->AttachTo(AttachParent);
			}
//EDIT BEGIN: fix assertion when Child->AttachParent is null and so Child->DetachFromParent(); does nothing
			else if (nullptr != Child->AttachParent)
			{
				Child->DetachFromParent();
			}
			else
			{
				AttachChildren.Pop(false);
			}
//EDIT END
			checkf(ChildCount > AttachChildren.Num(), TEXT("AttachChildren count increased while detaching '%s', likely caused by OnAttachmentChanged introducing new children, which could lead to an infinite loop."), *Child->GetName());
		}
		else
		{
		    AttachChildren.Pop(false);
		}
		ChildCount = AttachChildren.Num();
	}

Hope it helps.

Hey Cø and thank you for your help.
Sounds like a good solution to check the “AttachParent = NULL”-Case.

However I’m using the binary version and I’d rather not touch the source code, since I would have to consider the changes on every engine upgrade.

Maybe the Epic-guys could have a look at Cø’s solution?

Testing the solution would require a project with a similar setup to the one that you are using in your project. Could you provide repro steps so that I can attempt to reproduce the issue on our end, and then test the fix to see if it is indeed working? If you are unsure of what steps you took to get the crash to occur, could you submit your project so that I can test the fix? Thank you.

Thanks for your response, Sean. I’ve send you a PM on the forums with the project folder.

Hey -

Sean Flint and I are looking at the project you sent him. We’ve packaged the project and are able to start a server from the button in the upper left corner. For testing purposes, is there a simple way to connect multiple clients or will it require going through the Sign Up process?

hello,

any update on this?

Hello Chosker,

I would recommend giving Cø’s hotfix a try and seeing if that prevents the crash from occurring in your project. Otherwise, we will need more information regarding what exactly is causing the crash, and how we can reproduce the issue.

well I don’t have the source set up, nor do I have time to do so. but I thought you had enough to reproduce the issue by using 's project

if you still can’t reproduce it I can send you my project, there it happens 100% of the times that I close PIE.

We are awaiting a response from as far as how to reproduce the crash using his project. As far as what you can do, if you’d like to send your project we can take a look at it.

I sent you a PM on the forums with my project files. a lot of files are missing so you’ll have some missing references, but it should still allow you to play and reproduce the issue.

repro steps:

  1. load the project
  2. open eTestMap
  3. play in a new editor window
  4. close the game window
  5. pull your hair out as it crashes every time :smiley:

let me know if it works for you

Sorry, I didn’t receive a message for this thread until now. You don’t have to sign up since I’ve sent you two account infos with which you can login.
You can also open the console by pressing PageUp and type in “open 127.0.0.1”, but I wasn’t able to reproduce the issue with this method.

Hello,

This issue has been entered into our system (UE-23366) and has been fixed internally. The fix will be available in a later version. For now, if you are still experiencing the crash, I recommend using the hotfix that Cø provided.

Have a great day,

Sean Flint

great, thanks!

do you know if this fix will make it to a theoretical 10.1, or do we have to wait until 11.0?

Currently, the fix is scheduled for a possible 4.10 hotfix. We cannot guarantee that the fix will be available at that time, so please let us know if you are still experiencing issues after that hotfix is released. Thank you.

Sounds good, thank you!

hello,

UE-23366 was indeed fixed by 4.10.1 as per the release notes. howeverwith 4.10.1, I still have the crash every time I close PIE

hence, the issue isn’t really fixed, and UE4 is still broken for me :frowning:

the link I sent you on the forums via PM with my project should still work, and it will help you reproduce it 100%

I hope you guys can fix it for the next release