-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validity check to HandleDistanceAndTimeStats_Threaded
, to prevent crash
#767
Conversation
Ping to @ASpoonPlaysGames as instructed by contribution guidelines |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if you used a Guard Clause to help readability and reduce the number of lines changed
something like this should be fine:
if ( !IsValid( player ) )
continue
As for the actual logic behind the change, it looks good. When I wrote this function I was under the (seemingly incorrect) assumption that GetPlayerArray()
wouldn't give any invalid players...
It's a bit strange though that the SERVER VM managed to get the "Persistent data not available." error, as there isn't a way for it to check if persistence is available. This leads me to believe that disconnecting the player mid-frame can cause problems, but that's beyond the scope of this fix.
I'll make the change once back at my desktop, I've noticed this problem in my mods a couple times where code will try to do things with players that are no longer present, necessitating something like this in some places. |
Done, also still no crash on my server running the initial fix. I didn't change my test mod to use a guard clause but the effective result should be the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, still confused as to why GetPlayerArray()
is giving invalid players but whatever
HandleDistanceAndTimeStats_Threaded
, to prevent crash
This really isn't testable other than hosting a server for a prolonged period of time and checking for script errors. This is basically what @CTalvio did so I'm forgoing testing on my end ^^ |
Simply adds an
IsValid
check into theforeach player
loop inHandleDistanceAndTimeStats_Threaded
.My servers have been crashing on line
941
of the file as described in #766Currently testing this fix as a mod, and normally this crash would happen within a couple hours no matter what. One server instance is going on seven hours of matches with no crashes as of yet, but more time would be good. Will report back.