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

Merged
leonida/mandy
narekshaghoyandev merged 1 commit from ubiq-dev-status-null-name into main 2026-11-29 14:25:47 +00:00

Pull request successfully merged and closed

narekshaghoyandev commented 2026-11-26 13:45:05 +00:00

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)

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

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.

`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

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).

**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

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).

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 reviewed 2026-11-29 04:29:13 +00:00
timbot103 left a comment
No description provided.
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

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.

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 description provided.