TWeakObjectPtr is "STALE" when assigned valid Actor

Hi!

After upgrading to 4.21 from 4.19 I have a problem with TWeakObjectPtr being stale directly after assigned a valid actor?

bool bIsValidLowLevel = actor_placed_in_editor->IsValidLowLevel();

	TWeakObjectPtr<AActor> test_pointer; 
	test_pointer = actor_placed_in_editor;

	bool bIsState = test_pointer.IsStale();
	bool bIsValid = test_pointer.IsValid();

After the above code is run, the status is

bIsValidLowLevel = true

bIsState = false

bIsValid = true

However, if I hover over test_pointer it says “STALE”. If the pointer is used, e.g. Cast<ISomeInterface>(test_pointer.Get()), the game crashes.

Any help would be appreciated!

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

I’m also having this issue! I think it might only be related to the UE4.natvis file, which is incorrectly showing STALE or the wrong object.

This is still a problem - the visualizers have been broken for ages now.

Would it crash the game i its just visualizers?

Yeah, the UE4.natvis file is broken for FWeakObjectPtr and TWeakObjectPtr types. Open UE4.natvis, and replace the visualizer sections for the above mentioned types with the following:

<DisplayString Condition="ObjectSerialNumber &lt; 1">nullptr</DisplayString>
<DisplayString Condition="GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].SerialNumber != ObjectSerialNumber">STALE</DisplayString>
<DisplayString>{GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].Object}</DisplayString>
<Expand>
  <ExpandedItem>GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].Object</ExpandedItem>
</Expand>




<DisplayString Condition="ObjectSerialNumber &lt; 1">nullptr</DisplayString>
<DisplayString Condition="GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].SerialNumber != ObjectSerialNumber">STALE</DisplayString>
<DisplayString>{($T1*)GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].Object}</DisplayString>
<Expand>
  <ExpandedItem>($T1*)GObjectArrayForDebugVisualizers->Objects[ObjectIndex / 65536][ObjectIndex % 65536].Object</ExpandedItem>
</Expand>

(Basically the number 66560 has to be replaced with 65536, Epic apparently has changed the number of elements per chunk in FChunkedFixedUObjectArray from 65 * 1024 to 64 * 1024 .)

Seams like this is fixed in 4.27. Not sure the earliest version it was fixed in though.