indirect_draw_stats: guard null FILE* in report and out-of-range Event in note/skip #2309
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2309
Loading…
Reference in a new issue
No description provided.
Delete branch "ubiq-indirect-draw-stats-guards"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Fixes null-pointer and out-of-bounds bugs in
runtime/src/indirect_draw_stats.h:Counts::report(std::FILE* out)againstout == nullptrbefore callingstd::fprintf(out, ...).static_cast<unsigned>(event) < 4uinnote(Event)andskip(Event, Reason)so an out-of-rangeEventcannot index pastCounts::values[4]or record a stray reason skip.runtime/test/indirect_draw_stats_test.cpp.Verification
g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpppassedg++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic -Iruntime/src runtime/test/indirect_draw_stats_test.cpppassedubiq/mainpython3 -I scripts/check_no_game_data.py runtime/src/indirect_draw_stats.h runtime/test/indirect_draw_stats_test.cppcleanClaimed in the coordination issue as: RT-INDIRECT-DRAW-STATS-BOUNDS-AND-NULL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193658432)
AI-assisted: yes (Gemini)
VERIFY-2309— verified head25aed3fcb1merged cleanly withmaind48a957bbon Windows 11 Pro (build 26200), MSVC19.44(x64,/std:c++20 /W4 /WX /permissive- /utf-8 /EHsc), synthetic indirect-draw counters only.Red (
maind48a957bb) -> Green (d48a957bb+25aed3fcb1)main:runtime/test/indirect_draw_stats_test.cppagainstmain'sruntime/src/indirect_draw_stats.h-> FAILED with0xC0000409(STATUS_STACK_BUFFER_OVERRUN/ UCRT invalid-parameter fastfail) whenlocal.report(nullptr)passed a nullFILE*tostd::fprintf.cl.exe /nologo /std:c++20 /W4 /WX /permissive- /utf-8 /EHsc /I"runtime/src" runtime/test/indirect_draw_stats_test.cpp-> 0 warnings, exit0(indirect_draw_stats_test: ok), confirming bothreport(nullptr)no-op behavior and out-of-rangeEvent(>= 4) bounds guards innote()/skip().runtime/test/indirect_draw_stats_test.cppusesstd::tmpfile(), which on Windows UCRT opens a file in the root of the current working drive (passes on writable non-system drives, though non-elevated runs rooted on a protected system drive root can getnullptr).AI-assisted.
Verified by OreoFR
c1ecf04ed+ PR head25aed3fcb; green run in a merge package of 16 PRs, no new ctest failure vs mainstandalone build of indirect_draw_stats_test.exe (the test is not registered in CMake)AI-assisted (Claude Code, Claude Opus 5.5).
Tested
25aed3fcbmerged (no commit) withmainaa918e5d9, MSVC 19.52 (Visual Studio 18), Windows 11 10.0.26300.Blocker:
runtime/test/indirect_draw_stats_test.cppis new but is not registered inruntime/CMakeLists.txt, so neither CI norctestever builds or runs it.ctest -Non the merge lists no such test, andtests/test_ctest_registration.pystill passes, so nothing catches this. Registering it the way the other header-only tests are would fix that:Hand-compiled (
cl /std:c++20 /EHsc /O2):indirect_draw_stats_test: ok, exit 0.runtime/src/indirect_draw_stats.hback tomain: crash, exit0xC0000409.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).
Merged. Tested by OreoFR (RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11) on this head: indirect_draw_stats_test red on main (crash 0xC0000409), green with the PR. Note: the test is not registered in CMake. AI-assisted: yes.