[PR #2016] runtime: guard null and invalid sizes in value_write_sink and add unit tests (RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS) #2021

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

📋 Pull Request Information

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

Base: main ← Head: feat/rt-value-write-sink-guards-and-tests


📝 Commits (1)

  • 804f974 runtime: guard null and invalid sizes in value_write_sink and add unit tests (RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS)

📊 Changes

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

View changed files

📝 runtime/CMakeLists.txt (+7 -0)
📝 runtime/src/value_write_sink.h (+12 -1)
➕ runtime/test/value_write_sink_test.cpp (+219 -0)

📄 Description

Claimed in the coordination issue as: RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170514927)

What and why

Harden runtime/src/value_write_sink.h and provide unit test coverage:

  • Guard arena() against null buffer pointers and non-4/8-byte sizes by immediately returning Landing::refused, preventing null dereference and invalid writes.
  • Guard title_pages() against null addresses, null bytes, and zero size by returning false immediately.
  • Guard clear_arena() against null device pointers (!device).
  • Add clear_title_pages() and reset_for_test() to allow clean state resets across tests and teardown.
  • Add portable CPU-only CTest unit test runtime/test/value_write_sink_test.cpp verifying initial state, guards, arena and title_pages dispatch, device-matched clearing, and multi-threaded concurrency.

Tested

  • g++ -std=c++20 -Wall -Wextra runtime/test/value_write_sink_test.cpp -> builds cleanly, runs and exits 0 (OK: value_write_sink_test passed all checks).
  • python -I tests/test_ci_registration.py -> Ran 16 tests in 4.676s, OK.
  • python -I tests/test_text_write_line_endings.py -> Ran 3 tests in 11.795s, OK.
  • python -I scripts/check_no_game_data.py runtime/src/value_write_sink.h runtime/test/value_write_sink_test.cpp runtime/CMakeLists.txt -> exit 0.
  • git diff --check -> clean.

Tested on Windows 11 x64 (GCC C++20 / Python 3.12, stdlib tests, no game data needed).
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/2016 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/rt-value-write-sink-guards-and-tests` --- ### 📝 Commits (1) - [`804f974`](https://github.com/ubiquitarianism/leonida/commit/804f97479f90e04f9f48b1750e6831ea263ae731) runtime: guard null and invalid sizes in value_write_sink and add unit tests (RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS) ### 📊 Changes **3 files changed** (+238 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+7 -0) 📝 `runtime/src/value_write_sink.h` (+12 -1) ➕ `runtime/test/value_write_sink_test.cpp` (+219 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7170514927) ### What and why Harden `runtime/src/value_write_sink.h` and provide unit test coverage: - Guard `arena()` against null buffer pointers and non-4/8-byte sizes by immediately returning `Landing::refused`, preventing null dereference and invalid writes. - Guard `title_pages()` against null addresses, null bytes, and zero size by returning `false` immediately. - Guard `clear_arena()` against null device pointers (`!device`). - Add `clear_title_pages()` and `reset_for_test()` to allow clean state resets across tests and teardown. - Add portable CPU-only CTest unit test `runtime/test/value_write_sink_test.cpp` verifying initial state, guards, arena and title_pages dispatch, device-matched clearing, and multi-threaded concurrency. ### Tested - `g++ -std=c++20 -Wall -Wextra runtime/test/value_write_sink_test.cpp` -> builds cleanly, runs and exits 0 (`OK: value_write_sink_test passed all checks`). - `python -I tests/test_ci_registration.py` -> `Ran 16 tests in 4.676s`, `OK`. - `python -I tests/test_text_write_line_endings.py` -> `Ran 3 tests in 11.795s`, `OK`. - `python -I scripts/check_no_game_data.py runtime/src/value_write_sink.h runtime/test/value_write_sink_test.cpp runtime/CMakeLists.txt` -> `exit 0`. - `git diff --check` -> `clean`. Tested on Windows 11 x64 (GCC C++20 / Python 3.12, stdlib tests, no game data needed). 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#2021
No description provided.