Skip to content

fix: find a fired timer again before the list is touched after its callback - #1484

Merged
roflmuffin merged 2 commits into
roflmuffin:mainfrom
makadore:fix/timer-removal-during-callback
Nov 8, 2026
Merged

roflmuffin merged 2 commits into
roflmuffin:mainfrom
makadore:fix/timer-removal-during-callback

Conversation

@makadore

@makadore makadore commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

A timer callback that kills another timer sitting earlier in the list shifts the list, and RunFrame kept using the index it had before the callback: it erased the wrong entry and left the fired, already deleted timer in the list, so the next frame read freed memory; two kills from one callback moved the index past the end; a repeating timer behind schedule ran twice in one frame.
The loop now finds the fired timer again when its index no longer points at it, then erases or reschedules it there and continues below it.
Four tests in Tests.Native cover the cases; on main three of them take the server down and the fourth sees a second run in the same frame.
Possibly the crash reported in #981.

…llback

RunFrame kept using the index it had before the callback, both to erase
the timer and to continue the loop. A callback that kills another timer
earlier in the list shifts the list: the erase dropped a different timer
and left the fired one, already deleted, in the list, so the next frame
read freed memory; two kills from one callback moved the index past the
end; a repeating timer behind schedule ran twice in one frame.
@makadore
makadore requested a review from roflmuffin as a code owner November 5, 2026 09:42
@roflmuffin
roflmuffin enabled auto-merge (squash) November 8, 2026 11:26
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