pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting #2336

Open
github-bot wants to merge 1 commit from github-bot/gh-2336 into main AGit
Owner

@⁠narekshaghoyandev on GitHub · 2026-11-26 14:01 UTC · original
narekshaghoyandev:ubiq-pipeline-wait-window → main · +45 −1 · 2 files · 1 commits · open

Fixes window and signed-integer subtraction bugs in leonida::pipeline_wait::title_submitting() (runtime/src/pipeline_wait.h):

  • Return false immediately when within_ns <= 0 (previously, if another thread stored a timestamp slightly ahead of now_ns(), now_ns() - last was negative and < 0, returning true even for a zero/negative window).
  • Return false when last <= 0, avoiding signed 64-bit subtraction overflow UB (now_ns() - INT64_MIN).
  • Check now < last || now - last < within_ns so the subtraction only runs when now >= last > 0.
  • Added standalone unit test 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.cpp passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/pipeline_wait_test.cpp passed
  • Negative control: new test failed on line 24 (!title_submitting(0), exit 1) against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/src/pipeline_wait.h runtime/test/pipeline_wait_test.cpp clean

Claimed in the coordination issue as: RT-PIPELINE-WAIT-SIGNED-SUB-AND-WINDOW (#1608)
AI-assisted: yes (Gemini)

**@⁠narekshaghoyandev** on GitHub · 2026-11-26 14:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2336) `narekshaghoyandev:ubiq-pipeline-wait-window` → `main` · +45 −1 · 2 files · 1 commits · open Fixes window and signed-integer subtraction bugs in `leonida::pipeline_wait::title_submitting()` (`runtime/src/pipeline_wait.h`): - Return `false` immediately when `within_ns <= 0` (previously, if another thread stored a timestamp slightly ahead of `now_ns()`, `now_ns() - last` was negative and `< 0`, returning `true` even for a zero/negative window). - Return `false` when `last <= 0`, avoiding signed 64-bit subtraction overflow UB (`now_ns() - INT64_MIN`). - Check `now < last || now - last < within_ns` so the subtraction only runs when `now >= last > 0`. - Added standalone unit test `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.cpp` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/pipeline_wait_test.cpp` passed - Negative control: new test failed on line 24 (`!title_submitting(0)`, exit 1) against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/src/pipeline_wait.h runtime/test/pipeline_wait_test.cpp` clean Claimed in the coordination issue as: RT-PIPELINE-WAIT-SIGNED-SUB-AND-WINDOW (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) AI-assisted: yes (Gemini)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:08:04 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-26 15:37 UTC · original · reviewed

Compiled and ran pipeline_wait_test.cpp directly with GCC 11 and UBSan on Ubuntu/WSL. The boundary cases passed with no sanitizer report. Could you also register pipeline_wait_test with CTest? I found no build or test entry for the new file, so the normal suite currently skips it.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-26 15:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2336#pullrequestreview-6076880367) · **reviewed** Compiled and ran `pipeline_wait_test.cpp` directly with GCC 11 and UBSan on Ubuntu/WSL. The boundary cases passed with no sanitizer report. Could you also register `pipeline_wait_test` with CTest? I found no build or test entry for the new file, so the normal suite currently skips it. AI-assisted.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2336/head:github-bot/gh-2336'
git switch 'github-bot/gh-2336'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2336'
git switch 'github-bot/gh-2336'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2336'
git switch 'github-bot/gh-2336'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2336'
git switch 'main'
git merge --squash 'github-bot/gh-2336'
git switch 'main'
git merge --ff-only 'github-bot/gh-2336'
git switch 'main'
git merge 'github-bot/gh-2336'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.