mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:50:53 +01:00
[PR #831] [MERGED] runtime: map early OS ERROR_TIMEOUT to _Timedout in _Cnd_timedwait_for_unchecked (RT-CRT-TIMED-WAIT-EARLY-TIMEOUT) #869
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#869
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/831
Author: @Maticcm
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @aslan2142
Base:
main← Head:fix/crt-timed-wait-early-timeout📝 Commits (1)
bc9d0a5runtime: map early OS ERROR_TIMEOUT to _Timedout in _Cnd_timedwait_for_unchecked📊 Changes
2 files changed (+92 additions, -4 deletions)
View changed files
📝
runtime/src/crt_timed_wait.cpp(+25 -4)📝
runtime/test/crt_timed_wait_test.cpp(+67 -0)📄 Description
Claimed in the coordination issue as: RT-CRT-TIMED-WAIT-EARLY-TIMEOUT
What and why
Fixes intermittent
crt_timed_waitfailures on Windows wherestd::condition_variable::wait_forwithout a predicate returnedstd::cv_status::no_timeoutearly (observed at 199–200 ms on a 200 ms wait, failing in baseline-j 8CTest and in 2/10 standalone runs on Windows 11).runtime/src/crt_timed_wait.cppimplements_Cnd_timedwait_for_uncheckedviamsvcp140.dll!_Cnd_timedwaitagainst aTIME_UTCdeadline. Insidemsvcp140.dll, ifSleepConditionVariableSRWtimes out (ERROR_TIMEOUT) even a fraction of a millisecond beforetarget,_Xtime_diff_to_millis2(target, &now)is still non-zero, so_Cnd_timedwaitreturns_Thrd_result::_Success. MSVC STL'sstd::condition_variable::wait_for(<condition_variable>) treats_Successas a notification/spurious wake and returnscv_status::no_timeoutinstead of checkingsteady_clock::now() < _Targetand waiting out the deadline.timedwait_for_implnow saves and clearsLastErroraround_Cnd_timedwait(restoring the caller'sLastErrorafterwards) and maps_Thrd_result::_Successwithwait_error == ERROR_TIMEOUTback to_Thrd_result::_Timedoutfor_Cnd_timedwait_for_unchecked, while preserving checked semantics for_Cnd_timedwait_for. Added regression tests inruntime/test/crt_timed_wait_test.cppcovering 25 consecutive 10 ms unnotifiedwait_forcalls, pre-existingERROR_TIMEOUTacross a notified wait, andLastErrorpreservation on timeout.Tested
scripts\build_runtime.ps1(MSVC 19.50.35729.0, Windows SDK 10.0.26100.0, RelWithDebInfo):[260/260]incremental targets built cleanly (0 errors, 0 warnings).runtime\build\crt_timed_wait_test.exex 25 consecutive runs:25/25passed (RESULT: PASS, exit 0).ctest --test-dir runtime/build -R "crt_timed_wait|vk_fence|d3d12_fence|d3d12_queue_wait|frame_pacer|xtaskqueue" --output-on-failure:10/10passed (100%).python -I scripts/check_no_game_data.py runtime/src/crt_timed_wait.cpp runtime/test/crt_timed_wait_test.cpp:ok (2 file(s)).python -m compileall -q make_game.py tools tests: exit 0.GPUs tested: NVIDIA GeForce RTX 3080, driver 630.20, Windows 11 (CPU/CRT runtime change)
AI-assisted: yes
Known limitations: Tested on native Windows 11; preserves the
msvcp140.dll!_Cnd_timedwaitpath for Wine 9 compatibility without touching_Mtx_t, not yet re-run under Wine 9 locally.Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator changes)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.