Repository navigation
arena_size: a negative LEONIDA_ARENA_MB clamps to the 16 MiB floor, not the 4095 MiB maximum (ARENA-NEGATIVE-MB) - #923
Conversation
…or (ARENA-NEGATIVE-MB)
strtoull("-5") wraps to 2^64-5, so decide_arena_size clamped it to the
4095 MiB maximum. strtoll clamps "-5" and "-99999999999999999999" to the
16 MiB floor, as the header comment documents.
Adds checks for "-5", the huge negative and the huge positive to
arena_size_test. Other inputs keep their results.
KernelSmoker
left a comment
There was a problem hiding this comment.
Reviewed exact head 49e6392c9e6ee45cfce8ef7b690aaa7fc223ce0d. Parsing LEONIDA_ARENA_MB as signed prevents negative values from wrapping through strtoull; clamping occurs in MiB bounds before conversion to VkDeviceSize, and overflow values still clamp to the documented floor/ceiling. The added negative and overflow cases cover the regression. I built and ran runtime/test/arena_size_test.cpp in the Fedora 45 tool container using GCC 16 with -std=c++20 -Wall -Wextra -Werror -pedantic; it passed and printed the expected summary. I could not independently link the sanitizer variant because this tool image lacks libubsan; this is an environment limitation. No GPU/game data used.
|
Merging. Why merged: ARENA-NEGATIVE-MB: LEONIDA_ARENA_MB is parsed with strtoll, so a negative value clamps to the 16 MiB floor instead of wrapping around to the 4095 MiB maximum. KernelSmoker approved this exact head. Why it's good: A 3-line parse change. arena_size passes both plain and under validation. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 66d4f5a, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main 6261ca9: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5). |
Claimed in the coordination issue as: ARENA-NEGATIVE-MB (#14 (comment))
What was wrong
runtime/src/arena_size.h:63parsedLEONIDA_ARENA_MBwithstd::strtoull. A negative number wraps to a hugeunsigned value, so
std::clampreturned the 4095 MiB maximum. The header comment documents a clamp to 16..4095 MiB,and a negative number should reach the 16 MiB floor.
Reproduction on
origin/main(g++ 16,-std=c++20 -fsanitize=address,undefined, a probe callingdecide_arena_sizewith an emptyArenaLimits):What changed
runtime/src/arena_size.h: parse withstd::strtolland clamp as a signed value before converting toVkDeviceSize. Negative text now reaches the 16 MiB floor. Every other input keeps its result.runtime/test/arena_size_test.cpp: three new checks inrequest_without_limits:"-5"gives 16 MiB,"-99999999999999999999"gives 16 MiB,"99999999999999999999"gives 4095 MiB.Tested
g++ -std=c++20 -Wall -Wextra -fsanitize=address,undefined -I runtime/src -I <dir with vulkan/ and vk_video/> runtime/test/arena_size_test.cppthen run the binary: builds with no warnings, prints the summary line, exit 0.clang++: exit 0. It prints three-Wmissing-field-initializerswarnings fromquery_arena_limits(lines 34 to 36), which this change does not touch.origin/mainheader: fails withline 32: decide_arena_size("-5", none).bytes == 16 * MiB, exit 1.-5,-1,-0,-5,-99999999999999999999andabcgive 16 MiB;99999999999999999999and99999give 4095 MiB;+20gives 20 MiB;0x20gives 16 MiB.python3 -I scripts/check_no_game_data.py runtime/src/arena_size.h runtime/test/arena_size_test.cpp: exit 0.git diff --check: clean.Not tested
arena_sizeon Windows.cteston Linux for the whole runtime tree (only the single test file was built and run).runtime/shims/d3d12_vulkan_device.cpp.origin/mainheader ran one at a time through the probe. The test stops at its firstfailing check (line 32), so the huge-negative check was not reached by the test binary on the unfixed header.
AI-assisted (Claude Code).