Dingf / GDCommunityLauncher

The launcher for the Grim Dawn Community League project
MIT License
1 stars 2 forks source link

Potential concurrency issue when saving data to server #1

Closed 12foo closed 1 year ago

12foo commented 1 year ago

Hi, spumble from the Discord here. I had a problem earlier with my game getting progressively slower and more CPU hungry, freezing on trying to quit or go to main menu, and failing to sync character data. I was kindly pointed here and have had a look at the code. I think this line might be causing problems:

https://github.com/Dingf/GDCommunityLauncher/blob/0ae9416feff649ae171e13672092c6cd4169c656/dll/src/ServerSync.cpp#L399

It's using a blocking .get() call inside an asynchronous pplx task, probably causing a thread leak in some circumstances, eventually leading to the game saturating the thread pool so that no REST call can proceed (leading to failed syncs). This seems to be supported by the cpprestsdk devs here:

https://github.com/microsoft/cpprestsdk/issues/1147#issuecomment-499414735

I hope this was causing the problem-- if not, I'll see about setting up Visual Studio and having a go at some proper debugging.

Edit: Found some more of these: https://github.com/Dingf/GDCommunityLauncher/blob/0ae9416feff649ae171e13672092c6cd4169c656/dll/src/ServerSync.cpp#L670 https://github.com/Dingf/GDCommunityLauncher/blob/0ae9416feff649ae171e13672092c6cd4169c656/dll/src/ServerSync.cpp#L806