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

Closed
leonida/mandy
ambroseautomation wants to merge 0 commits from carry/old-9806-query-oom into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

ambroseautomation commented 2026-11-24 18:37:18 +00:00

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)
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 approved these changes 2026-11-24 18:38:51 +00:00
abnalstlll-byte left a comment

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.

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

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

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

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

**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
Sign in to join this conversation.
No description provided.