Intermittent shutdown crashes
Closed this issue · 4 comments
During application shutdown there is a race between DestroyModule and the thread that runs CommunicationsHost.
There is a clumsy, temporary fix at #5 but it would be good to find something better. Perhaps there should be a mutex at the ClientInfo level?
I will try to pin point the issue. Hopefully, it is only related to the listening socket, since I had something in place to prevent race condition with the connection socket (using atomic state).
I believe it is only related to the listening socket. Let me get a partial callstack.
It was a null pointer deference (mpSocket was null, not pListenSocket) at the following line in ListenConnect() in NetImgui_NetworkUE4.cpp:
FSocket* pNewSocket = pListenSocket->mpSocket->Accept(FString("netImgui"));
My hypothesis was that this code was running at the same time as Disconnect() in the same file was called on the thread running the module shutdown. Adding a sleep to address the 100% core issue will have dramatically reduced the chances of this recurring. It seemed to occur ~10% of shutdowns prior to the sleep being added, when ListenConnect() was running constantly.