Avoid overflow in Windows preparation timestamps #1517

Merged
klimovich008 merged 1 commit from codex/fix-windows-seed-time into main 2026-11-10 06:16:57 +00:00
klimovich008 commented 2026-11-10 05:50:05 +00:00 (Migrated from github.com)

What this fixes

On Windows, checking the prepared-shader stamp overflows signed 64-bit arithmetic in both FILETIME-to-nanosecond conversions. This removes undefined arithmetic at startup; no wrong preparation decision or game stutter was reproduced. Follow-up to #1387.

Why merge

  • Keep both Windows clocks in native 100 ns ticks and preserve the two-second safety window.
  • Old records hash once and rewrite through the existing path; the record layout, translator stamp and hash stay unchanged.
  • Linux clocks and preparation defaults stay unchanged.

Change

  • gpu/vk/vk_draw.cpp: remove both overflowing multiplications and express the Windows slack in ticks.
  • tests/test_prepare_seed_stamp.py: check the native Windows clocks, the safety window and migration of old records.

Tested

  • python -I -B tests/run_all.py --jobs 1 --strict prepare_seed_stamp with GCC on PATH: 1 passed, 0 skipped; real helpers, synthetic files and record migration.
  • Clang 23.1.5: fails on the old code, passes now. Repeated with signed-overflow UBSan: old code reports overflow; corrected code does not.
  • Windows 11, Ryzen 7 5700X3D, Clang 23.1.5: migration hashes once, then skips hashing. No game data is included.
  • Full Windows/Ubuntu source workflows and Linux/Windows renderer builds pass in CI.

Not covered

  • No GPU/game integration or stutter improvement is claimed.
## What this fixes On Windows, checking the prepared-shader stamp overflows signed 64-bit arithmetic in both FILETIME-to-nanosecond conversions. This removes undefined arithmetic at startup; no wrong preparation decision or game stutter was reproduced. Follow-up to #1387. ## Why merge - Keep both Windows clocks in native 100 ns ticks and preserve the two-second safety window. - Old records hash once and rewrite through the existing path; the record layout, translator stamp and hash stay unchanged. - Linux clocks and preparation defaults stay unchanged. ## Change - `gpu/vk/vk_draw.cpp`: remove both overflowing multiplications and express the Windows slack in ticks. - `tests/test_prepare_seed_stamp.py`: check the native Windows clocks, the safety window and migration of old records. ## Tested - `python -I -B tests/run_all.py --jobs 1 --strict prepare_seed_stamp` with GCC on PATH: 1 passed, 0 skipped; real helpers, synthetic files and record migration. - Clang 23.1.5: fails on the old code, passes now. Repeated with signed-overflow UBSan: old code reports overflow; corrected code does not. - Windows 11, Ryzen 7 5700X3D, Clang 23.1.5: migration hashes once, then skips hashing. No game data is included. - Full Windows/Ubuntu source workflows and Linux/Windows renderer builds pass in CI. ## Not covered - No GPU/game integration or stutter improvement is claimed.
Commenting is not possible because the repository is archived.
No description provided.