Download

Editor Crashes When Preview Stopped (Access Violation Exception)

Hi guys, got this error for a while now and I couldn’t find any solution. I’m taking a Udemy Course on UE4 Game development and we were asigned to make a door mesh move(rotate) as one.

This is the OpenDoor.cpp file:


#include "OpenDoor.h"
#include "GameFramework/Actor.h"

// Sets default values for this component's properties
UOpenDoor::UOpenDoor()
{
    // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
    // off to improve performance if you don't need them.
    PrimaryComponentTick.bCanEverTick = true;

    // ...
}


// Called when the game starts
void UOpenDoor::BeginPlay()
{
    Super::BeginPlay();

    TargetYaw = InitialYaw + 90.f;

    InitialYaw = GetOwner()->GetActorRotation().Yaw;
    CurrentYaw = InitialYaw;

}

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    UE_LOG(LogTemp, Warning, TEXT("Yaw is: %f"), GetOwner()->GetActorRotation().Yaw);

    CurrentYaw = FMath::Lerp(CurrentYaw, TargetYaw, 0.02f);
    FRotator DoorRotation = GetOwner()->GetActorRotation();
    DoorRotation.Yaw = CurrentYaw;
    GetOwner()->SetActorRotation(DoorRotation);


    //float CurrentYaw = GetOwner()->GetActorRotation().Yaw;
    FRotator OpenDoor(0.f, TargetYaw, 0.f);
    OpenDoor.Yaw = FMath::FInterpTo(CurrentYaw, 90.f, DeltaTime, 45);

}

My OpenDoor.h file:


#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "OpenDoor.generated.h"


UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGSCAPE_API UOpenDoor : public UActorComponent
{
    GENERATED_BODY()

public:    
    // Sets default values for this component's properties
    UOpenDoor();

protected:
    // Called when the game starts
    virtual void BeginPlay() override;

public:    
    // Called every frame
    virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

private:

    float InitialYaw;
    float CurrentYaw;
    float TargetYaw;
};


And here it is the log end(and error msg):


[2020.04.01-23.41.19:263] 46]LogUObjectHash: Compacting FUObjectHashTables data took   1.97ms
[2020.04.01-23.41.19:307] 50]LogPlayLevel: Display: Destroying online subsystem :Context_3
[2020.04.01-23.41.20:803][226]LogEditorViewport: Clicking on Actor (LMB): StaticMeshActor (SM_Door)
[2020.04.01-23.41.22:839][226]LogWindows: Error: === Critical error: ===
[2020.04.01-23.41.22:839][226]LogWindows: Error: 
[2020.04.01-23.41.22:839][226]LogWindows: Error: Fatal error!
[2020.04.01-23.41.22:839][226]LogWindows: Error: 
[2020.04.01-23.41.22:839][226]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffff
[2020.04.01-23.41.22:839][226]LogWindows: Error: 
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56a7cc74 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe5642c5a4 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56479056 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:839][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56478fc3 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56483ce7 UE4Editor-SlateCore.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe5686e860 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56840195 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe5686f001 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56893de2 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffe56893316 UE4Editor-Slate.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ff68c1d901f UE4Editor.exe!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ff68c1ec3ec UE4Editor.exe!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ff68c1ec4ca UE4Editor.exe!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ff68c1fceae UE4Editor.exe!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ff68c1ffcbe UE4Editor.exe!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffeb0af7bd4 KERNEL32.DLL!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: [Callstack] 0x00007ffeb2a8ced1 ntdll.dll!UnknownFunction ]
[2020.04.01-23.41.22:840][226]LogWindows: Error: 
[2020.04.01-23.41.22:856][226]LogExit: Executing StaticShutdownAfterError
[2020.04.01-23.41.23:010][226]LogWindows: FPlatformMisc::RequestExit(1)
[2020.04.01-23.41.23:010][226]LogCore: Engine exit requested (reason: Win RequestExit)
[2020.04.01-23.41.23:042][226]Log file closed, 04/01/20 20:41:23


Thanks in advance!

You’re dereferencing the “GetOwner()” object without checking if the Owner is valid.

​​​​​I’ve tried what you say, checking if the object is valid or not, but it didn’t work. I get the exact same issue when I stop the “game”. I tried using the IsValid method on both BeginPlay and TickComponent. Any other idea on how could I fix it?

Okay, FIXED. Here’s what worked if someone has the same problem:

Add a couple validators to the GetOwner method, as TheJamsh said, but this way:



void UOpenDoor::BeginPlay()
{
    Super::BeginPlay();

    if (IsValid(GetOwner())) {
        InitialYaw = GetOwner()->GetActorRotation().Yaw;
        CurrentYaw = InitialYaw;
        TargetYaw = InitialYaw + 90.f;
    }

}

// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    if (IsValid(GetOwner())) {
        UE_LOG(LogTemp, Warning, TEXT("%s"), *GetOwner()->GetActorRotation().ToString());
        UE_LOG(LogTemp, Warning, TEXT("Yaw is: %f"), GetOwner()->GetActorRotation().Yaw);

        CurrentYaw = FMath::Lerp(CurrentYaw, TargetYaw, 0.02f);
        FRotator DoorRotation = GetOwner()->GetActorRotation();
        DoorRotation.Yaw = CurrentYaw;
        GetOwner()->SetActorRotation(DoorRotation);
    }


Same problem same solution +1