VERSION 4.17.2
Hey guys,
I think I might have found an Engine bug but as I’m not sure if I’m just making some dumb mistake I’ll just post it in C++ for now. It would surprise me, though, as I’ve been working with C++ in UE4 for almost two months now and it seems unlikely that I have been doing this wrong the whole time but it just started crashing now.
I was able to reproduce the problem in a complete new project so I’ll just show you with this.
Here’s the code, explanations below:
MyObject.h:
UCLASS()
class TEMP_API UMyObject : public UObject
{
GENERATED_BODY()
public:
FString str;
};
MyActor.h:
UCLASS()
class TEMP_API AMyActor : public AActor
{
GENERATED_BODY()
public:
AMyActor();
protected:
virtual void BeginPlay() override;
public:
virtual void Tick(float DeltaTime) override;
private:
UMyObject* myObject;
};
MyActor.cpp:
AMyActor::AMyActor()
{
PrimaryActorTick.bCanEverTick = true;
}
void AMyActor::BeginPlay()
{
myObject = NewObject<UMyObject>();
myObject->str = "test";
Super::BeginPlay();
}
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FString test = myObject->str;
}
Now this is as simple as it gets.
The only thing I do is creating an instance of the UMyObject class and initializing its “str” member with “test”.
Then I proceed to read “str” with every tick.
I created a blueprint instance of MyActor, placed it in the game world and started it. Nothing else!
And after a while the game crashes with Reading violation 0xFFFF… error.
I’ve been sitting over this for hours and I’m really out of ideas.
Has this ever happened to anyone before?
Can anyone else reproduce it?
Is it an Engine bug?
Unfortunately I can’t really test it on other versions right now