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

[Bug]: Timer period modifications may violate invariants of TimerManager::base_timer_sorter std::set sorting #12509

Closed
JGRennison opened this issue Apr 17, 2024 · 0 comments

Comments

@JGRennison
Copy link
Contributor

Version of OpenTTD

master

Expected result

Invariants are always maintained, etc

Actual result

TimeoutTimer::Reset(const TPeriod timeout), IntervalTimer::SetInterval and savegame load of _new_competitor_timeout.period can directly change the BaseTimer::period field of timers which are already in the TimerManager std::set, which uses TimerManager::base_timer_sorter. This can violate the ordering invariants of std::set, which may result in undefined behaviour.

Steps to reproduce

See src/timer/.

JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Apr 20, 2024
Use this as the primary sort key for TimerGameTick::TPeriod,
to avoid container sort order changes on timer period saveload.
See: OpenTTD#12509
JGRennison added a commit to JGRennison/Upstream-OpenTTD that referenced this issue Apr 20, 2024
JGRennison added a commit to JGRennison/OpenTTD-patches that referenced this issue Apr 21, 2024
rubidium42 pushed a commit that referenced this issue Apr 25, 2024
Use this as the primary sort key for TimerGameTick::TPeriod,
to avoid container sort order changes on timer period saveload.
See: #12509
PeterN pushed a commit to PeterN/OpenTTD that referenced this issue Apr 30, 2024
Use this as the primary sort key for TimerGameTick::TPeriod,
to avoid container sort order changes on timer period saveload.
See: OpenTTD#12509
PeterN pushed a commit that referenced this issue Apr 30, 2024
Use this as the primary sort key for TimerGameTick::TPeriod,
to avoid container sort order changes on timer period saveload.
See: #12509
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

No branches or pull requests

1 participant