pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting #2336
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2336"
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?
Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-26T14:01:57Z.
Fixes window and signed-integer subtraction bugs in
leonida::pipeline_wait::title_submitting()(runtime/src/pipeline_wait.h):falseimmediately whenwithin_ns <= 0(previously, if another thread stored a timestamp slightly ahead ofnow_ns(),now_ns() - lastwas negative and< 0, returningtrueeven for a zero/negative window).falsewhenlast <= 0, avoiding signed 64-bit subtraction overflow UB (now_ns() - INT64_MIN).now < last || now - last < within_nsso the subtraction only runs whennow >= last > 0.runtime/test/pipeline_wait_test.cpp.Verification
g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/pipeline_wait_test.cpppassedg++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/pipeline_wait_test.cpppassed!title_submitting(0), exit 1) against unmodifiedubiq/mainpython3 -I scripts/check_no_game_data.py runtime/src/pipeline_wait.h runtime/test/pipeline_wait_test.cppcleanClaimed in the coordination issue as: RT-PIPELINE-WAIT-SIGNED-SUB-AND-WINDOW (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194149264)
AI-assisted: yes (Gemini)
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T15:37:28Z.
Review: COMMENTED
Compiled and ran
pipeline_wait_test.cppdirectly with GCC 11 and UBSan on Ubuntu/WSL. The boundary cases passed with no sanitizer report. Could you also registerpipeline_wait_testwith CTest? I found no build or test entry for the new file, so the normal suite currently skips it.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:41:35Z.
#2336 | head
1be69fd56c(merged cleanly with maind48a957bb9) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(pipeline_wait|d3d12_mesh)$" --output-on-failure(LEONIDA_VK_VALIDATION=1,/W4 /WX /permissive- /EHsc /utf-8onpipeline_wait_test) | red on main:pipeline_waitfails atline 24: !title_submitting(0)(rc=8) | green on PR+main: 2/2 CTests pass (pipeline_waitpipeline_wait_test: okunder/W4 /WX+d3d12_mesh4096/4096pixels matched) on RTX 3090 with0Khronos validation errors;check_no_game_data.py0violations. Non-blocking note:runtime/test/pipeline_wait_test.cppis not yet registered viaadd_executable/add_testinruntime/CMakeLists.txt, so CTest will not build or run it automatically until wired up | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:02:15Z.
Verified by OreoFR
c1ecf04ed+ PR head1be69fd56; green run in a merge package of 16 PRs, no new ctest failure vs mainstandalone build of pipeline_wait_test.exe (the test is not registered in CMake)!title_submitting(0)AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:49:50Z.
Tested
1be69fd56merged (no commit) withmainaa918e5d9, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300.Blocker:
runtime/test/pipeline_wait_test.cppis new but is not registered inruntime/CMakeLists.txt, so neither CI norctestever builds or runs it.ctest -Non the merge lists no such test, andtests/test_ctest_registration.pystill passes, so nothing catches this. Registering it the way the other header-only tests are would fix that:Hand-compiled (
cl /std:c++20 /EHsc /O2):pipeline_wait_test: ok, exit 0.runtime/src/pipeline_wait.hback tomain:line 24: !title_submitting(0), exit 1.I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:28:06Z.
Review: COMMENTED
Static audit of head
1be69fd56only. I ran no builds, tests, or GPU workloads.The subtraction in
runtime/src/pipeline_wait.h:28is safe. A nonpositive window or stored timestamp returns false before the subtraction, covering a zero sentinel and a storedINT64_MIN. A positive stored timestamp ahead of the sampled time returns true by short-circuit, including when the sampled time isINT64_MIN. Otherwise,now >= last > 0bounds the difference to[0, INT64_MAX - 1]. The warm-up caller inruntime/shims/d3d12_vulkan_device.cppstill uses the default one-second window. The changed code and standalone test use standard C++ facilities shared by MSVC and Linux compilers.runtime/test/pipeline_wait_test.cpp:11in the portableBUILD_TESTINGblock ofruntime/CMakeLists.txtwithadd_executableandadd_test. The normal Windows and Linux CTest jobs currently skip the regression.runtime/test/pipeline_wait_test.cpp:23. The live clock lets the future assertion pass after the timestamp becomes recent, and the old-submission case can skip. A predicate with explicit inputs can pinnow < lastat the signed limits and verify both sides of the strict cutoff with elapsed times ofwindow - 1andwindow.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:26:00Z.
Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: pipeline_wait_test red on main (line 24), green with the PR. Note: the test is not registered in CMake. AI-assisted: yes.