Crash when destroying a skeletal mesh attached via socket while tracing the parent

Hello,

We are migrating from 5.5.4 to 5.6.0 and encountered a crash during the destruction of a skeletal mesh component that is attached via a socket to a parent skeletal mesh component. The crash occurs when we trace the parent skeletal mesh in the same tick as the child is destroyed.

The crash appears related to the Weld system. The `WeldToImplementation`` call on attach works correctly, but during \``UnWeldFromParent`` there is no fallback to resolve the socket name into a bone name when looking up the BodyInstance`, which results in a null dereference.

We fixed the crash by transferring the fallback logic from WeldToImplementation into UnWeldFromParent, specifically resolving the BoneName from the socket if the original BodyInstance lookup fails. Here’s the relevant fix (look to code block).

This ensures that the component properly unwelds when destroyed mid-tick, even if it’s still involved in a physics trace.

Regards Igor.

`void UPrimitiveComponent::UnWeldFromParent()
{
FBodyInstance* NewRootBI = GetBodyInstance(NAME_None, false);
UWorld* CurrentWorld = GetWorld();
if (NewRootBI == NULL || NewRootBI->WeldParent == nullptr || CurrentWorld == nullptr || CurrentWorld->GetPhysicsScene() == nullptr || !IsValidChecked(this) || IsUnreachable())
{
return;
}

// If we’re purging (shutting down everything to kill the runtime) don’t proceed
// to make new physics bodies and weld them, as they’ll never be used.
if(GExitPurge)
{
return;
}

SCOPE_CYCLE_COUNTER(STAT_UnweldPhysics);

FName SocketName;
UPrimitiveComponent * RootComponent = GetRootWelded(this, GetAttachSocketName(), &SocketName);

if (RootComponent)
{
//start fix
FBodyInstance* RootBI = RootComponent->GetBodyInstance(SocketName, false);
FName BoneName = SocketName;

//If initial lookup fails, check if we need to lookup the bone from the socket instead
if (!RootBI && RootComponent->IsA())
{
USkeletalMeshComponent* RootSkeletal = Cast(RootComponent);
if (const USkeletalMeshSocket* Socket = RootSkeletal->GetSocketByName(SocketName))
{
BoneName = Socket->BoneName;
RootBI = RootComponent->GetBodyInstance(BoneName, false);
}
}

if (RootBI)
{
//end fix
bool bRootIsBeingDeleted = !IsValidChecked(RootComponent) || RootComponent->IsUnreachable();
const FBodyInstance* PrevWeldParent = NewRootBI->WeldParent;`

CollStack:

[2025.07.01-06.21.58:072][409]LogWindows: Error: === Critical error: === [2025.07.01-06.21.58:072][409]LogWindows: Error: [2025.07.01-06.21.58:072][409]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff [2025.07.01-06.21.58:072][409]LogWindows: Error: [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618dde6e6 PlayGround.exe!SetHitResultFromShapeAndFaceIndex() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp:161] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618d8bb31 PlayGround.exe!ConvertOverlappedShapeToImpactHit<ChaosInterface::FLocationHit>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp:659] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618d8c99e PlayGround.exe!ConvertQueryImpactHitImp<ChaosInterface::FLocationHit>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp:304] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618d8f5ce PlayGround.exe!ConvertTraceResults<ChaosInterface::FSweepHit>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\CollisionConversions.cpp:491] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e75529 PlayGround.exe!TSceneCastCommonImpWithRetryRequest<TSQTraits<ChaosInterface::FSweepHit,1,1>,FGeomSQAdditionalInputs,FDefaultAccelContainer>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\SceneQuery.cpp:566] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e49e0a PlayGround.exe!TSceneCastCommonImp<TSQTraits<ChaosInterface::FSweepHit,1,1>,FGeomSQAdditionalInputs,FDefaultAccelContainer>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\SceneQuery.cpp:742] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e8696b PlayGround.exe!TraceCommonImp<1,1,FGeomSQAdditionalInputs,TArray<FHitResult,TSizedDefaultAllocator<32> >,FDefaultAccelContainer>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\SceneQuery.cpp:792] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e37e83 PlayGround.exe!TSceneCastCommon<1,1,TArray<FHitResult,TSizedDefaultAllocator<32> >,FGeomSQAdditionalInputs,FDefaultAccelContainer>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\SceneQuery.cpp:885] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e21986 PlayGround.exe!FGenericPhysicsInterface::GeomSweepMulti<FCollisionShape>() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\SceneQuery.cpp:1066] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618f823a9 PlayGround.exe!UWorld::SweepMultiByObjectType() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Collision\WorldCollision.cpp:263] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff6195a82f1 PlayGround.exe!UKismetSystemLibrary::execSphereTraceMultiForObjects() [E:\GIT\UE5\PlayGround\Intermediate\Build\Win64\PlayGround\Inc\Engine\UHT\KismetSystemLibrary.gen.cpp:19715] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e6ee4a PlayGround.exe!UObject::execCallMathFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1107] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e717bd PlayGround.exe!UObject::execLetBool() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:3044] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4df58 PlayGround.exe!ProcessLocalScriptFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1242] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e27d69 PlayGround.exe!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1070] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e2ff32 PlayGround.exe!ProcessLocalFunction’::2'::<lambda_1>::operator()() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1321] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4daf4 PlayGround.exe!ProcessLocalFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1339] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4df58 PlayGround.exe!ProcessLocalScriptFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1242] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e27d69 PlayGround.exe!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void *)>() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1070] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e2ff32 PlayGround.exe!ProcessLocalFunction’::2'::<lambda_1>::operator()() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1321] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4daf4 PlayGround.exe!ProcessLocalFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1339] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4df58 PlayGround.exe!ProcessLocalScriptFunction() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1242] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4d813 PlayGround.exe!UObject::ProcessInternal() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1364] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612b196e9 PlayGround.exe!UFunction::Invoke() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:7454] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612e4c2d7 PlayGround.exe!UObject::ProcessEvent() [E:\GIT\UE5\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2211] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618f83a75 PlayGround.exe!UActorComponent::TickComponent() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp:1772] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618e09a48 PlayGround.exe!FActorComponentTickFunction::ExecuteTickHelper<FActorComponentTickFunction::ExecuteTick’::2'::<lambda_1> >() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Classes\GameFramework\Actor.h:4838] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff618f11b28 PlayGround.exe!FActorComponentTickFunction::ExecuteTick() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp:1593] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a16cf29 PlayGround.exe!FTickFunctionTask::DoTask() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:345] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a1724d2 PlayGround.exe!TGraphTask<FTickFunctionTask>::ExecuteTask() [E:\GIT\UE5\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:707] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612081f23 PlayGround.exe!UE::Tasks::Private::FTaskBase::TryExecuteTask() [E:\GIT\UE5\Engine\Source\Runtime\Core\Public\Tasks\TaskPrivate.h:528] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612075049 PlayGround.exe!FNamedTaskThread::ProcessTasksNamedThread() [E:\GIT\UE5\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:779] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff612075439 PlayGround.exe!FNamedTaskThread::ProcessTasksUntilIdle() [E:\GIT\UE5\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:679] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a18ca45 PlayGround.exe!FTickTaskSequencer::ReleaseTickGroup() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:1011] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a1946ff PlayGround.exe!FTickTaskManager::RunTickGroup() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\TickTaskManager.cpp:2079] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61965328e PlayGround.exe!UWorld::RunTickGroup() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:786] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61965c5e7 PlayGround.exe!UWorld::Tick() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1527] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff619331936 PlayGround.exe!UGameEngine::Tick() [E:\GIT\UE5\Engine\Source\Runtime\Engine\Private\GameEngine.cpp:1878] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a6f1321 PlayGround.exe!FEngineLoop::Tick() [E:\GIT\UE5\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5625] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a704c1c PlayGround.exe!GuardedMain() [E:\GIT\UE5\Engine\Source\Runtime\Launch\Private\Launch.cpp:187] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a704cfa PlayGround.exe!GuardedMainWrapper() [E:\GIT\UE5\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:128] [2025.07.01-06.21.58:072][409]LogWindows: Error: [Callstack] 0x00007ff61a707b08 PlayGround.exe!LaunchWindowsStartup()

Hi Igor,

Thank you for the report, callstack and proposed fix. I am trying to repro the issue now, but I’m afraid I am having a little difficulty. Would it be possible for you to provide a minimal repro project, or repro steps I can follow from a blank project to trigger the crash? Otherwise, would you kindly be able to provide a bit more information about your repro? For example:

- Do you have a single actor containing both skeletal mesh components you mentioned? When and how are they attached/welded and detached/unwelded?

- When and how is the trace triggered? I can see SphereTraceMultiForObjects() is being called from TickComponent(), can you provide a little more context?

- Since UnWeldFromParent() does not appear in the provided callstack, it would also be helpful to see the callstack of the point where that function is called.

I will keep on trying to repro the issue here, but any extra information can be helpful so that the engine devs can test it and validate a fix.

Best regards,

Vitor

Hi VItor,

We have a separated actor (with skeletal mesh) attached to our AI character that can be destroyed using a weapon. This separated actor is attached to a socket by its socket name (not the bone name, which is important). A crash occurs when we destroy the separated actor. Regarding the trace, it’s the more challenging part. It’s an AI sense that runs every tick to detect if they see the player. As for the repro project, it seems like a complex problem to me (we need the trace to occur in the same tick that we destroy the object). However, if you investigate the code for WeldToImplementation and UnWeldFromParent, you should notice inconsistencies in that code.

Regards Igor.

Hi Igor,

I have been able to reproduce the behavior where a skeletal mesh component attached-and-welded to another one using a socket name instead of a bone name is not properly unwelded when being destroyed. I still haven’t been able to craft a reliable repro project, but I have been able to observe the crash some times. In my case, it happened a few moments later (instead of on the same frame), after garbage collection had a chance to run and a trace was performed that would hit the destroyed component. At this point, the welded FBodyInstance still exists and causes the hit, leading BodyInst->GetPhysicsActor() inside function SetHitResultFromShapeAndFaceIndex() to return a freed pointer.

I have filed an internal bug report about this issue. You should be able to track progress on it once the devs mark it as public: UE-305904.

Let me know if there is anything else I can assist you with.

Best regards,

Vitor