Access violation reading location TArray.Empty()

Hi guys, Im not sure what is going on here. I have been following the Shooter Example project to try and get some multiplayer functionality and i’m in the process of writing the server browser widget but when i call Empty() on the array of list items, i get an access violation saying:

First-chance exception at 0x00007FF75582CE19 in RTS-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000000008.
Unhandled exception at 0x00007FF75582CE19 in RTS-Win64-DebugGame.exe: 0xC0000005: Access violation reading location 0x0000000000000008.

I dont understand what i am doing wrong here because this is called as soon as the menu is brought up, so there aren’t even any items there. I have already tried making the array a uproperty as the array is of shared pointers and that had no effect.

Any help with this would be greatly appreciated.

Kieran.

If you post your setup it’d help.

I assume it is either the array is private and you are accessing it outside member functions, or perhaps the object that contains the array is actually null and you are calling functions on it.

I am calling it from within the class it belongs to so i dont think its that. Also surely if the server browser object is null the function would not be called at all right?

I am not familiar with the shooter example or what you are trying to do so someone else might have a better idea, but in general the access violation you are getting is either from the class itself being null (the function would indeed be called on a null object and it would crash as soon as it tries to access any member variables/functions like what is happening), or you are doing operations on invalid/null objects inside the array, or you are going out of bounds of the array.

Okay so ive done a little more debugging and ive found that even when i replace the ServerList.Empty(); with: Screenshot - 57342dbdf3881171e575a7e4ae3b7fdd - Gyazo
It still gives the error. Its not actually breaking on the call itself but on this: Screenshot - 57342dbdf3881171e575a7e4ae3b7fdd - Gyazo

In both cases it breaks on DestructItems, which i think suggests that it thinks there are items in the array which there are not. when i call Empty or initialize the array in the constructor it works but out of the constructor it doesn’t

I Have fixed the problem now. I believe it was something along the lines of what BaderThanBad was saying. I was calling the BeginServerSearch function when the widget was enabled. To fix it i called the function when a button was pressed.

Thank you for your help BaderThanBad