-
Notifications
You must be signed in to change notification settings - Fork 97
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
base: master
Are you sure you want to change the base?
Conversation
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.
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.
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; | ||
} | ||
|
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.
This is inefficient, there are better ways to go about this.
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.
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)) |
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.
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)
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 have edited my PR description to answer what you asked for
done! thanks for the info |
This fixes that sort of crash:
Which happens on this function call:
metamod-source/core/sourcehook/sourcehook_impl_chook.h
Line 95 in 2009298
Coming from here:
metamod-source/core/sourcehook/sourcehook_impl.h
Line 259 in 4bc5a3a
So from my understanding, this->m_Paused crashes because
this
is nullThat'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: