FRunnable crashes when changing a bool value

[FONT=&amp]If I understand correctly, it is unwise to spawn or destroy UObjects within FRunnables.
[FONT=&amp]Furthermore, if I understand correctly, it is unwise to modify UObjects within FRunnables.
[FONT=&amp]I’m wondering then why I’m getting a crash with the following code:


uint32 FNeedsRunnable::Run(){
    // Check if we even have a container to work with.
    if (Container != NULL)
    {
        //Container->ThreadSafeUpdateNeeds();

         Container->IsUpdated = true;
    }


    return 0;
}

[FONT=&amp]

[FONT=&amp]where Container is a struct. It itself is not a USTRUCT(). Some of it’s properties are pointers to USTRUCTs and UObjects, but none of them are being modified or touched - all I’m doing here is updating a bool value - and yet this still causes a crash.
[FONT=&amp]Any ideas?

What’s the crash?

I modify a state enum in an AActor when my FRunnable completes without any issues, so in principle I don’t see why you have a problem.

For some reason, the editor crash window says I lack the appropriate symbols, despite them being downloaded, installed, and verified.

However, according to my Minidump, the error is as follows:

[FONT=lucida console]Exception Code: 0xC0000005
[FONT=lucida console]Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.

Here is the code relevant to the crash:


uint32 FNeedsRunnable::Run(){
	if (Container != NULL)
	{
		Container->IsUpdated = true;
	}


	return 0;
}

Container is a pointer to this kind of struct:


struct FRunnableContainer
{
	FClassicNeedsContainer* Needs;
	ACClassicPerson* Person;
	float TimeStamp = 0.0f;
	bool IsUpdated = false;


	FRunnableContainer() {};


	FRunnableContainer(FClassicNeedsContainer* InNeeds, float InTime, bool InUpdated) : Needs(InNeeds), TimeStamp(InTime), IsUpdated(InUpdated) {};
};

with FClassicNeedsContainer being a USTRUCT() and ACClassicPerson being an Actor. However, neither of those should be relevant, as we are only updating that boolean value.

EDIT: Looking at the code, it appears that I never tell that assign that runnable’s Container variable - i.e. it is a NULL pointer. That brings up another question: Container is NULL, but the code inside of if(Container != NULL) runs.

Anyways, even when I assign it a container, I still get the same crash.

Hmm, I guess somehow the engine is granting access to the AActor* member in my case through the UObject framework. Not in front of UE at the moment but I’ll have a go at assigning a non-UObject member later if I get a chance.

Try use ThreadSafe pointers instead:

RxDesu, you saint. Using TSharedPtr seems to be working! Thank you!!