fix: ispaused invalid iterator#205
Conversation
Kenzzer
left a comment
There was a problem hiding this comment.
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.
This is inefficient, there are better ways to go about this.
There was a problem hiding this comment.
what are the better ways? using this?
return myIter != myList.end() && std::distance(myList.begin(), myIter) >= 0;
There was a problem hiding this comment.
Issue is this function existence, we shouldnt need it.
| 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.
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.
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
thisis 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: