EXCEPTION_ACCESS_VIOLATION when runing get function for variable in struct

Are you sure the elements of the TArray being passed in are valid? I ask because I am fairly sure that you can have nullptr references in a TArray which would cause a crash if you try to reference it.

http://prntscr.com/fvz5i9 This is how im creating the “contradictions” (that go into Arguments) I create three of them then have a 3 second delay that then goes in and runs that code using the ‘Arguments’ array.

I feel like this SHOULD be valid but at this point getting a second opinion on my code wouldn’t be a bad thing.

Posting this just to document it.

Found the issue - I had originally tried to declare my ‘contradictions’ as a default variable in the BP editor and when it didn’t work i forgot to delete it hence there was a null value at the start.

Hi

Whenever I try and run my game in editor it crashes and after checking the logs I get the following error.

[2017.07.14-16.38.50:484][969]LogWindows:Error: === Critical error: ===
[2017.07.14-16.38.50:484][969]LogWindows:Error: 
[2017.07.14-16.38.50:484][969]LogWindows:Error: Fatal error!
[2017.07.14-16.38.50:484][969]LogWindows:Error: 
[2017.07.14-16.38.50:484][969]LogWindows:Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000010c
[2017.07.14-16.38.50:484][969]LogWindows:Error: 
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-DanganronpaMP-3376.dll!ANonstop_Debate::StartDebate() [e:\ue\danganronpamp\source\danganronpamp\nonstop_debate.cpp:23]
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-DanganronpaMP-3376.dll!ANonstop_Debate::execStartDebate() [e:\ue\danganronpamp\source\danganronpamp\nonstop_debate.h:16]
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0A44C1A
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0B77A1E
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0B9BC72
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0B7842E
[2017.07.14-16.38.50:484][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0BC1BC3
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0B9BC72
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0A44C1A
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000E0B9AFEB
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DD5B3922
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DE846EA7
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DD572CDF
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DD57FE2B
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DE6B4BE4
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DDC6D511
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DE6A248E
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-Engine.dll!0x00000000DDC8C003
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DBB98527
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DBBE0B64
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DBBC4CE0
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DBBE11B4
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DB6C626B
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor-UnrealEd.dll!0x00000000DBED1AD6
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor.exe!0x0000000015B1DEE3
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor.exe!0x0000000015B0EB40
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor.exe!0x0000000015B0EBBA
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor.exe!0x0000000015B20A29
[2017.07.14-16.38.50:485][969]LogWindows:Error: UE4Editor.exe!0x0000000015B222B6
[2017.07.14-16.38.50:485][969]LogWindows:Error: KERNEL32.DLL!0x0000000017B42774
[2017.07.14-16.38.50:485][969]LogWindows:Error: ntdll.dll!0x000000001A2C0D51
[2017.07.14-16.38.50:485][969]LogWindows:Error: ntdll.dll!0x000000001A2C0D51
[2017.07.14-16.38.50:485][969]LogWindows:Error: 
[2017.07.14-16.38.50:513][969]LogExit: Executing StaticShutdownAfterError
[2017.07.14-16.38.50:516][969]LogWindows: FPlatformMisc::RequestExit(1)
[2017.07.14-16.38.50:516][969]Log file closed, 07/14/17 17:38:50

I went to look at the code it references and in the header file it just references GENERATED_BODY() so I took a look in the .CPP (shown below)

// Fill out your copyright notice in the Description page of Project Settings.

#include "DanganronpaMP.h"
#include "Nonstop_Debate.h"


ANonstop_Debate::ANonstop_Debate()
{
	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;
	ContradictionFound = false;
	Active = true;
	Success = false;
	ActiveArgument = NULL;
	Proceed = false;
}
void ANonstop_Debate::StartDebate(TArray<UContradiction_Struct*> Arguments, TArray<UCameraComponent*> Cameras) 
{
	while (Active) {
		for (int argumentnum = 0; argumentnum < Arguments.Num(); argumentnum++) {
			Proceed = false;
			ActiveArgument = Arguments[argumentnum];
			ArgumentTime = ActiveArgument->getTimeToSayArgument();
			GetWorldTimerManager().SetTimer(ArgumentTimer, this, &ANonstop_Debate::ArgumentTimerContinue, 1.0f);
			while (Proceed == false) {}
		}
	}
}

void ANonstop_Debate::ArgumentTimerContinue() 
{
	ArgumentTime--;
	if (ArgumentTime < 1)
	{
		Proceed = true;
	}
}

It references this line

			ArgumentTime = ActiveArgument->getTimeToSayArgument();

Which interacts with a user defined struct i made (shown below)

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Engine/UserDefinedStruct.h"
#include "Contradiction_Struct.generated.h"

/**
 * 
 */
UCLASS(BlueprintType)
class DANGANRONPAMP_API UContradiction_Struct : public UUserDefinedStruct
{
public:
	GENERATED_BODY()
	//The text displayed in the argument
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FString DisplayText;
	//Get
	FString getDisplayText() 
	{
		return DisplayText;
	}
	//Set
	void SetDisplayText(const FString NewValue)
	{
		DisplayText = NewValue;
	}
	//The name of the character talking
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FString CharacterName;
	//Get
	FString getCharacterName()
	{
		return CharacterName;
	}
	//set
	void setCharacterName(const FString NewValue)
	{
		CharacterName = NewValue;
	}
	//Indicates whether or not the statement is contradictory or not
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool Contradictory;
	//Get
	bool getContradictory()
	{
		return Contradictory;
	}
	//Set
	void setContradictory(const bool newValue)
	{
		Contradictory = newValue;
	}
	//The ID of the truth bullet that contradicts this argument
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int32 CounteredByID;
	//Get
	int32 getCounteredByID() 
	{
		return CounteredByID;
	}
	//Set
	void setCounteredBYID(const int32 newValue)
	{
		CounteredByID = newValue;
	}
	//The character who says this statement (ID)
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int32 CharacterID;
	//Get
	int32 getCharacterID() 
	{
		return CharacterID;
	}
	//Set
	void setCharacterID(int32 newValue)
	{
		CharacterID = newValue;
	}
	//Time before it switches round
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int32 TimeToSayArgument;	
	//Get
	int32 getTimeToSayArgument() 
	{
		return TimeToSayArgument;
	}
	//Set
	void setTimeToSayArgument(int32 newValue)
	{
		TimeToSayArgument = newValue;
	}
};

Im out of ideas on how to fix this