mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:55:52 +01:00
[PR #1971] runtime: wake blocked waiters in FramePacer::set_uncapped() and prevent timeout/clock overflow #1978
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1978
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1971
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-frame-pacer-uncap-wake-and-overflow📝 Commits (1)
943e37cruntime: wake blocked waiters on set_uncapped() and avoid timeout/clock overflow in frame_pacer📊 Changes
2 files changed (+71 additions, -5 deletions)
View changed files
📝
runtime/src/frame_pacer.h(+22 -5)📝
runtime/test/frame_pacer_test.cpp(+49 -0)📄 Description
Claim:
RT-FRAME-PACER-UNCAP-WAKE-AND-OVERFLOW(claim comment#7168928060on #1608).Fixes (
runtime/src/frame_pacer.h)FramePacer::set_uncapped(): previouslyset_uncapped()only flippeduncapped_without callingcv_.notify_all(), leaving any thread already blocked insidewait_frame_event()(e.g. withinfinite_timeout_mson the vblank grid or latency throttle) stuck until the next vblank or timeout.give_uptimeout arithmetic inwait_locked(): previouslystart + std::uint64_t(timeout_ms) * 1000could wrapuint64_twhenstartis large, settinggive_up < startand causing an immediate false timeout. Now saturates cleanly atno_deadline.int64_t/time_pointoverflow inSteadyFrameClock::wait(): previouslystart_ + std::chrono::microseconds(deadline_us)converted an unsigneduint64_tdirectly to signedstd::chrono::microseconds::rep(int64_t), wrapping negative fordeadline_us > INT64_MAXand spinning immediately. Now computes a relative remaining duration bounded to 24 hours percv.wait_for()call (matching theFrameClock::waitcontract where callers loop on wake).Verification
CMakeLists.txtchanges).runtime/test/frame_pacer_test.cppwith three new tests:set_uncapped(true)waking a thread blocked oninfinite_timeout_ms, saturating timeout nearUINT64_MAX, andSteadyFrameClock::wait()with a> INT64_MAXdeadline blocking cleanly until notified.frame_pacer_testcleanly under:clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror -pthreadclang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror -pthreadclang++ -std=c++20 -O2 -Wall -Wextra -Werror -pthreadpython3 -I scripts/check_no_game_data.pyon both files andpython3 -I tests/test_text_write_line_endings.py: all passed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.