Destroying Actor causes Exception Access Violation

You must be trying to access the TargetCharacter after you destroyed it. Make sure you wrap every instance of TargetCharacter in your project with an if ensure check. So like this:



if(!ensure(TargetCharacter)) { return; }


Using an ensure will tell you where in the code your TargetCharacter is returning null in the output log.

Hey,

I know this is a long shot, but if anyone could shed any sort of light on why this is happening I would be most grateful, I have been working on this for a while. Simply put, when I call destroy on an actor it causes the entire engine to crash and throw an exception access violation, here is the function call. This is the only function called, if the destroy line is removed the exception is not thrown:

/** Function called to open the start menu */
void ATMOCharacter::OpenStartMenu()
{
	if (TargetCharacter)
	{
		TargetCharacter->Destroy();
	}
}

Here is the log file,

link text

I thought I had wrapped all my references in an if (TargetCharacter) { // Miscellaneous }, but now that you have mentioned it that would seem to be the most probable scenario :(, time to go line by line. Good tip on the ensure though, I had no idea that was a thing, sounds very useful. Cheers mate.

I have looked over my code for the last few hours, and there does not seem to be any that are unguarded. Is there any other reason this could have happened, I am really confused

I finally got an address out of the output file, shown here Log

It says

[2017.12.13-22.17.18:272][347]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000330
[2017.12.13-22.17.18:272][347]LogWindows: Error:
[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x00000000647C4B59 UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x0000000064AE4886 UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x00000000649D18CD UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x00000000649FFC63 UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x0000000064603AE1 UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x0000000064E48DCF UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x00000000645AB9F4 UE4Editor-Engine.dll!UnknownFunction []

[2017.12.13-22.17.18:272][347]LogWindows: Error: [Callstack] 0x0000000053A72578 UE4Editor-TMO.dll!ATMOCharacter::OpenStartMenu() [c:\users\jon\desktop\tmo 4.18\source\tmo\tmocharacter.cpp:750]

For reference the line is

/** Function called to open the start menu */
void ATMOCharacter::OpenStartMenu()
{
	if (TargetCharacter)
	{
		ARusherCharacter* EnemyChar = Cast<ARusherCharacter>(TargetCharacter);
		if (EnemyChar)
		{
			SquadController::RemoveMeFromSquad(EnemyChar);
			TargetCharacter->Destroy();
			// TargetCharacter = this;
		}
	}
} // This is line 750 here

I am very confused