GameNetworkingSockets icon indicating copy to clipboard operation
GameNetworkingSockets copied to clipboard

ReceiveMessagesOnConnection from a worker thread with delayed SteamNetworkingMessage_t::Release()

Open bartwe opened this issue 1 year ago • 1 comments

Using the SteamAPI. I'm using a worker thread to read and process received messages from ReceiveMessagesOnConnection, this is done in such a way that the matching SteamNetworkingMessage_t::Release() may be a bit later. At times the main thread calls RunCallbacks, when this triggers the SteamNetConnectionStatusChangedCallback_t callback to notify the connection has been closed, the worker thread may not have called release yet and may do so soon, i've had crashes in the native dll in this region and i'm wondering if there is a thread safety issue here where the connection getting closed on the main thread doesn't allow the worker thread to receive and release concurrently.

bartwe avatar Dec 05 '24 13:12 bartwe

You should be able to call release from any thread at any time. Once the API gives a message to you, it is all yours. Release() should not need to take any expensive locks, although it may need to do heap operations.

Do you have a stack trace or dump I can look at?

zpostfacto avatar Dec 06 '24 18:12 zpostfacto