dev_status: guard nullptr in Builds::name() #2313

Merged
narekshaghoyandev merged 1 commit from upstream-pr/2313 into main 2026-11-29 14:25:47 +00:00
narekshaghoyandev commented 2026-11-26 13:45:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-26T13:45:05Z.


Fixes a null-pointer dereference in leonida::dev_status::Builds::name(const char* text) (runtime/src/dev_status.h):

  • Previously, passing nullptr to Builds::name() (or constructing Build(nullptr)) called std::strlen(nullptr), causing immediate UB/SIGSEGV.
  • Guard if (!text) by clearing name_[0] = 0 and returning early.
  • Added standalone unit test runtime/test/dev_status_test.cpp.

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/dev_status_test.cpp passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/dev_status_test.cpp passed
  • Negative control: new test failed with UBSan null-argument + ASan SEGV against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/src/dev_status.h runtime/test/dev_status_test.cpp clean

Claimed in the coordination issue as: RT-DEV-STATUS-NULL-NAME (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193761192)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5511157449 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-26T13:45:05Z. --- Fixes a null-pointer dereference in `leonida::dev_status::Builds::name(const char* text)` (`runtime/src/dev_status.h`): - Previously, passing `nullptr` to `Builds::name()` (or constructing `Build(nullptr)`) called `std::strlen(nullptr)`, causing immediate UB/SIGSEGV. - Guard `if (!text)` by clearing `name_[0] = 0` and returning early. - Added standalone unit test `runtime/test/dev_status_test.cpp`. ### Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/dev_status_test.cpp` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/dev_status_test.cpp` passed - Negative control: new test failed with UBSan null-argument + ASan SEGV against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/src/dev_status.h runtime/test/dev_status_test.cpp` clean Claimed in the coordination issue as: RT-DEV-STATUS-NULL-NAME (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193761192) AI-assisted: yes (Gemini)
zmasi commented 2026-11-28 12:16:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:16:01Z.


VERIFY-2313 — verified head 9ec18b2b87 merged cleanly with main d48a957bb on Windows 11 Pro (build 26200), MSVC 19.44 (x64, /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc), synthetic build-status names only.

Red (main d48a957bb) -> Green (d48a957bb + 9ec18b2b87)

  • Red on main:
    • Compiling and running runtime/test/dev_status_test.cpp against main's runtime/src/dev_status.h -> crashed with 0xC0000005 (STATUS_ACCESS_VIOLATION) calling std::strlen(nullptr) inside Builds::name(nullptr).
  • Green on merged PR:
    • cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc /I"runtime/src" runtime/test/dev_status_test.cpp -> 0 warnings, exit 0 (dev_status_test: ok).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239108305 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313#issuecomment-7239108305). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T12:16:01Z. --- `VERIFY-2313` — verified head `9ec18b2b87` merged cleanly with `main` `d48a957bb` on Windows 11 Pro (build 26200), MSVC `19.44` (`x64`, `/std:c++20 /W4 /WX /permissive- /utf-8 /EHsc`), synthetic build-status names only. ### Red (`main` `d48a957bb`) -> Green (`d48a957bb` + `9ec18b2b87`) - **Red on `main`**: - Compiling and running `runtime/test/dev_status_test.cpp` against `main`'s `runtime/src/dev_status.h` -> crashed with **`0xC0000005` (`STATUS_ACCESS_VIOLATION`)** calling `std::strlen(nullptr)` inside `Builds::name(nullptr)`. - **Green on merged PR**: - `cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc /I"runtime/src" runtime/test/dev_status_test.cpp` -> **0 warnings**, exit **`0`** (`dev_status_test: ok`). AI-assisted.
OreoFR commented 2026-11-28 22:01:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:01:58Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 9ec18b2b8; green run in a merge package of 16 PRs, no new ctest failure vs main
  • Test: standalone build of dev_status_test.exe (the test is not registered in CMake)
  • Red on main: crash 0xC0000005 (nullptr in Builds::name)
  • Green with the PR: OK
  • Verdict: READY (the test is not in CMake: ctest will never run it)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246447509 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313#issuecomment-7246447509). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:01:58Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `9ec18b2b8`; green run in a merge package of 16 PRs, no new ctest failure vs main - Test: `standalone build of dev_status_test.exe (the test is not registered in CMake)` - Red on main: crash 0xC0000005 (nullptr in Builds::name) - Green with the PR: OK - Verdict: READY (the test is not in CMake: ctest will never run it) - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
TheGeogeo commented 2026-11-28 22:49:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T22:49:48Z.


Tested 9ec18b2b8 merged (no commit) with main aa918e5d9, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300.

Blocker: runtime/test/dev_status_test.cpp is new but is not registered in runtime/CMakeLists.txt, so neither CI nor ctest ever builds or runs it. ctest -N on the merge lists no such test, and tests/test_ctest_registration.py still passes, so nothing catches this. Registering it the way the other header-only tests are would fix that:

add_executable(dev_status_test test/dev_status_test.cpp)
add_test(NAME dev_status COMMAND dev_status_test)

Hand-compiled (cl /std:c++20 /EHsc /O2):

  • Green: dev_status_test: ok, exit 0.
  • Red, with runtime/src/dev_status.h back to main: crash, exit 0xC0000005.

I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247011954 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313#issuecomment-7247011954). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T22:49:48Z. --- Tested `9ec18b2b8` merged (no commit) with `main` `aa918e5d9`, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300. **Blocker:** `runtime/test/dev_status_test.cpp` is new but is not registered in `runtime/CMakeLists.txt`, so neither CI nor `ctest` ever builds or runs it. `ctest -N` on the merge lists no such test, and `tests/test_ctest_registration.py` still passes, so nothing catches this. Registering it the way the other header-only tests are would fix that: ```cmake add_executable(dev_status_test test/dev_status_test.cpp) add_test(NAME dev_status COMMAND dev_status_test) ``` Hand-compiled (`cl /std:c++20 /EHsc /O2`): - Green: `dev_status_test: ok`, exit 0. - Red, with `runtime/src/dev_status.h` back to `main`: crash, exit `0xC0000005`. I did not run the ctest tests relinked by the header change: test runs on this machine are paused for memory. AI-assisted (Claude Code).
timbot103 commented 2026-11-29 04:29:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T04:29:13Z.

Review: COMMENTED


Static audit of head 9ec18b2b8 only. No builds, tests, or GPU runs.

The guard in runtime/src/dev_status.h:23 clears the buffer while holding the mutex. last() copies the name into an owning std::string under that mutex, and runtime/src/dev_overlay.h can format the empty result. The guard and standalone test use standard C++ facilities.

  • runtime/test/dev_status_test.cpp:23 — The Windows and Linux runtime jobs build the CMake targets and run CTest. This source has no target or CTest entry, and the existing dev_overlay test only passes non-null names. A future removal of the guard would escape those checks. Please register the test in runtime/CMakeLists.txt or add the two null-input cases to runtime/test/dev_overlay_test.cpp.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6101401456 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313#pullrequestreview-6101401456). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T04:29:13Z. **Review:** COMMENTED --- Static audit of head `9ec18b2b8` only. No builds, tests, or GPU runs. The guard in `runtime/src/dev_status.h:23` clears the buffer while holding the mutex. `last()` copies the name into an owning `std::string` under that mutex, and `runtime/src/dev_overlay.h` can format the empty result. The guard and standalone test use standard C++ facilities. - `runtime/test/dev_status_test.cpp:23` — The Windows and Linux runtime jobs build the CMake targets and run CTest. This source has no target or CTest entry, and the existing `dev_overlay` test only passes non-null names. A future removal of the guard would escape those checks. Please register the test in `runtime/CMakeLists.txt` or add the two null-input cases to `runtime/test/dev_overlay_test.cpp`. AI-assisted.
MoonEyes commented 2026-11-29 14:25:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:25:50Z.


Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: dev_status_test red on main (crash 0xC0000005), green with the PR. Note: the test is not registered in CMake, so ctest does not run it. AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257296743 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2313#issuecomment-7257296743). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:25:50Z. --- Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: dev_status_test red on main (crash 0xC0000005), green with the PR. Note: the test is not registered in CMake, so ctest does not run it. AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2313
No description provided.