[PR #2336] pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting #2340

Open
opened 2026-11-26 21:20:53 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2336
Author: @narekshaghoyandev
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: ubiq-pipeline-wait-window


📝 Commits (1)

  • 1be69fd pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting

📊 Changes

2 files changed (+45 additions, -1 deletions)

View changed files

📝 runtime/src/pipeline_wait.h (+4 -1)
➕ runtime/test/pipeline_wait_test.cpp (+41 -0)

📄 Description

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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194149264)
AI-assisted: yes (Gemini)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2336 **Author:** [@narekshaghoyandev](https://github.com/narekshaghoyandev) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `ubiq-pipeline-wait-window` --- ### 📝 Commits (1) - [`1be69fd`](https://github.com/ubiquitarianism/leonida/commit/1be69fd56c1dbe4e6816f8c373417e5e5e30a621) pipeline_wait: guard non-positive window and signed subtraction overflow in title_submitting ### 📊 Changes **2 files changed** (+45 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/pipeline_wait.h` (+4 -1) ➕ `runtime/test/pipeline_wait_test.cpp` (+41 -0) </details> ### 📄 Description 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://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194149264) AI-assisted: yes (Gemini) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2340
No description provided.