Destructibles crash in 4.8

Hello,
I was doing some physics stuff with a custom destructible actor and I was getting a crash every now and then… the crash report was not showing anything useful at all so it took me quite a while to figure out how to reproduce the crash in a clean project.

After a few days I figured out a way to reproduce a similar crash consistently with any destructible.
Hopefully if this one gets fixed it will also fix the random crashes in my custom destructible.

Epic please fix this as soon as possible.

Repro steps:

  1. Add a bsp into your level (or any mesh with collision really)

  2. Drop a destructible asset into your level (from what I have tested any asset will do)

  3. Place the destructible inside the bsp brush like so

46936-bug1.jpg

  1. Add some force per tick to the destructible (for example in the level blueprint)

46937-bug2.jpg

  1. Click play… and crash

    Access violation - code c0000005 (first/second chance not available)

    “”

    PhysX3PROFILE_x64
    PhysX3PROFILE_x64
    PhysX3PROFILE_x64
    UE4Editor_Engine!<lambda_11bc5c8ad3e6b4f034a34c90204cc6e0>::operator()() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\components\destructiblecomponent.cpp:486]
    UE4Editor_Engine!UDestructibleComponent::ExecuteOnPhysicsReadWrite() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\components\destructiblecomponent.cpp:762]
    UE4Editor_Engine!UDestructibleComponent::AddForce() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\components\destructiblecomponent.cpp:490]
    UE4Editor_Engine!UPrimitiveComponent::execAddForce() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\classes\components\primitivecomponent.h:117]
    UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\class.cpp:4125]
    UE4Editor_CoreUObject!UObject::CallFunction() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:463]
    UE4Editor_CoreUObject!UObject::ProcessContextOpcode() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1552]
    UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:673]
    UE4Editor_CoreUObject!UObject::CallFunction() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:587]
    UE4Editor_CoreUObject!UObject::ProcessInternal() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:673]
    UE4Editor_CoreUObject!UFunction::Invoke() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\class.cpp:4125]
    UE4Editor_CoreUObject!UObject::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\coreuobject\private\uobject\scriptcore.cpp:1023]
    UE4Editor_Engine!AActor::ProcessEvent() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\actor.cpp:520]
    UE4Editor_Engine!AActor::ReceiveTick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\intermediate\build\win64\ue4editor\inc\engine\engine.generated.1.cpp:2267]
    UE4Editor_Engine!AActor::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\actor.cpp:682]
    UE4Editor_Engine!AActor::TickActor() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\actor.cpp:670]
    UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\actor.cpp:105]
    UE4Editor_Engine!FTickTaskSequencer::FTickFunctionTask::DoTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\ticktaskmanager.cpp:113]
    UE4Editor_Engine!TGraphTaskFTickTaskSequencer::FTickFunctionTask::ExecuteTask() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\async\taskgraphinterfaces.h:753]
    UE4Editor_Core!FTaskThread::ProcessTasks() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\async\taskgraph.cpp:430]
    UE4Editor_Core!FTaskThread::ProcessTasksUntilQuit() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\async\taskgraph.cpp:273]
    UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\private\async\taskgraph.cpp:991]
    UE4Editor_Engine!FTaskGraphInterface::WaitUntilTaskCompletes() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\core\public\async\taskgraphinterfaces.h:192]
    UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\ticktaskmanager.cpp:232]
    UE4Editor_Engine!FTickTaskManager::RunTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\ticktaskmanager.cpp:643]
    UE4Editor_Engine!UWorld::RunTickGroup() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\leveltick.cpp:697]
    UE4Editor_Engine!UWorld::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\engine\private\leveltick.cpp:1181]
    UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\editorengine.cpp:1339]
    UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\editor\unrealed\private\unrealedengine.cpp:366]
    UE4Editor!FEngineLoop::Tick() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launchengineloop.cpp:2355]
    UE4Editor!GuardedMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\launch.cpp:142]
    UE4Editor!GuardedMainWrapper() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
    UE4Editor!WinMain() [d:\buildfarm\buildmachine_++depot+ue4-releases+4.8\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]

I was able to reproduce this. All you need to do is Just have a DM applying force plugged into Event tick. No need for some of the other steps. :slight_smile:

I’ve reported it with UE-17363.

You can work around this by using timers and custom events that are plugged into tick, so that you’re also not applying force for every tick of every frame.

Here is the work around:

Thank you!

Tim

Thanks for reporting it Tim :slight_smile:

You are right, with blueprints all you need is add force.

But my custom destructible (which adds force per tick in C++) does not crash immediately… it only crashes randomly (sometimes) when I push the physics around or when they get stuck inside another mesh.

Unfortunately your workaround is not applicable in my case.

Please inform me when you guys find a fix! (even if I have to add it to the engine in C++ myself).

Thanks again.

I’ll let you know once the fix is in. :slight_smile:

Hello once again,

The problem seems to still exist in 4.9, except it doesn’t seem to happen from blueprints anymore but in C++.

What I’m trying to do is add a force to each individual chunk per tick.

Here is an example custom destructible component…

#include "Engine.h"
#include "CustomDestructibleComponent.h"

// PhysX 			
#include "PhysXIncludes.h" 
#include "PhysXPublic.h"
//....

UCustomDestructibleComponent::UCustomDestructibleComponent(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
	PrimaryComponentTick.bCanEverTick = true;
	bAutoActivate = true;
}

void UCustomDestructibleComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// #if WITH_PHYSX
// 	uint32 ChunkCount = ApexDestructibleActor->getNumVisibleChunks();
// 	const uint16* ChunkIndices = ApexDestructibleActor->getVisibleChunks();
// 	for (uint32 c = 0; c < ChunkCount; c++)
// 	{
// 		PxRigidDynamic* Chunk = ApexDestructibleActor->getChunkPhysXActor(ChunkIndices[c]);
// 		check(Chunk);
// 
// 		if (Chunk)
// 		{
// 			//Add force for this chunk
// 			Chunk->addForce(PxVec3(0.f, 0.f, 10.f), PxForceMode::eFORCE, true);
// 		}
// 	}
// #endif // WITH_PHYSX 

	for (const FName& BoneName : GetAllSocketNames())
	{
		FBodyInstance* ChunkBI = GetBodyInstance(BoneName);

		if (!ChunkBI)
			continue;

		//Add force for this chunk
		ChunkBI->AddForce(FVector(0.f, 0.f, 10.f));
	}
}

I have tried 2 different approaches for this, one using physx directly(the commented out part) and one using the bodyInstance.

Both result in insta-crash.

Any solution would be extremely appreciated, it’s like this since 4.8…

The crash log:

(apparently it’s too many characters to fit in this post…)

I have tried in a blank project before, didn’t make any difference.
I can create a simple test project if you think it will be any useful but the example code I posted above should be all you need to replicate the crash.

Can you link your Crash Report machine ID here, along with the call stack and logs for the crash happening?

Also, if you set this up in a new blank project do you see the same crash?

Hi TK-Master,

The original issue was fixed with the ticket above. The current crash that you’re getting with applying tick on a per chunk basis is necessarily recommended.

It would be better to post that as a separate question in the C++ Programming section and seek help from the community.