Exception when calling method, Object is valid
I am currently writing a Replication Graph for my Master's thesis.
During the GatherActorListsForConnection calls, it crashes when calling the method for my custom ReplicationGraphNode (UReplicationGraphNode_Room).
Rooms is a TMap:
The function call fails with the message
I don't know what to search for, I cannot debug any further, the GatherActorListsForConnection function is never reached. I also specifically implemented the function, turned off pragma optimization and debugged with the DebugGame-Editor, still the same error. Why am I getting this exception even though I test for the object being null?
SOLVED: I now fixed the issue by changing the Map to a TArray of a struct containing the information and declaring that as a UPROPERTY().
Apparently nested containers (TArray in TMap) cannot be done (Error only appeared after declaring it a UPROPERTY) and maybe declaring it a UPROPERTY() got rid of memory/garbage collection issues...
answered May 15 '19 at 09:40 AM
it's indeed strange it passing 0x0 only way to explain it is that key get nulled after the check, but if you get 0xFFFFFCF that means it's invalid pointer, and it will pass null check as it's different value then null which in most cases is value 0. If thats the case your code will crash at RoomMapEntry.Key->GetRoomInfo() in if condition check right after.
Also in you use IsValid there no point of making null pointer check as IsValid does null check already, also by doing`&RoomMapEntry.Key` you creating pointer of a statically declared pointer variable which never will be null. So your code can be reduced to this:
Now reason why you may have invalid pointers is usally UE4 not seeing the object reference in property or engine not seeing property at all and GC deletes the object as it see it as trash. It's either missing UPROPERTY() on TMap or container you using don't raport object reference (Which if i remember right it might be the case with TMap). Or you manually deleted it and if TMap indeed don't cooperate with GC it will have invalid pointer
I'm also not sure about TArray in TMap as for example TArray in TArray is not supported.
Also make sure to check the logs as they might tell you more about crash, check Saved/Logs in your project directory.
answered May 14 '19 at 11:18 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here