Skip to content
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

Merged
merged 3 commits into from
Jan 2, 2024

Conversation

CTalvio
Copy link
Contributor

@CTalvio CTalvio commented Dec 3, 2023

Simply adds an IsValid check into the foreach player loop in HandleDistanceAndTimeStats_Threaded.

My servers have been crashing on line 941 of the file as described in #766

Currently 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.

@CTalvio
Copy link
Contributor Author

CTalvio commented Dec 3, 2023

Ping to @ASpoonPlaysGames as instructed by contribution guidelines

Copy link
Contributor

@ASpoonPlaysGames ASpoonPlaysGames left a 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.

@CTalvio
Copy link
Contributor Author

CTalvio commented Dec 3, 2023

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.

@CTalvio
Copy link
Contributor Author

CTalvio commented Dec 3, 2023

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.

Copy link
Contributor

@ASpoonPlaysGames ASpoonPlaysGames left a 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

@ASpoonPlaysGames ASpoonPlaysGames added the needs testing Changes from the PR still need to be tested label Dec 3, 2023
@GeckoEidechse GeckoEidechse changed the title Add validity check to HandleDistanceAndTimeStats_Threaded, to prevent crash Add validity check to HandleDistanceAndTimeStats_Threaded, to prevent crash Dec 20, 2023
@GeckoEidechse GeckoEidechse added the almost ready to merge Apart from any small remaining other issues addressed by other labels, this would be ready to merge label Dec 20, 2023
@GeckoEidechse
Copy link
Member

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 ^^

@GeckoEidechse GeckoEidechse removed needs testing Changes from the PR still need to be tested almost ready to merge Apart from any small remaining other issues addressed by other labels, this would be ready to merge labels Jan 2, 2024
@GeckoEidechse GeckoEidechse merged commit af84c42 into R2Northstar:main Jan 2, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants