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

fix: ispaused invalid iterator #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxime1907
Copy link

@maxime1907 maxime1907 commented Feb 14, 2025

This fixes that sort of crash:

Which happens on this function call:

Coming from here:

So from my understanding, this->m_Paused crashes because this is null

That's why i am trying to avoid any call with iter being an invalid iterator

i added this on our prod servers since 04/02/2025 and we have not encountered this crash again:

Copy link
Member

@Kenzzer Kenzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe your fix & crash in details, without that information it's unclear what you're trying to fix.

On that note, your crash seems like it could stem from an unproperly setup dynamic sourcehook.

Comment on lines +259 to +267
bool isValidIterator(List<CHook>::iterator &myIter, List<CHook> &myList) {
for (auto iter = myList.begin(); iter != myList.end(); ++iter) {
if (iter == myIter) {
return true;
}
}
return false;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inefficient, there are better ways to go about this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the better ways? using this?

return myIter != myList.end() && std::distance(myList.begin(), myIter) >= 0;

void SkipPaused(List<CHook>::iterator &iter, List<CHook> &list)
{
while (iter != list.end() && iter->IsPaused())
if (!iter || !isValidIterator(iter, list))
Copy link
Member

@Kenzzer Kenzzer Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your basis for believing iter can be null ? And if it is null, does checking only for that fixes your crash ? (I'm mainly hoping we can avoid having to iterate the entire the list)

Copy link
Author

@maxime1907 maxime1907 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have edited my PR description to answer what you asked for

@maxime1907
Copy link
Author

Please describe your fix & crash in details, without that information it's unclear what you're trying to fix.

On that note, your crash seems like it could stem from an unproperly setup dynamic sourcehook.

done! thanks for the info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants