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

Open
github-bot wants to merge 1 commit from github-bot/gh-2016 into main AGit
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-25 18:12 UTC · original
abnalstlll-byte:feat/rt-value-write-sink-guards-and-tests → main · +238 −1 · 3 files · 1 commits · open

Claimed in the coordination issue as: RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS (#1608)

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)

**@⁠abnalstlll-byte** on GitHub · 2026-11-25 18:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2016) `abnalstlll-byte:feat/rt-value-write-sink-guards-and-tests` → `main` · +238 −1 · 3 files · 1 commits · open Claimed in the coordination issue as: RT-VALUE-WRITE-SINK-GUARDS-AND-TESTS (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### 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)
Harden runtime/src/value_write_sink.h:
- 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() to reject null device pointers.
- 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.

AI-assisted (Claude Code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:14:51 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2016/head:github-bot/gh-2016'
git switch 'github-bot/gh-2016'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2016'
git switch 'github-bot/gh-2016'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2016'
git switch 'github-bot/gh-2016'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2016'
git switch 'main'
git merge --squash 'github-bot/gh-2016'
git switch 'main'
git merge --ff-only 'github-bot/gh-2016'
git switch 'main'
git merge 'github-bot/gh-2016'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.