Hi, I’ve been writing a state system based on the state pattern using cpp for a character in ue5.
I have come across an error with the engine where it seems to crash due to an EXCEPTION_ACCESS_VIOLATION after a random amount of time while doing nothing in particular. I understand that this error means that there was some memory that the engine attempted to access and failed. Every time it crashes there could be a different result. I have noticed a few different recurring crash logs.
1. The first crash log that I will receive points to a line in my code. The hex value would be one of the following: 0x00000000, 0xfffffffffff, or a seemingly random value. This originally caused me to believe that I was attempting to call a function on a nullptr value. This is the code segment that I am pointed to:
void ATimeTraveler::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (CurrentState != nullptr) {
assert(CurrentState != nullptr);
CurrentState->Update(); // this is the line that the error points to
}
else {
UE_LOG(LogTemp, Warning, TEXT("Current State is nullptr"));
}
}
ATimeTraveler is a class which extends the basic ACharacter class. The line in my code is surrounded in a conditional where it will only run given that CurrentState != nullptr and I assert that it is not nullptr. I will still receive this version of the crash log despite this.
2. The other type of crash log i will receive will similarly point to either a 0x0000000, 0xffffffffff, or seemingly random value, but will not mention any lines from my written code, but only values such as UnrealEditor_Engine and UnrealEditor_Core.
I am completely lost as to why I could be getting this error. Please let me know if you would like me to provide anymore information. Thank you for any help in advance!