runtime: keep query recording state consistent after allocation failure (OLD-9806) #1107

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1107 into main
ambroseautomation commented 2026-11-24 18:37:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T18:37:18Z.


Claimed in the coordination issue as: OLD-9806 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140880997)

What and why

Carries forward old-pr/9806 (draft #79, original commit author WebIdentity1 preserved; indexed in #17), rebased cleanly onto current main (71f99e224).

Fixes strong exception safety in CommandList::begin_query and CommandList::end_query (runtime/src/command_list.h):

  • begin_query: rolls back active_.pop_back() if append(query) throws (e.g., std::bad_alloc), preventing a leaked active-query entry that would permanently block close() or retrying the query.
  • end_query: calls append(query) before erasing the entry from active_, so an allocation failure leaves the query active and retryable.
  • Adds runtime/test/command_list_query_oom_test.cpp and registers command_list_query_oom in runtime/CMakeLists.txt.

Tested

  • Compiled and ran command_list_query_oom_test.exe natively on Windows 11 with MSVC (/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2): exit 0, zero compiler warnings.
  • Compiled and ran command_list_test.exe with the same flags: exit 0, zero compiler warnings.
  • python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/src/command_list.h runtime/test/command_list_query_oom_test.cpp: exit 0 (no game data).

GPUs tested: n/a (CPU-only command-list IR test; built and tested on Windows 11 Pro 64-bit, MSVC VS 18)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — runtime command-list IR)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478129893 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1107). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T18:37:18Z. --- Claimed in the coordination issue as: OLD-9806 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140880997) ### What and why Carries forward `old-pr/9806` (draft #79, original commit author `WebIdentity1` preserved; indexed in #17), rebased cleanly onto current `main` (`71f99e224`). Fixes strong exception safety in `CommandList::begin_query` and `CommandList::end_query` (`runtime/src/command_list.h`): - `begin_query`: rolls back `active_.pop_back()` if `append(query)` throws (e.g., `std::bad_alloc`), preventing a leaked active-query entry that would permanently block `close()` or retrying the query. - `end_query`: calls `append(query)` before erasing the entry from `active_`, so an allocation failure leaves the query active and retryable. - Adds `runtime/test/command_list_query_oom_test.cpp` and registers `command_list_query_oom` in `runtime/CMakeLists.txt`. ### Tested - Compiled and ran `command_list_query_oom_test.exe` natively on Windows 11 with MSVC (`/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`): exit 0, zero compiler warnings. - Compiled and ran `command_list_test.exe` with the same flags: exit 0, zero compiler warnings. - `python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/src/command_list.h runtime/test/command_list_query_oom_test.cpp`: exit 0 (no game data). GPUs tested: n/a (CPU-only command-list IR test; built and tested on Windows 11 Pro 64-bit, MSVC VS 18) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — runtime command-list IR)
abnalstlll-byte commented 2026-11-24 18:38:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:38:51Z.

Review: APPROVED


Audited and verified. Guarantees strong exception safety in CommandList::begin_query and end_query by rolling back ctive_ state on allocation failure. Unit tests in
untime/test/command_list_query_oom_test.cpp verify fault injection behavior. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045188756 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1107#pullrequestreview-6045188756). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:38:51Z. **Review:** APPROVED --- Audited and verified. Guarantees strong exception safety in CommandList::begin_query and end_query by rolling back ctive_ state on allocation failure. Unit tests in untime/test/command_list_query_oom_test.cpp verify fault injection behavior. Approved.
madhyn commented 2026-11-24 19:35:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T19:35:58Z.


Tested 53c1c4c02 on Arch Linux:

  • ctest --test-dir runtime/build/linux -R "^(command_list_query_oom|command_list)$" --output-on-failure: 2/2 passed (0.00 s)

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7142326727 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1107#issuecomment-7142326727). Originally posted by [madhyn](https://github.com/madhyn) on 2026-11-24T19:35:58Z. --- Tested `53c1c4c02` on Arch Linux: - `ctest --test-dir runtime/build/linux -R "^(command_list_query_oom|command_list)$" --output-on-failure`: **2/2 passed** (0.00 s) AI-assisted: yes
Deedlyy commented 2026-11-24 20:17:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:17:16Z.


Recommendation: [MERGE]

Reasoning: Carries #79: strong exception safety in CommandList::begin_query/end_query, so a bad_alloc during append no longer leaves a dangling active query that blocks close(). Small change (+8/-1) with a dedicated OOM test. Verified on Linux by madhyn. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143308464 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1107#issuecomment-7143308464). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:17:16Z. --- **Recommendation:** [MERGE] **Reasoning:** Carries #79: strong exception safety in `CommandList::begin_query`/`end_query`, so a `bad_alloc` during append no longer leaves a dangling active query that blocks `close()`. Small change (+8/-1) with a dedicated OOM test. Verified on Linux by madhyn. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 3/10

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1107
No description provided.