[PR #2057] runtime: guard null bind callbacks, add owner accessor and unit test suite for DeferredImageBinding (RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS) #2062

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2057
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/rt-deferred-image-binding-guards-and-tests


📝 Commits (1)

  • 14e1a35 runtime: guard null bind callbacks, add owner accessor and unit test suite for DeferredImageBinding (RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS)

📊 Changes

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

View changed files

📝 runtime/CMakeLists.txt (+5 -0)
📝 runtime/src/deferred_image_binding.h (+2 -1)
➕ runtime/test/deferred_image_binding_test.cpp (+144 -0)

📄 Description

Claimed in the coordination issue as: RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS (claim)

What and why

runtime/src/deferred_image_binding.h synchronizes deferred single-time image memory binding across concurrent calls (e.g. from command replay and descriptor table creation).

  1. Null callback guard:

    • ensure(): guards against null bind_ function pointer (if (!bind_ || !bind_(owner_)) return false;), returning false safely instead of crashing.
  2. Owner query helper:

    • Added owner() accessor returning owner_.
  3. Unit test suite (runtime/test/deferred_image_binding_test.cpp):

    • 28 assertions verifying:
      • Initial state (bound() == false, owner() == target).
      • Null callback handling (returns false, leaves bound() == false).
      • Failed bind retry semantics (retries on failure without latching bound_).
      • Latching on success (bound() == true).
      • Idempotency (subsequent calls return true immediately without re-invoking callback).
      • Null owner pointer handling.
      • Multithreaded race synchronization (16 concurrent threads calling ensure() simultaneously; callback executes exactly once, all threads succeed).
      • Independent instances isolation.

Registers deferred_image_binding_test and CTest in runtime/CMakeLists.txt.

Tested

  • Unit test execution: 28/28 checks passed (0 failures).
  • python -I tests/test_ci_registration.py: 16/16 pass.
  • python -I tests/test_text_write_line_endings.py: 3/3 pass.
  • python -I scripts/check_no_game_data.py: clean (0 violations, no game data).

AI-assisted (Claude Code)


🔄 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/2057 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/rt-deferred-image-binding-guards-and-tests` --- ### 📝 Commits (1) - [`14e1a35`](https://github.com/ubiquitarianism/leonida/commit/14e1a352c445aef86d4cd0eca0444565a07f67ca) runtime: guard null bind callbacks, add owner accessor and unit test suite for DeferredImageBinding (RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS) ### 📊 Changes **3 files changed** (+151 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+5 -0) 📝 `runtime/src/deferred_image_binding.h` (+2 -1) ➕ `runtime/test/deferred_image_binding_test.cpp` (+144 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171856623)) ### What and why `runtime/src/deferred_image_binding.h` synchronizes deferred single-time image memory binding across concurrent calls (e.g. from command replay and descriptor table creation). 1. **Null callback guard**: - `ensure()`: guards against null `bind_` function pointer (`if (!bind_ || !bind_(owner_)) return false;`), returning false safely instead of crashing. 2. **Owner query helper**: - Added `owner()` accessor returning `owner_`. 3. **Unit test suite (`runtime/test/deferred_image_binding_test.cpp`)**: - 28 assertions verifying: - Initial state (`bound() == false`, `owner() == target`). - Null callback handling (returns false, leaves `bound() == false`). - Failed bind retry semantics (retries on failure without latching `bound_`). - Latching on success (`bound() == true`). - Idempotency (subsequent calls return true immediately without re-invoking callback). - Null owner pointer handling. - Multithreaded race synchronization (16 concurrent threads calling `ensure()` simultaneously; callback executes exactly once, all threads succeed). - Independent instances isolation. Registers `deferred_image_binding_test` and CTest in `runtime/CMakeLists.txt`. ### Tested - Unit test execution: `28/28 checks passed` (0 failures). - `python -I tests/test_ci_registration.py`: 16/16 pass. - `python -I tests/test_text_write_line_endings.py`: 3/3 pass. - `python -I scripts/check_no_game_data.py`: clean (0 violations, no game data). AI-assisted (Claude Code) --- <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#2062
No description provided.