…the editor crashes on startup (assert fails) at the following location:
UE4Editor-CoreUObject.dll!TFastReferenceCollector<FGCReferenceProcessor,FGCCollector,FGCArrayPool,0>::ProcessObjectArray(TArray<UObject *,FDefaultAllocator> & InObjectsToSerializeArray, TRefCountPtr & MyCompletionGraphEvent) Line 293 C++
UE4Editor-CoreUObject.dll!TGraphTask<TFastReferenceCollector<FGCReferenceProcessor,FGCCollector,FGCArrayPool,0>::FCollectorTask>::ExecuteTask(TArray<FBaseGraphTask *,FDefaultAllocator> & NewTasks, ENamedThreads::Type CurrentThread) Line 883 C++
UE4Editor-Core.dll!FTaskThreadAnyThread::ProcessTasks() Line 1277 C++
UE4Editor-Core.dll!FTaskThreadAnyThread::ProcessTasksUntilQuit(int QueueIndex) Line 1171 C++
UE4Editor-Core.dll!FTaskThreadBase::Run() Line 643 C++
UE4Editor-Core.dll!FRunnableThreadWin::Run() Line 76 C++
UE4Editor-Core.dll!FRunnableThreadWin::GuardedRun() Line 25 C++
However, if either the UPROPERTY() is removed, or the pointer is initialized to nullptr inside the struct’s constructor, like this:
Object = nullptr;
…the editor starts up.
The log states:
0]LogUObjectBase:Error: Object flags
are invalid or either Class or Outer
This error is probably related to UE-23056 where the developer notes say ‘Improper struct initialization’ (which isn’t being terribly specific).
I see that not initializing the pointer probably IS an improper initialization, and I get that this probably cannot be caught at compile time. However, it is a very obscure error to me that took some time to track down.
Maybe an improved runtime error could be implemented that somehow names the affected struct?
This project opens fine, even if I make a Blueprint of the class and place it in the default level. I also tried creating another local instance of the struct in my class’ constructor, and that didn’t result in a crash either.
You’re not trying to do anything with it. Try passing it as a function parameter. Try broadcasting a delegate with the struct as a parameter. The crash at least for me was on the c++ level, I did nothing in blueprints at that point.
I was digging into this some more today, and noticed that the error message that I was getting does already somewhat hint at where the problem lies. This is the error that I am receiving: LogWindows:Error: Invalid object in GC: 0x000007fec7bda848, ReferencingObject: MyActor /Script/TestStruct3.Default__MyActor, ReferencingObjectClass: Class /Script/TestStruct3.MyActor, Property Name: Object, Offset: 1072, TokenIndex: 17
In this case, “Object” may not be the best name for the pointer in the struct. However, the error does indicate that there is a problem with the property named Object. Do you think that needs to be further clarified in this case?
You’re right, I missed that error message. My mistake was that when you stop the MS Visual Studio debugger at the point where it hits the breakpoint (and not click ‘Continue’ (twice), the UED doesn’t finish the log so that line never gets written.
I think the error message you posted is sufficient.
I bumped into same issue in 4.20 too (Invalid object in GC). Unitialized UPROPERTY() UObject* in struct which is in struct (all of them marked as UPROPERTY) is causing crash on GC.
I created the struct in begin play with FMyStruct s = FMyStruct(); and then assigned to class variable of same type: StructClassVariable = s;
Actor class which contains StructClassVariable is placed in level and command obj gc is causing crash.
So what can be hapenning is that FMyStruct created as local variable does not have its variable initialized because it is not UPROPERTY() class variable and this variable is then assigned to class variable marked as UPROPERTY(). Next GC iterates over references and actor reference in class variable is not initialized, so it crashes.