Here is the situation: I have a manager class that is a UObject with a TMap and an FCriticalSection.
The manager class has a function that edits the TMap and sets up a timer for every new entry added to the TMap. The function is called from a behavior tree task, and I use FScopeLock Lock(&CriticalSection) to prevent errors when editing the TMap.
The function that is called by the timer(s) takes a TMap key as parameter and reads and edits the specific entry. I also utilize a ScopeLock here.
Finally, there is a third function that is also called from a behavior tree that edits the TMap and uses the ScopeLock.
Most of the time this system works as expected but when I get the AIs in the game map to call the manager’s functions a lot, I can sometimes get a EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000024 that crashes the game, and the log points out to the FScopeLock Lock(&CriticalSection) in the first function I mentioned. And removing the lock would risk an error caused by the TMap.
I do not possess much previous experience with Unreal Engine’s mutexes and as such trying to replicate and research this error is a bit complicated. So if anyone would have an idea about this bug’s cause and know a possible fix, that would be convenient.