[PR #2061] runtime: guard empty destination and null data in write_pipeline_cache_file and add tests (RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS) #2067

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

📋 Pull Request Information

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

Base: main ← Head: feat/rt-pipeline-cache-file-guards-and-tests


📝 Commits (1)

  • ca0c72f runtime: guard empty destination and null data in write_pipeline_cache_file and add tests (RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS)

📊 Changes

2 files changed (+11 additions, -0 deletions)

View changed files

📝 runtime/src/pipeline_cache_file.h (+2 -0)
📝 runtime/test/pipeline_cache_file_test.cpp (+9 -0)

📄 Description

Claimed in the coordination issue as: RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS (claim)

What and why

runtime/src/pipeline_cache_file.h provides atomic, crash-safe checkpoint writes for the pipeline cache file via same-directory staging and renaming.

  1. Input guards:

    • write_pipeline_cache_file: returns std::errc::invalid_argument immediately if destination.empty() (preventing creation of orphan .tmp... files in the working directory) or if size > 0 && !data (preventing null pointer dereference in std::fwrite).
    • Safely allows writing an empty 0-byte file when size == 0 (even if data is null).
  2. Test suite extension (runtime/test/pipeline_cache_file_test.cpp):

    • Verifies destination.empty() returns std::errc::invalid_argument.
    • Verifies null buffer with positive size returns std::errc::invalid_argument.
    • Verifies writing 0 bytes with null data creates an empty file and succeeds.
    • Cleans up temporary test file to preserve directory file-count invariants.

Tested

  • Standalone test execution: pipeline_cache_file_test passes cleanly (exit 0).
  • 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/2061 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/rt-pipeline-cache-file-guards-and-tests` --- ### 📝 Commits (1) - [`ca0c72f`](https://github.com/ubiquitarianism/leonida/commit/ca0c72f810e143caba070386a28c8505ae78c013) runtime: guard empty destination and null data in write_pipeline_cache_file and add tests (RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS) ### 📊 Changes **2 files changed** (+11 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/pipeline_cache_file.h` (+2 -0) 📝 `runtime/test/pipeline_cache_file_test.cpp` (+9 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-PIPELINE-CACHE-FILE-GUARDS-AND-TESTS ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171974710)) ### What and why `runtime/src/pipeline_cache_file.h` provides atomic, crash-safe checkpoint writes for the pipeline cache file via same-directory staging and renaming. 1. **Input guards**: - `write_pipeline_cache_file`: returns `std::errc::invalid_argument` immediately if `destination.empty()` (preventing creation of orphan `.tmp...` files in the working directory) or if `size > 0 && !data` (preventing null pointer dereference in `std::fwrite`). - Safely allows writing an empty 0-byte file when `size == 0` (even if `data` is null). 2. **Test suite extension (`runtime/test/pipeline_cache_file_test.cpp`)**: - Verifies `destination.empty()` returns `std::errc::invalid_argument`. - Verifies null buffer with positive size returns `std::errc::invalid_argument`. - Verifies writing 0 bytes with null data creates an empty file and succeeds. - Cleans up temporary test file to preserve directory file-count invariants. ### Tested - Standalone test execution: `pipeline_cache_file_test` passes cleanly (exit 0). - `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#2067
No description provided.