# Changing a default subobject name in C++ class leads to UActorComponent being marked as PendingKill immediately after being instantiated when loading from .uasset, and is eventually reset to NULL by GC

**URL:** <https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745>\
**Category:** C++\
**Tags:** garbage-collector, actor-component, serialization, unreal-engine, crash, bug-report, question\
**Created:** [March 24, 2021, 9:47am UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745 "2021-03-24T09:47:09Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![RocknRolla](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RocknRolla](https://forums.unrealengine.com/u/RocknRolla)\
**Post date:** [March 24, 2021, 9:47am UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/1 "2021-03-24T09:47:09Z")

</div>

## Short Description

So, I’ve been investigating this bug for quite some time. I have also found several posts on UE forums on this issue. It affects several engine versions – I have personally reproduced it on 4.25.4 and 4.26.1 (using both Launcher version and recompiled from source).  
The issue happens only with blueprints. There are 2 symptoms I know of:

- `UPROPERTY()` component pointer is somehow set to `NULL` in `BeginPlay()` though it has been set to a non-`NULL` object in C++ constructor using `CreateDefaultSubobject`.
- When opening component details tab, no component properties are visible.

Generally, the advice on the forums is to either reparent a Blueprint to some another parent and the reparent back to the original parent, or to just re-create Blueprint from scratch. In both cases you lose component settings stored in Blueprint, which leads to certain amount of work needed to be redone.

## How to reproduce

1. Create a new UE4 project using Blank C++ template without starter content.

2. Create a new actor C++ class `ATestActor`.

3. Add component property to this class, e.g.:

4. Create default subobject for a component in constructor, e.g.:

5. Add NULL-check to BeginPlay:

6. Re-compile project and launch the engine.

7. Create Blueprint parented to `ATestActor` (e.g., `BP_TestActor`) and open it in Full Blueprint Editor.  
Click on `CapsuleComponent` in Components tab and verify that component properties are visible in Details tab.  
Save and close the engine.

8. Change the name of the component default subobject created in C++ constructor, e.g.:

9. Launch engine and open BP\_TestActor in Full Blueprint Editor.  
Click on `CapsuleComponent` in Components tab and verify that component NO properties are visible in Details tab (Details tab is empty).

10. Drag and drop BP\_TestActor onto a default map and click Play. Editor crashes on our check in `ATestActor::BeginPlay()` because `CapsuleComponent == nullptr`.

## Demo

I have created a simple demo project using the above scenario and published it on github: [GitHub - vogoltsov/UE4\_ActorComponent\_PendingKill\_Demo](https://github.com/vogoltsov/UE4_ActorComponent_PendingKill_Demo)

## Bug details

Notes:

- During loading, if project files remain unchanged, UE4 allocates the same object identifiers each time the project is loaded. So, I am using object identifiers from my demo project onwards.
- I am using Unreal Engine 4.26.1 recompiled from source. As I have added several pragmas to disable optimization on certain functions, so actual line numbers in code may differ a little.

I’ve traced the modifications of `ATestActor`’s member property `CapsuleComponent`:

1. `Default_TestActor[InternalIndex=19506]` (CDO for `ATestActor`) is created and `CapsuleComponent` is set to a non-`NULL` object `UCapsuleComponent[InternalIndex=19507]`.

2. `BP_TestActor.uasset` starts loading.

3. `Default_BP_TestActor[InternalIndex=23596]` (CDO for `BP_TestActor`) is created and `CapsuleComponent` is set to a non-NULL object `UCapsuleComponent[InternalIndex=23595]`.

4. `Default_BP_TestActor.CapsuleComponent` is set to Default\_TestActor.CapsuleComponent[InternalIndex=19507].

5. `Default_BP_TestActor.CapsuleComponent` is reverted to `UCapsuleComponent[InternalIndex=23595]` (value set in 3).

6. `Default_BP_TestActor.CapsuleComponent` is set to a newly created `UCapsuleComponent[InternalIndex=23594]`.

7. During garbage collection, `Default_BP_TestActor.CapsuleComponent` is set to `NULL` because the component instance is marked as `RF_PendingKill`.

After that, I started investigating how `UCapsuleComponent[InternalIndex=23594]` is created and why it is marked as `RF_PendingKill`. The problem lies in how the object property is being de-serialized from the archive. This process can be summarized to:

1. Save current object property value to a local variable (this is essentially a default subobject created in C++ constructor). [Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/PropertyObject.cpp#L105).
2. Read new property value from archive slot. [Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/PropertyObject.cpp#L106).
3. Obtain template to be used as new property value archetype. [Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/LinkerLoad.cpp#L4565).
4. Archetype object is searched in outer class CDO (which is `Default_TestActor`). [Link to source](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectArchetype.cpp#L84).
5. To locate an archetype, perform thread-safe lookup in object outer hash map using `StaticFindObjectFastInternalThreadSafe()`. [Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectHash.cpp#L623).
6. Lookup is performed by name supplied in archive (`Export.ObjectName` variable) which appears to be `“OldComponentName”`. But the object created in constructor has been registered in outer map using name supplied in `ATestActor` constructor, which is `“NewComponentName”`. Thus, outer hash map lookup fails, and `NULL` is returned.
7. Because the object could not be found in outer hash map, class default object is returned as the archetype.  
[Link to source](https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectArchetype.cpp#L131).
8. Construct new object using template.  
[Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/LinkerLoad.cpp#L4710).
9. Now everything goes well, until execution hits `AActorComponent::PostInitProperties()`. In normal circumstances, newly created component should be added as owned component to outer object (which is `Default_BP_TestActor`).  
But because `MyArchetype != GetClass()->ClassDefaultObject` check fails, `MarkPendingKill()` is called.  
[Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp#L311).
10. Replace property value with new pointer. [Link to source](https://github.com/EpicGames/UnrealEngine/blob/4.26.1-release/Engine/Source/Runtime/CoreUObject/Private/UObject/PropertyObject.cpp#L111).

## Proposed solution

I understand that changing component names is generally to be avoided, but it can sometimes be done “unintentionally” – e.g., to fix spelling errors during refactoring. The problem is not that component renaming may not be supported, but that Unreal Engine just silently sets component property to `NULL` **without raising an error** or at least issuing a warning.

Personally, I would prefer a fail-fast solution when performing an invalid operation (i.e., renaming a component) leads to an error, so this can be immediately addressed. We would also need to add a new core redirect type to allow renaming components without breaking things. (This whole situation is somewhat similar to renaming C++ class which have existing child Blueprints.)

One way to achieve this would be to modify `UActorComponent::PostInitProperties()` and move `MyArchetype != GetClass()->ClassDefaultObject` inside `ensureAlwaysMsgs()` or `checkf()`, e.g.:

```
ensureAlwaysMsgf(MyArchetype != GetClass()->ClassDefaultObject, TEXT("Failed to get archetype for natively created component. Owner class: %s. Owner name: %s. Component class: %s. Component name: %s"), *OwnerPrivate->GetClass()->GetPathName(), *OwnerPrivate->GetFName().ToString(), *GetClass()->GetPathName(), *GetFName().ToString());

```

This would result at least in the following error being written to Output Log:

```
LogOutputDevice: Error: Ensure condition failed: MyArchetype != GetClass()->ClassDefaultObject [File:C:\Development\UnrealEngine\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp] [Line: 293] 
Failed to get archetype for natively created component. Owner class: /Game/BP_TestActor.BP_TestActor_C. Owner name: Default__BP_TestActor_C. Component class: /Script/Engine.CapsuleComponent. Component name: OldComponentName

```

I have attached a sample patch. I have tested on several of my pet projects as well as ActionRPG sample project, and this seems to be working fine. But more tests are needed for sure.

```
diff --git a/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp b/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp
index 87eee3ccab3..342449f3b07 100644
--- a/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp
+++ b/Engine/Source/Runtime/Engine/Private/Components/ActorComponent.cpp
@@ -289,7 +289,8 @@ void UActorComponent::PostInitProperties()
                if (!FPlatformProperties::RequiresCookedData() && CreationMethod == EComponentCreationMethod::Native && HasAllFlags(RF_NeedLoad|RF_DefaultSubObject))
                {
                        UObject* MyArchetype = GetArchetype();
- if (!MyArchetype->IsPendingKill() && MyArchetype != GetClass()->ClassDefaultObject)
+ ensureAlwaysMsgf(MyArchetype != GetClass()->ClassDefaultObject, TEXT("Failed to get archetype for natively created component. Owner class: %s. Owner name: %s. Component class: %s. Component name: %s"), *OwnerPrivate->GetClass()->GetPathName(), *OwnerPrivate->GetFName().ToString(), *GetClass()->GetPathName(), *GetFName().ToString());
+ if (!MyArchetype->IsPendingKill())
                        {
                                OwnerPrivate->AddOwnedComponent(this);
                        }

```

---

<div class="post-metadata">

**Author:** ![resivium1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@resivium1](https://forums.unrealengine.com/u/resivium1)\
**Post date:** [February 27, 2022, 8:17pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/2 "2022-02-27T20:17:01Z")

</div>

I experienced a similar issue in UE5: changing the component `SubobjectName` of an UObject made with `CreateDefaultSubject` leads to nullptrs in existing blueprints that still use the previous component name. I found that renaming the variable name of the component fixes the depending blueprints.

For example:

````auto
// 1. Define component with a certain SubobjectName. 
URadialForceComponent* RadialForceComponent = CreateDefaultSubobject<URadialForceComponent>(TEXT("I will change this name after creating a blueprint with this Actor"));

// now make a blueprint with it

// 2. Changing SubobjectName breaks downstream blueprints
URadialForceComponent* RadialForceComponent = CreateDefaultSubobject<URadialForceComponent>(TEXT("RenamedComponent breaks blueprint"));

// 3. fix: refactor variable (ignoring SubobjectName)
URadialForceComponent* RadialForceComponentRenamedVar = CreateDefaultSubobject<URadialForceComponent>(TEXT("RenamedComponent breaks blueprint"));```
````

---

<div class="post-metadata">

**Author:** ![zana4ka03](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zana4ka03](https://forums.unrealengine.com/u/zana4ka03)\
**Post date:** [June 17, 2023, 1:05pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/3 "2023-06-17T13:05:21Z")

</div>

The safest solution I’ve found is to simply comment creating of subobject, resave blueprints without created subobject, uncomment creating of subobject. In this case all you’re losing is blueprint changed data in this particular component.

---

<div class="post-metadata">

**Author:** ![Backside4Charter](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Backside4Charter](https://forums.unrealengine.com/u/Backside4Charter)\
**Post date:** [July 14, 2023, 1:11pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/4 "2023-07-14T13:11:27Z")

</div>

I can confirm this is still happening in 5.2.1.

It’s very frustrating since it’s extremely common to want to change the name of a subobject. The current solution at least gets you out of a corrupted state, but it’s a very cumbersome workaround that leads to data loss. I hope the Unreal developers can prioritize a fix for this.

---

<div class="post-metadata">

**Author:** ![NyuNighteyes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NyuNighteyes](https://forums.unrealengine.com/u/NyuNighteyes)\
**Post date:** [October 15, 2023, 12:51pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/5 "2023-10-15T12:51:26Z")

</div>

bump

pls fix or add clear error

---

<div class="post-metadata">

**Author:** ![VoiDTimo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VoiDTimo](https://forums.unrealengine.com/u/VoiDTimo)\
**Post date:** [October 29, 2024, 4:35pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/6 "2024-10-29T16:35:21Z")

</div>

Still in 2024 wasted my days off work tracking down this instead of making progress. Horaaaay…time wasted.

---

<div class="post-metadata">

**Author:** ![ADIAN](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/adian/32/1194609_2.png) [@ADIAN](https://forums.unrealengine.com/u/ADIAN)\
**Post date:** [March 5, 2025, 2:42am UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/7 "2025-03-05T02:42:48Z")

</div>

epic games, help!

---

<div class="post-metadata">

**Author:** ![andyvyking](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/andyvyking/32/641039_2.png) [@andyvyking](https://forums.unrealengine.com/u/andyvyking)\
**Post date:** [June 18, 2025, 10:56pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/8 "2025-06-18T22:56:26Z")

</div>

Thank you for investigating this! I just spent a day troubleshooting and scratching my head as to why I was getting nullptr, until I found your post.

I hit it in 5.5 with a UPROPERTY UObject, that wasn’t even exposed to the blueprint subclass.

---

<div class="post-metadata">

**Author:** ![Yandayixia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yandayixia](https://forums.unrealengine.com/u/Yandayixia)\
**Post date:** [January 7, 2026, 1:28pm UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/9 "2026-01-07T13:28:53Z")

</div>

Can confirm still happens as of 5.7.1

Simply calling Rename on a parent class defined subobject causes it to lose visibility in the detail editor.

---

<div class="post-metadata">

**Author:** ![MaxKarabin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MaxKarabin](https://forums.unrealengine.com/u/MaxKarabin)\
**Post date:** [August 19, 2026, 10:09am UTC](https://forums.unrealengine.com/t/changing-a-default-subobject-name-in-c-class-leads-to-uactorcomponent-being-marked-as-pendingkill-immediately-after-being-instantiated-when-loading-from-uasset-and-is-eventually-reset-to-null-by-gc/480745/10 "2026-08-19T10:09:29Z")

</div>

Skill happens in 5.8.0. I renamed a component class creating in a ctor while refactoring and changed component name. After that the Editor started crashing because of NullPointerException in PostInitializeComponents.

Tried to

1. Comment a line with CreateDefaultObject in ctor.
2. Start the Editor clicking a Debug button in Rider IDE.
3. Make some changes in a derived blueprint;
4. Save and compile it.
5. Restart the Editor.
6. Close the Editor.
7. Uncomment the line with CreateDefaultObject.
8. Start the Editor.

It helped to fix NullPointerException but the subobject has the old name.
