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

Merged
leonida/mandy
abnalstlll-byte merged 1 commit from feat/rt-value-write-sink-guards-and-tests into main 2026-11-30 17:15:20 +00:00

Pull request successfully merged and closed

abnalstlll-byte commented 2026-11-25 18:12:19 +00:00

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)

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)
MoonEyes commented 2026-11-28 02:48:45 +00:00

Hi @abnalstlll-byte, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/CMakeLists.txt), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

Hi @abnalstlll-byte, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/CMakeLists.txt`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
OreoFR commented 2026-11-30 13:40:32 +00:00

Carried as #2735 because of the conflict with main after #2566; @abnalstlll-byte, if you come back, say so and the carry is dropped.

Carried as #2735 because of the conflict with main after #2566; @abnalstlll-byte, if you come back, say so and the carry is dropped.
Sign in to join this conversation.
No description provided.