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

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1107
Author: @ambroseautomation
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: carry/old-9806-query-oom


📝 Commits (1)

  • 53c1c4c Keep query recording state consistent after allocation failure

📊 Changes

3 files changed (+105 additions, -1 deletions)

View changed files

📝 runtime/CMakeLists.txt (+2 -0)
📝 runtime/src/command_list.h (+8 -1)
➕ runtime/test/command_list_query_oom_test.cpp (+95 -0)

📄 Description

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)

🔄 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/1107 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `carry/old-9806-query-oom` --- ### 📝 Commits (1) - [`53c1c4c`](https://github.com/ubiquitarianism/leonida/commit/53c1c4c021bae80ce07e3d1cd8745e18a718acb1) Keep query recording state consistent after allocation failure ### 📊 Changes **3 files changed** (+105 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+2 -0) 📝 `runtime/src/command_list.h` (+8 -1) ➕ `runtime/test/command_list_query_oom_test.cpp` (+95 -0) </details> ### 📄 Description 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) --- <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#1141
No description provided.